Skip to content

Cnp counties #407

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

Closed
wants to merge 13 commits into from
67 changes: 65 additions & 2 deletions stdnum/ro/cnp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

"""CNP (Cod Numeric Personal, Romanian Numerical Personal Code).

The CNP is a 13 digit number that includes information on the person's
Expand Down Expand Up @@ -67,7 +66,12 @@ def get_birth_date(number):
"""Split the date parts from the number and return the birth date."""
number = compact(number)
centuries = {
'1': 1900, '2': 1900, '3': 1800, '4': 1800, '5': 2000, '6': 2000,
'1': 1900,
'2': 1900,
'3': 1800,
'4': 1800,
'5': 2000,
'6': 2000,
} # we assume 1900 for the others in order to try to construct a date
year = int(number[1:3]) + centuries.get(number[0], 1900)
month = int(number[3:5])
Expand Down Expand Up @@ -105,3 +109,62 @@ def is_valid(number):
return bool(validate(number))
except ValidationError:
return False


def get_county(number):
"""Geting county names from sequence"""
number = compact(number)
counties = {
'01': 'Alba',
'02': 'Arad',
'03': 'Arges',
'04': 'Bacau',
'05': 'Bihor',
'06': 'Bistrita-Nasaud',
'07': 'Botosani',
'08': 'Brasov',
'09': 'Braila',
'10': 'Buzau',
'11': 'Caras-Severin',
'12': 'Cluj',
'13': 'Constanta',
'14': 'Covasna',
'15': 'Dambovita',
'16': 'Dolj',
'17': 'Galati',
'18': 'Gorj',
'19': 'Harghita',
'20': 'Hunedoara',
'21': 'Ialomita',
'22': 'Iasi',
'23': 'Ilfov',
'24': 'Maramures',
'25': 'Mehedinti',
'26': 'Mures',
'27': 'Neamt',
'28': 'Olt',
'29': 'Prahova',
'30': 'Satu Mare',
'31': 'Salaj',
'32': 'Sibiu',
'33': 'Suceava',
'34': 'Teleorman',
'35': 'Timis',
'36': 'Tulcea',
'37': 'Vaslui',
'38': 'Valcea',
'39': 'Vrancea',
'40': 'Bucuresti',
'41': 'Bucuresti - Sector 1',
'42': 'Bucuresti - Sector 2',
'43': 'Bucuresti - Sector 3',
'44': 'Bucuresti - Sector 4',
'45': 'Bucuresti - Sector 5',
'46': 'Bucuresti - Sector 6',
'51': 'Calarasi',
'52': 'Giurgiu',
'47': 'Bucuresti - Sector 7 (desfiintat)',
'48': 'Bucuresti - Sector 8 (desfiintat)'
}
county = counties.get(number[7:9], 'Alba')
return county