22 lines
1.9 KiB
Python
22 lines
1.9 KiB
Python
import regex as re
|
|
letras = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E']
|
|
reemplazo_nie = {
|
|
'X': 0,
|
|
'Y': 1,
|
|
'Z': 2,
|
|
None: '',
|
|
}
|
|
meses = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']
|
|
|
|
t = r"((?P<prefijo>\+[0-9]+)? *(?P<parte1>\d{3})-(?P<parte2>\d{3})-(?P<parte3>\d{3}))|((?P<parte1>\d{3}) *(?P<parte2>\d{3}) *(?P<parte3>\d{3}))|( *\+(?P<num>(\d *){10,15}))"
|
|
T = re.compile(t)
|
|
|
|
d = r"(((?P<letrainicio>[X-Z])*(?P<numero>\d{7}))|(?P<numero>\d{8}))-(?P<letrafinal>[A-HJ-NP-TV-Z])" # cambiar, el nie son 7
|
|
D = re.compile(d, flags=re.I|re.M)
|
|
|
|
i = r"((?P<anyo>0{3}[1-9]|\d{4})-(?P<mes>0\d|1[0-2])-(?P<dia>[0-2]\d|3[01])\s+(?P<hora>[0-1]\d|2[0-4]):(?P<minuto>[0-5]\d))|((?P<mes>january|february|march|april|may|june|july|august|september|october|november|december)\s+(?P<dia>\d|[12]\d|3[01]),\s+(?P<anyo>0{3}[1-9]|\d{4})\s+(?P<hora>[1-9]|1[0-2]):(?P<minuto>[0-5]\d)\s+(?P<segundo>[ap]m))|((?P<hora>[01]\d|2[0-3]):(?P<minuto>[0-5]\d):(?P<segundo>[0-5]\d)\s+(?P<dia>[0-2]\d|3[01])/(?P<mes>0\d|1[0-2])/(?P<anyo>0{3}[1-9]|\d{4}))"
|
|
I = re.compile(i, flags=re.IGNORECASE)
|
|
|
|
R = r"( *(?P<Grados1>([0-2][0-9][0-9])|(3[0-5][0-9]))(?P<Minutos1>[0-6][0-9])(?P<Segundos1>[0-5][0-9]\.\d{4})(?P<Letra1>(N|S))(?P<Grados2>([0-2][0-9][0-9])|(3[0-5][0-9]))(?P<Minutos2>[0-5][0-9])(?P<Segundos2>[0-5][0-9]\.\d{4})(?P<Letra2>(W|E)) *)|( *(?P<Grados1>((1[0-9][0-9])|(2[0-9][0-9])|(3[0-5][0-9])|\d{2}|\d{1}))° *(?P<Minutos1>([0-5][0-9])|[0-9])' *(?P<Segundos1>(([0-5][0-9])|[0-9])\.\d{4})\" *(?P<Letra1>(N|S)) *, *(?P<Grados2>((1[0-9][0-9])|(2[0-9][0-9])|(3[0-5][0-9])|\d{2}|\d{1}))° *(?P<Minutos2>([0-5][0-9])|[0-9])' *(?P<Segundos2>(([0-5][0-9])|[0-9])\.\d{4})\" *(?P<Letra2>(W|E)) *)|( *((?P<Signo1>[+\- ]?)(?P<Coord1>(([1-8]?[0-9])\.\d+)|90)) *, *((?P<Signo2>[+\- ]?)(?P<Coord2>([1][0-7][0-9]\.\d+)|([1-9]?[0-9]\.\d+))|90) *)"
|
|
P = re.compile(R)
|