Guest User

Untitled

a guest
Jul 23rd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. import sys
  2. import psycopg2
  3.  
  4.  
  5. W = "\033[0m" # white (normal)
  6. R = "\033[31m" # red
  7. T = "\033[93m" # tan
  8. G = "\033[32m" # green
  9. LG = "\033[1;32m" # light green
  10.  
  11. def prr1t(rows):
  12. for row in rows:
  13. if row is not None:
  14. row = row[1:]
  15. print(G + "-" * 45 + W)
  16. print(
  17. R + "\t" + "TC Kimlik Numarası" + W + ": " + G + str(row[0]) + W + "\n"
  18. )
  19.  
  20. print(R + "\t" + "Isim" + W + ": " + G + str(row[1]) + W)
  21. print(R + "\t" + "Soy Isim" + W + ": " + G + str(row[2]) + W + "\n")
  22.  
  23. print(R + "\t" + "Anne Adı" + W + ": " + G + str(row[3]) + W)
  24. print(R + "\t" + "Baba Adı" + W + ": " + G + str(row[4]) + W + "\n")
  25.  
  26. print(R + "\t" + "Cinsiyet" + W + ": " + G + str(row[5]) + W + "\n")
  27.  
  28. print(R + "\t" + "Doğum Şehiri" + W + ": " + G + str(row[6]) + W)
  29. print(R + "\t" + "Doğum Tarihi" + W + ": " + G + str(row[7]) + W + "\n")
  30.  
  31. print(R + "\t" + "Kutuk Şehir" + W + ": " + G + str(row[8]) + W)
  32. print(R + "\t" + "Kutuk İlce" + W + ": " + G + str(row[9]) + W + "\n")
  33.  
  34. print(R + "\t" + "İkamet Ettiği Şehir" + W + ": " + G + str(row[10]) + W)
  35. print(R + "\t" + "İkamet Ettiği Ilçe" + W + ": " + G + str(row[11]) + W)
  36. print(R + "\t" + "İkamet Ettiği Mahalle" + W + ": " + G + str(row[12]) + W)
  37. print(R + "\t" + "Sokak Adresi" + W + ": " + G + str(row[13]) + W)
  38. print(R + "\t" + "Kapı Numarası" + W + ": " + G + str(row[14]) + W + "\n")
  39.  
  40.  
  41.  
  42. def executeTc(ru):
  43. query = "SELECT * FROM citizen WHERE national_identifier='" + ru + "';"
  44. conn = psycopg2.connect(dbname="mernis", user="postgres", password="toor")
  45. cursor = conn.cursor()
  46. cursor.execute(query)
  47. rows = cursor.fetchall()
  48. return rows
  49.  
  50.  
  51. def pad(pad, string1=None, padLeft=None):
  52. if string1 == None:
  53. return pad
  54. if padLeft:
  55. return (pad + str(string1))[-len(pad) :]
  56. else:
  57. return (pad + str(string1))[: len(pad)]
  58.  
  59.  
  60. def sonIkiHane(tc):
  61. tc_rakam = []
  62. for i in range(0, 11):
  63. tc_rakam.append(int(tc) % 10)
  64. tc = (int(tc) - tc_rakam[i]) / 10
  65. tc_rakam = tc_rakam[::-1]
  66. cift = tc_rakam[0] + tc_rakam[2] + tc_rakam[4] + tc_rakam[6] + tc_rakam[8]
  67. tek = tc_rakam[1] + tc_rakam[3] + tc_rakam[5] + tc_rakam[7]
  68.  
  69. tc_rakam[9] = (7 * cift - tek) % 10
  70. tc_rakam[10] = (
  71. tc_rakam[9]
  72. + tc_rakam[8]
  73. + tc_rakam[7]
  74. + tc_rakam[6]
  75. + tc_rakam[5]
  76. + tc_rakam[4]
  77. + tc_rakam[3]
  78. + tc_rakam[2]
  79. + tc_rakam[1]
  80. + tc_rakam[0]
  81. ) % 10
  82.  
  83. return tc_rakam[9] * 10 + tc_rakam[10]
  84.  
  85.  
  86. def tc_new(tc, tc_sayisi, yasli):
  87. tc_sayisi = int(tc_sayisi)
  88. stringss = []
  89. tc5digit = int(str(tc)[0:5])
  90. tc4digit = int(str(tc)[5:9])
  91. while tc_sayisi:
  92. if yasli > 0:
  93. tc4digit = tc4digit - 1
  94. tc5digit = tc5digit + 3
  95. if tc5digit > 99999:
  96. tc5digit = tc5digit - 100000
  97. if tc4digit < 0:
  98. tc4digit = tc4digit + 10000
  99. else:
  100. tc5digit = tc5digit - 3
  101. tc4digit = tc4digit + 1
  102. if tc4digit > 9999:
  103. tc4digit = tc4digit - 10000
  104. if tc5digit < 0:
  105. tc5digit = tc5digit + 100000
  106. raw_tc = (
  107. pad("00000", str(tc5digit), True) + pad("0000", str(tc4digit), True) + "00"
  108. )
  109. stringss.append(
  110. pad("00000", str(tc5digit), True)
  111. + pad("0000", str(tc4digit), True)
  112. + pad("00", sonIkiHane(raw_tc), True)
  113. )
  114. tc_sayisi = tc_sayisi - 1
  115. return stringss
  116.  
  117.  
  118. # string = []
  119.  
  120. #
  121. def posibleFam(tc, x, y):
  122. print("Ailesinde ondan küçük olanlar")
  123. print("*"*30)
  124. ro = []
  125. anne34= tc_new(tc, x, 0)
  126. for poe in anne34:
  127. ro += executeTc(poe)
  128. prr1t(ro)
  129.  
  130. ro = []
  131.  
  132. print("Ailesinde ondan büyük olanlar")
  133. anne34= tc_new(tc, x, 1)
  134. for poe in anne34:
  135. ro += executeTc(poe)
  136. prr1t(ro)
  137. posibleFam(sys.argv[1], 4, 4)
Add Comment
Please, Sign In to add comment