diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-03-15 11:40:32 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-04-16 16:43:03 +0200 |
commit | d6b7e1aa72a6194d056fbcea80c77ddbac0e9c71 (patch) | |
tree | 7f3ec07afd4806f951d010a1b01815eb4e695fa4 | |
parent | 06f626043e419beb40408ea28a8bb47ef2c1ebb8 (diff) | |
download | Ishtar-d6b7e1aa72a6194d056fbcea80c77ddbac0e9c71.tar.bz2 Ishtar-d6b7e1aa72a6194d056fbcea80c77ddbac0e9c71.zip |
✨ Parcel: free input improvment - filter special spaces and stranges commas (refs #5790)
-rw-r--r-- | archaeological_operations/tests.py | 10 | ||||
-rw-r--r-- | archaeological_operations/utils.py | 5 |
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: |