This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requirements | |
# - pip install zeep | |
# | |
# Mertcan GÖKGÖZ - 2019 | |
# PrismaCSI | |
# | |
import re | |
import zeep | |
from zeep.cache import SqliteCache | |
from zeep.transports import Transport | |
# Koşullara uyan ama kabul etmememiz gerekenlerin listesi | |
dont_accept_values = ( | |
'11111111111', | |
'11111111110', | |
'22222222220', | |
'33333333330', | |
'44444444440', | |
'55555555550', | |
'66666666660', | |
'77777777770', | |
'88888888880', | |
'99999999990' | |
) | |
# TC Kimlik numara algoritmaya göre doğrumu | |
def IsDogruTcMi(tckn: str) -> bool: | |
if tckn in dont_accept_values: | |
return False | |
if len(tckn) != 11: | |
return False | |
if not tckn.isdigit(): | |
return False | |
if int(tckn[0]) == 0: | |
return False | |
tckn_sumary = (sum([int(tckn[i]) for i in range(0, 9, 2)]) * 7 - sum([int(tckn[i]) for i in range(1, 9, 2)])) % 10 | |
if tckn_sumary != int(tckn[9]) or(sum([int(tckn[i]) for i in range(10)]) % 10) != int(tckn[10]): | |
return False | |
return True | |
# Suriyeli/Mülteci/İkame izni kontrolü | |
def IsSuriyeliMi(tckn: str) -> bool: | |
if tckn.startswith('99') or tckn.startswith('997'): | |
return True | |
transport = Transport(cache=SqliteCache(), timeout=10) | |
# Türk vatandaşlarını nüfus müdürlüğünden kontrol et | |
def TRIdentificationNumberValidator(tckn: str, ad: str, soyad: str, dogumyil: int) -> bool: | |
ApiHost = 'https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL' | |
Service = zeep.Client(wsdl=ApiHost, transport=transport) | |
ClientService = Service.service.TCKimlikNoDogrula(tckn, ad.upper(), soyad.upper(), dogumyil) | |
return ClientService | |
# Yabancı uyruklu vatandaşları nüfus müdürlüğünden kontrol et | |
def ForeignTRIdentificationNumberValidator(tckn: str, ad: str, soyad: str, dogumgun: int, dogumay: int, dogumyil: int) -> bool: | |
ApiHost = 'https://tckimlik.nvi.gov.tr/Service/KPSPublicYabanciDogrula.asmx?WSDL' | |
Service = zeep.Client(wsdl=ApiHost, transport=transport) | |
ClientService = Service.service.YabanciKimlikNoDogrula(tckn, ad.upper(), soyad.upper(), dogumgun, dogumay, dogumyil) | |
return ClientService | |
# Eski Nüfus Cüzdanı Doğrulama | |
def OldPersonAndIdentificationCardValidator(tckn: str, ad: str, soyad: str, dogumgun: int, dogumay: int, dogumyil: int, serino: str, cuzdan_no: int) -> bool: | |
ApiHost = 'https://tckimlik.nvi.gov.tr/Service/KPSPublicV2.asmx?WSDL' | |
Service = zeep.Client(wsdl=ApiHost, transport=transport) | |
ClientService = Service.service.KisiVeCuzdanDogrula(tckn, ad.upper(), soyad.upper(), dogumgun, dogumay, dogumyil, serino.upper(), cuzdan_no) | |
return ClientService | |
# Yeni Kimlik Kartı Doğrulama | |
def NewPersonAndIdentificationCardValidator(tckn: str, ad: str, soyad: str, dogumgun: int, dogumay: int, dogumyil: int, tck_seri_no: str) -> bool: | |
ApiHost = 'https://tckimlik.nvi.gov.tr/Service/KPSPublicV2.asmx?WSDL' | |
Service = zeep.Client(wsdl=ApiHost, transport=transport) | |
ClientService = Service.service.KisiVeCuzdanDogrula(tckn, ad.upper(), soyad.upper(), dogumgun, dogumay, dogumyil, tck_seri_no.upper()) | |
return ClientService | |
# Türk vatandaşları veya Ikamet izni olanları kontrol et | |
def tcValidatorClassify(tckn: str, ad: str, soyad: str, dogumgun: int, dogumay: int, dogumyil: int) -> bool: | |
if IsSuriyeliMi(tckn): | |
return ForeignTRIdentificationNumberValidator(tckn, ad.upper(), soyad.upper(), dogumgun, dogumay, dogumyil) | |
else: | |
return TRIdentificationNumberValidator(tckn, ad.upper(), soyad.upper(), dogumyil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment