summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-03-15 11:40:32 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-03-15 14:13:05 +0100
commit3d3b3f13b33beca4909b5b3d617105a1e8b242fe (patch)
tree07321d72df65e355fcaa28e04aa8b13e3a90bc62
parentf1fe4253fff3a50a40d3d5064cabb400285bdde9 (diff)
downloadIshtar-3d3b3f13b33beca4909b5b3d617105a1e8b242fe.tar.bz2
Ishtar-3d3b3f13b33beca4909b5b3d617105a1e8b242fe.zip
✨ Parcel: free input improvment - filter special spaces and stranges commas (refs #5790)
-rw-r--r--archaeological_operations/tests.py10
-rw-r--r--archaeological_operations/utils.py5
2 files changed, 15 insertions, 0 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index baffffa26..e2a59345d 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -1660,6 +1660,16 @@ class ParcelTest(ImportTest, TestCase):
]
},
),
+ (
+ "1991\t:AI:\xa023\ufe5019\uff0c20",
+ {
+ "1991": [
+ ("AI", "19"),
+ ("AI", "20"),
+ ("AI", "23"),
+ ]
+ },
+ ),
)
# ),("Domaine public", {}
# ),("Tranche 1 : AV:4 à 6, 18, 80, 104 / partiellement : 5 et 18", {}
diff --git a/archaeological_operations/utils.py b/archaeological_operations/utils.py
index a571228b8..010716adb 100644
--- a/archaeological_operations/utils.py
+++ b/archaeological_operations/utils.py
@@ -485,6 +485,11 @@ def parse_parcels(parcel_str, insee_code=None, owner=None):
if len(town) >= 2 or not town:
return parcels
town = town[0]
+ parcel_str = parcel_str.strip().replace("\ufe50", ",").replace("\uff0c", ",").replace("\n", " ")
+ parcel_str = re.sub(r'\s+', ' ', parcel_str)
+ parcel_str = parcel_str.replace("à", "_aaaa_").replace("n°", "_nnnn_")
+ parcel_str = parcel_str.encode("ascii", "ignore").decode("utf-8")
+ parcel_str = parcel_str.replace("_aaaa_", "à").replace("_nnnn_", "n°")
m = PARCEL_YEAR_REGEXP.match(parcel_str)
year = None
if m: