Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode ritorna GIRGENTI (soppresso) invece di AGRIGENTO #16

Closed
AldoErco opened this issue Jan 25, 2022 · 4 comments
Closed

Decode ritorna GIRGENTI (soppresso) invece di AGRIGENTO #16

AldoErco opened this issue Jan 25, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@AldoErco
Copy link

Python version
3.8

Package version
0.3.7

Current behavior (bug description)
print(codicefiscale.decode('LNNFNC80A01A089K')) restituisce:
{'code': 'LNNFNC80A01A089K', 'omocodes': ['LNNFNC80A01A089K', 'LNNFNC80A01A08VZ', 'LNNFNC80A01A0UVL', 'LNNFNC80A01ALUVO', 'LNNFNC80A0MALUVG', 'LNNFNC80ALMALUVR', 'LNNFNC8LALMALUVC', 'LNNFNCULALMALUVZ'], 'sex': 'M', 'birthdate': datetime.datetime(1980, 1, 1, 0, 0), 'birthplace': {'code': 'A089', 'province': 'AG', 'name': 'GIRGENTI (soppresso)'}, 'raw': {'code': 'LNNFNC80A01A089K', 'surname': 'LNN', 'name': 'FNC', 'birthdate': '80A01', 'birthdate_year': '80', 'birthdate_month': 'A', 'birthdate_day': '01', 'birthplace': 'A089', 'cin': 'K'}}

Expected behavior
Mi aspetto come birthplace di trovare AGRIGENTO o al limite una lista con entrambi, non solo il comune soppresso.

Il CF LNNFNC80A01A089K è inventato ma il bug l'ho riscontrato con un CF vero.

@AldoErco AldoErco added the bug Something isn't working label Jan 25, 2022
@AldoErco
Copy link
Author

Se ho capito bene come è stato strutturato data.py e come i soppressi vengono sostituiti dagli attuali, allora in data.py line 5337 dovrebbe andare tra line 152 e 153.

AldoErco added a commit to AldoErco/python-codicefiscale that referenced this issue Jan 25, 2022
@AldoErco AldoErco mentioned this issue Jan 25, 2022
@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Jan 25, 2022

@AldoErco in data.py in comuni sono in ordine alfabetico, qui il problema è un altro (per questo motivo ti ho chiuso la PR) e non appena avrò tempo gli darò un'occhiata.

La gestione della lista dei comuni sarebbe completamente da rifare, perchè i comuni cambiano nel tempo, in sostanza bisognerebbe avere una lista dei comuni per ogni anno, in modo tale che in base alla data di nascita si possano ottenere le informazioni corrette e seguire il loro cambiamento nel corso degli anni a venire.

@AldoErco
Copy link
Author

@fabiocaccamo io ho rilevato in data.py che il pezzo di codice:

    for municipality in _MUNICIPALITIES:
        code = municipality['code']
        ...
        data['codes'][code] = municipality

prima processa la riga 153 e aggiunge al dictionary l'elemento data['codes']['A089']** = { "code": "A089", "province": "AG", "name": "AGRIGENTO" }
poi processa la 5337 e aggiorna per stessa chiave l'elemento data['codes']['A089'] = { "code": "A089", "province": "AG", "name": "GIRGENTI (soppresso)" }

Scusa se insisto, ma guardando il codice non capisco perché devono stare in ordine alfabetico, visto che _MUNICIPALITIES lo usi per costruire due dictionary e spostando quella riga:
-il dictionary data['codes'] assegna i valori corretti
-il dictionary data['municipalities'] mantiene gli stessi elementi chiave-valore solo spostando i due di GIRGENTI in alto. Ma poi siccome lo leggi per chiave, non cambia nulla.

Lo stesso problema c'è ad esempio su A014 e chissà quanti altri.

@fabiocaccamo
Copy link
Owner

@AldoErco you can upgrade to 0.3.9 version, this and other problems of the same nature have been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants