From f0a69a3b49a1a8ad77949e58b35e44e09c6d88c5 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Fri, 8 Mar 2024 11:53:10 +0100 Subject: [PATCH 1/3] chore: cast type_siae as string --- .../aio_proxy/response/formatters/complements.py | 3 ++- aio/aio-proxy/aio_proxy/response/helpers.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/aio/aio-proxy/aio_proxy/response/formatters/complements.py b/aio/aio-proxy/aio_proxy/response/formatters/complements.py index 20fbc0f9..0b40fa1f 100644 --- a/aio/aio-proxy/aio_proxy/response/formatters/complements.py +++ b/aio/aio-proxy/aio_proxy/response/formatters/complements.py @@ -2,6 +2,7 @@ format_collectivite_territoriale, ) from aio_proxy.response.formatters.insee_bool import format_insee_bool +from aio_proxy.response.helpers import string_list_to_string from aio_proxy.response.unite_legale_model import Complements @@ -37,7 +38,7 @@ def get_field(field, default=None): statut_entrepreneur_spectacle = get_field( "statut_entrepreneur_spectacle", ) - type_siae = get_field("type_siae") + type_siae = string_list_to_string(get_field("type_siae")) return Complements( collectivite_territoriale=collectivite_territoriale, convention_collective_renseignee=convention_collective_renseignee, diff --git a/aio/aio-proxy/aio_proxy/response/helpers.py b/aio/aio-proxy/aio_proxy/response/helpers.py index 9552cd47..1275b38e 100755 --- a/aio/aio-proxy/aio_proxy/response/helpers.py +++ b/aio/aio-proxy/aio_proxy/response/helpers.py @@ -76,3 +76,14 @@ def evaluate_field(field_value): return None else: return None + + +def string_list_to_string(string_list): + if string_list.strip("[]") == "nan": + return None + else: + elements = string_list.strip("[]").split(", ") + # Remove surrounding quotes from each element + cleaned_elements = [element.strip("'") for element in elements] + # Join the elements into a single string + return ", ".join(cleaned_elements) From b3a8e587721b5f80249d7db471f6f02e39514785 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Fri, 8 Mar 2024 12:03:40 +0100 Subject: [PATCH 2/3] fix: add None case --- aio/aio-proxy/aio_proxy/response/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aio/aio-proxy/aio_proxy/response/helpers.py b/aio/aio-proxy/aio_proxy/response/helpers.py index 1275b38e..ff435817 100755 --- a/aio/aio-proxy/aio_proxy/response/helpers.py +++ b/aio/aio-proxy/aio_proxy/response/helpers.py @@ -79,7 +79,7 @@ def evaluate_field(field_value): def string_list_to_string(string_list): - if string_list.strip("[]") == "nan": + if string_list.strip("[]") == "nan" or string_list is None: return None else: elements = string_list.strip("[]").split(", ") From 2fc2b16664da4b21262e5092bedd9b1ee817ad29 Mon Sep 17 00:00:00 2001 From: HAEKADI Date: Fri, 8 Mar 2024 12:05:01 +0100 Subject: [PATCH 3/3] fix: add None case --- aio/aio-proxy/aio_proxy/response/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aio/aio-proxy/aio_proxy/response/helpers.py b/aio/aio-proxy/aio_proxy/response/helpers.py index ff435817..1946604b 100755 --- a/aio/aio-proxy/aio_proxy/response/helpers.py +++ b/aio/aio-proxy/aio_proxy/response/helpers.py @@ -79,7 +79,9 @@ def evaluate_field(field_value): def string_list_to_string(string_list): - if string_list.strip("[]") == "nan" or string_list is None: + if string_list is None: + return None + elif string_list.strip("[]") == "nan": return None else: elements = string_list.strip("[]").split(", ")