Guest User

Untitled

a guest
Jun 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.87 KB | None | 0 0
  1. import re
  2.  
  3. ###### here just enter the snowtam nothing else is required to run this script #####
  4. #note that only up to 2 runways can be supported, have fun
  5. text = '''A)EADD
  6. B) 12220945
  7. C) 08L
  8. F) 5/5/5
  9. G) 2/2/3
  10. H) 2/1/1
  11. N)5
  12. C)26R
  13. F) 1/1/1
  14. G) XX/XX/XX
  15.  
  16. H) 5/5/5
  17. N) 5
  18.  
  19. T) RUNWAY 08L CONTAMINATION 100 PERCENT.
  20. RUNWAY 08R CONTAMINATION 100 PERCENT - WET DUE TO CHEMICAL SPRAYING.
  21. ALL TWYS AND APRONS CONTAMINATED AT 100 PERCENT.'''
  22.  
  23. ##### DEPOSITS #######
  24. var_d_NIL = "Clear and dry"
  25. var_d_1 = "Damp"
  26. var_d_2 = "Wet or water patches"
  27. var_d_3 = "Rime (normally less than 1 mm deep)"
  28. var_d_4 = "Dry snow"
  29. var_d_5 = "Wet snow"
  30. var_d_6 = "Slush"
  31. var_d_7 = "Ice"
  32. var_d_8 = "Compact or rolled snow"
  33. var_d_9 = "Frozen ruts or ridges"
  34.  
  35. ##### BREAKING ACTION #####
  36. #estimated#
  37. A_BA_5 = 'Good'
  38. A_BA_4 = 'Medium/good'
  39. A_BA_3 = 'Medium'
  40. A_BA_2 = 'Medium/poor'
  41. A_BA_1 = 'Poor'
  42. A_BA_9 = 'Unreliable'
  43.  
  44.  
  45. type_BRD = 'Brakemeter-Dynometer'
  46. type_GRT = 'Grip Tester'
  47. type_MUM = 'Mu-meter'
  48. type_RFT = 'Runway friction tester'
  49. type_SFH = 'Surface friction tester (high pressure tires)'
  50. type_SFL = 'Surface friction tester (low pressure tires)'
  51. type_SKH = 'Skiddometer (high pressure tires)'
  52. type_SKL = 'Skiddometer (low pressure tires)'
  53. type_TAP = 'Tapleymeter'
  54.  
  55.  
  56.  
  57. ###### clean space mistakes if present at text #####
  58. text = re.sub("(?P<word>[A-Z]\))(?P<notspace>\S)", r"\g<word> \g<notspace>", text)
  59. text = re.sub("(?P<word>[A-Z]\))(?P<spaces>\s{2,30})", r"\g<word> ", text)
  60.  
  61. ##### correct for the last one ################
  62. text = text+"Z\)"
  63.  
  64. ###### check if multiple runways ##################
  65. list_multiple_runways = []
  66. list_multiple_runways_position = []
  67. p = re.compile("C\)")
  68. for m in p.finditer(text):
  69. list_multiple_runways.append( m.group())
  70. list_multiple_runways_position.append(m.start())
  71.  
  72. ####### CROP THE LAST STANDARD REGION #######
  73. text_end = ''
  74. counter_end_r = 0
  75. counter_end_s = 0
  76. counter_end_t = 0
  77. regex_end_r = (r'R\)')
  78. pattern_end_r = re.compile(regex_end_r,re.DOTALL)
  79. try:
  80. var_end = pattern_end_r.search(text).group()
  81. counter_end_r = 1
  82. except:
  83. pass
  84.  
  85. regex_end_s = (r'S\)')
  86. pattern_end_s = re.compile(regex_end_s,re.DOTALL)
  87. try:
  88. var_end = pattern_end_s.search(text).group()
  89. counter_end_s = 1
  90. except:
  91. pass
  92.  
  93. regex_end_t = (r'T\)')
  94. pattern_end_t = re.compile(regex_end_t,re.DOTALL)
  95. try:
  96. var_end = pattern_end_t.search(text).group()
  97. counter_end_t = 1
  98. except:
  99. pass
  100. try:
  101. if counter_end_r > 0 :
  102. regex_end= (r'R\)(.*?)\Z')
  103. pattern_end = re.compile(regex_end,re.DOTALL)
  104. text_end = pattern_end.search(text).group()
  105. elif counter_end_s > 0 :
  106. regex_end= (r'S\)(.*?)\Z')
  107. pattern_end = re.compile(regex_end,re.DOTALL)
  108. text_end = pattern_end.search(text).group()
  109.  
  110. elif counter_end_t > 0 :
  111. regex_end= (r'T\)(.*?)\Z')
  112. pattern_end = re.compile(regex_end,re.DOTALL)
  113. text_end = pattern_end.search(text).group()
  114. else:
  115. text_end = ''
  116. except:
  117. pass
  118.  
  119. ###### CROP C RUNWAYSSSS ############
  120.  
  121.  
  122.  
  123.  
  124. if len(list_multiple_runways) == 1:
  125. pass
  126. elif len (list_multiple_runways) == 2:
  127. text2 = text[:list_multiple_runways_position[1]]
  128. text2 = text2 + "Z\)"
  129. text3 = text[list_multiple_runways_position[1]:]
  130. list_all_text_double = [text2,text3]
  131. elif len (list_multiple_runways) >2:
  132. pass
  133.  
  134.  
  135.  
  136. #### run #####
  137.  
  138.  
  139.  
  140. if len(list_multiple_runways) == 1:
  141.  
  142. output_text = ""
  143.  
  144. regex_A = (r'A\)(.*?)\)')
  145. pattern = re.compile(regex_A,re.DOTALL)
  146. try:
  147. var_A = pattern.search(text).group()
  148. output_text = output_text + "\n" + "A)-->The aerodrome {} is the aerodrome the Snowtam is referred to.".format(var_A[3:-3])
  149.  
  150. except:
  151. pass
  152.  
  153.  
  154.  
  155.  
  156.  
  157. regex_B = (r'B\)(.*?)\)')
  158. pattern = re.compile(regex_B,re.DOTALL)
  159. try:
  160. var_B = pattern.search(text).group()
  161. output_text = output_text + "\n" + "B)-->Observation of the Snowtam is at {}nth Month at {}nth Day {}:{}UTC.".format(var_B[3:5],var_B[5:7],var_B[7:9],var_B[9:-3])
  162.  
  163. except:
  164. pass
  165.  
  166.  
  167.  
  168. regex_C = (r'C\)(.*?)\)')
  169. pattern = re.compile(regex_C,re.DOTALL)
  170. try:
  171. var_C = pattern.search(text).group()
  172. output_text = output_text + "\n" + "C)-->The runway,Snowtam refers to is runway {}.".format(var_C[3:-3])
  173.  
  174. except:
  175. pass
  176.  
  177. regex_D = (r'D\)(.*?)\)')
  178. pattern = re.compile(regex_D,re.DOTALL)
  179. try:
  180. var_D = pattern.search(text).group()
  181. output_text = output_text + "\n" + "D)-->The runway's clear of deposits lenght region is {} meters.".format(var_D[3:-3])
  182.  
  183. except:
  184. pass
  185.  
  186.  
  187. regex_E = (r'E\)(.*?)\)')
  188. pattern = re.compile(regex_E,re.DOTALL)
  189. try:
  190. var_E = pattern.search(text).group()
  191. output_text = output_text + "\n" + "E)-->The runway's clear of deposits width region is {} meters.\nInfo: If L or R is included here,the region is as viewed from the threshold having the lower runway designation number.".format(var_E[3:-3])
  192.  
  193. except:
  194. pass
  195.  
  196. regex_F = (r'F\)(.*?)\)')
  197. pattern = re.compile(regex_F,re.DOTALL)
  198. try:
  199.  
  200. var_F = pattern.search(text).group()
  201. var_F = var_F[3:-3]
  202. var_F = var_F.split("/")
  203.  
  204.  
  205.  
  206. var_F_first = ''
  207. var_F_second = ''
  208. var_F_third = ''
  209.  
  210. for i in range (0,3):
  211. if var_F[i] == "NIL":
  212. if i == 0:
  213. var_F_first = var_d_NIL
  214. elif i == 1:
  215. var_F_second = var_d_NIL
  216. else:
  217. var_F_third = var_d_NIL
  218. elif var_F[i] == "1":
  219. if i == 0:
  220. var_F_first = var_d_1
  221. elif i == 1:
  222. var_F_second = var_d_1
  223. else:
  224. var_F_third = var_d_1
  225. elif var_F[i] == "2":
  226. if i == 0:
  227. var_F_first = var_d_2
  228. elif i == 1:
  229. var_F_second = var_d_2
  230. else:
  231. var_F_third = var_d_2
  232. elif var_F[i] == "3":
  233. if i == 0:
  234. var_F_first = var_d_3
  235. elif i == 1:
  236. var_F_second = var_d_3
  237. else:
  238. var_F_third = var_d_3
  239. elif var_F[i] == "4":
  240. if i == 0:
  241. var_F_first = var_d_4
  242. elif i == 1:
  243. var_F_second = var_d_4
  244. else:
  245. var_F_third = var_d_4
  246. elif var_F[i] == "5":
  247. if i == 0:
  248. var_F_first = var_d_5
  249. elif i == 1:
  250. var_F_second = var_d_5
  251. else:
  252. var_F_third = var_d_5
  253. elif var_F[i] == "6":
  254. if i == 0:
  255. var_F_first = var_d_6
  256. elif i == 1:
  257. var_F_second = var_d_6
  258. else:
  259. var_F_third = var_d_6
  260. elif var_F[i] == "7":
  261. if i == 0:
  262. var_F_first = var_d_7
  263. elif i == 1:
  264. var_F_second = var_d_7
  265. else:
  266. var_F_third = var_d_7
  267. elif var_F[i] == "8":
  268. if i == 0:
  269. var_F_first = var_d_8
  270. elif i == 1:
  271. var_F_second = var_d_8
  272. else:
  273. var_F_third = var_d_8
  274. elif var_F[i] == "9":
  275. if i == 0:
  276. var_F_first = var_d_9
  277. elif i == 1:
  278. var_F_second = var_d_9
  279. else:
  280. var_F_third = var_d_9
  281.  
  282. multiple_first_c = ''
  283. c1 = 0
  284. if len(var_F[0]) > 1:
  285. multiple_first = var_F[0]
  286. for i in reversed(multiple_first):
  287. if i == '1':
  288. multiple_first_c = multiple_first_c + var_d_1 +" and on top "
  289. if i == '2':
  290. multiple_first_c = multiple_first_c + var_d_2 +" and on top "
  291. if i == '3':
  292. multiple_first_c = multiple_first_c + var_d_3 +" and on top "
  293. if i == '4':
  294. multiple_first_c = multiple_first_c + var_d_4 +" and on top "
  295. if i == '5':
  296. multiple_first_c = multiple_first_c + var_d_5 +" and on top "
  297. if i == '6':
  298. multiple_first_c = multiple_first_c + var_d_6 +" and on top "
  299. if i == '7':
  300. multiple_first_c = multiple_first_c + var_d_7 +" and on top "
  301. if i == '8':
  302. multiple_first_c = multiple_first_c + var_d_8 +" and on top "
  303. if i == '9':
  304. multiple_first_c = multiple_first_c + var_d_9 +" and on top "
  305. c1 = 1
  306.  
  307. c2 = 0
  308. multiple_second_c = ''
  309. if len(var_F[1]) > 1:
  310. multiple_second = var_F[1]
  311. for i in reversed(multiple_second):
  312. if i == '1':
  313. multiple_second_c = multiple_second_c + var_d_1 +" and on top "
  314. if i == '2':
  315. multiple_second_c = multiple_second_c + var_d_2 +" and on top "
  316. if i == '3':
  317. multiple_second_c = multiple_second_c + var_d_3 +" and on top "
  318. if i == '4':
  319. multiple_second_c = multiple_second_c + var_d_4 +" and on top "
  320. if i == '5':
  321. multiple_second_c = multiple_second_c + var_d_5 +" and on top "
  322. if i == '6':
  323. multiple_second_c = multiple_second_c + var_d_6 +" and on top "
  324. if i == '7':
  325. multiple_second_c = multiple_second_c + var_d_7 +" and on top "
  326. if i == '8':
  327. multiple_second_c = multiple_second_c + var_d_8 +" and on top "
  328. if i == '9':
  329. multiple_second_c = multiple_second_c + var_d_9 +" and on top "
  330. c2 = 1
  331.  
  332. c3 = 0
  333. multiple_third_c = ''
  334. if len(var_F[2]) > 1:
  335. multiple_third = var_F[2]
  336. for i in reversed(multiple_third):
  337. if i == '1':
  338. multiple_third_c = multiple_third_c + var_d_1 +" and on top "
  339. if i == '2':
  340. multiple_third_c = multiple_third_c + var_d_2 +" and on top "
  341. if i == '3':
  342. multiple_third_c = multiple_third_c + var_d_3 +" and on top "
  343. if i == '4':
  344. multiple_third_c = multiple_third_c + var_d_4 +" and on top "
  345. if i == '5':
  346. multiple_third_c = multiple_third_c + var_d_5 +" and on top "
  347. if i == '6':
  348. multiple_third_c = multiple_third_c + var_d_6 +" and on top "
  349. if i == '7':
  350. multiple_third_c = multiple_third_c + var_d_7 +" and on top "
  351. if i == '8':
  352. multiple_third_c = multiple_third_c + var_d_8 +" and on top "
  353. if i == '9':
  354. multiple_third_c = multiple_third_c + var_d_9 +" and on top "
  355. c3 = 1
  356.  
  357. if c1 > 0:
  358. var_F_first = multiple_first_c[:-12]
  359. if c2 > 0:
  360. var_F_second = multiple_second_c[:-12]
  361. if c3 > 0:
  362. var_F_third = multiple_third_c[:-12]
  363.  
  364.  
  365. output_text = output_text + "\n" + "F)-->The runway's first thrird has {} , second third has {} ,and the third part has {}.\nInfo: Deposit over total runway length, observed on each third of the runway, starting from threshold having the lower runway designation number.".format(var_F_first,var_F_second,var_F_third)
  366.  
  367. except:
  368. pass
  369.  
  370.  
  371. regex_G = (r'G\)(.*?)\)')
  372. pattern = re.compile(regex_G,re.DOTALL)
  373. try:
  374. var_G = pattern.search(text).group()
  375. var_G = var_G[3:-3]
  376. var_G = var_G.split('/')
  377. output_text = output_text + "\n" + "G)-->The runway's mean depth deposit at first thrird is {}mm , at second third is {}mm ,and the third part is {}mm.(All numbers in milimeters(mm))\nInfo:Observed on each third of the runway, starting from threshold having the lower runway designation number.\nIf XX , it means that the deposit is not measurable or operationally not significant.".format(var_G[0],var_G[1],var_G[2])
  378.  
  379. except:
  380. pass
  381.  
  382.  
  383. regex_H = (r'H\)(.*?)\)')
  384. pattern = re.compile(regex_H,re.DOTALL)
  385. var_H_E_first = ''
  386. var_H_E_second = ''
  387. var_H_E_third = ''
  388.  
  389. var_H_A_first = ''
  390. var_H_A_second = ''
  391. var_H_A_third = ''
  392.  
  393. var_H_machine = ''
  394.  
  395.  
  396. try:
  397. var_H = pattern.search(text).group()
  398. var_H = var_H[3:-3]
  399. if len(var_H) < 7:
  400. var_H = var_H.split("/")
  401. if var_H[0] == "5":
  402. var_H_E_first = A_BA_5
  403. elif var_H[0] == "4":
  404. var_H_E_first = A_BA_4
  405. elif var_H[0] == "3":
  406. var_H_E_first = A_BA_3
  407. elif var_H[0] == "2":
  408. var_H_E_first = A_BA_2
  409. elif var_H[0] == "1":
  410. var_H_E_first = A_BA_1
  411. elif var_H[0] == "9":
  412. var_H_E_first = A_BA_9
  413.  
  414. if var_H[1] == "5":
  415. var_H_E_second = A_BA_5
  416. elif var_H[1] == "4":
  417. var_H_E_second = A_BA_4
  418. elif var_H[1] == "3":
  419. var_H_E_second = A_BA_3
  420. elif var_H[1] == "2":
  421. var_H_E_second = A_BA_2
  422. elif var_H[1] == "1":
  423. var_H_E_second = A_BA_1
  424. elif var_H[1] == "9":
  425. var_H_E_second = A_BA_9
  426.  
  427. if var_H[2] == "5":
  428. var_H_E_third = A_BA_5
  429. elif var_H[2] == "4":
  430. var_H_E_third = A_BA_4
  431. elif var_H[2] == "3":
  432. var_H_E_third = A_BA_3
  433. elif var_H[2] == "2":
  434. var_H_E_third = A_BA_2
  435. elif var_H[2] == "1":
  436. var_H_E_third = A_BA_1
  437. elif var_H[2] == "9":
  438. var_H_E_third = A_BA_9
  439. output_text = output_text + "\n" + "H)-->The runway's estimated(not from machine) Friction measurment(breaking action) at the first thrird is {}, at the second third is {},and at the third part is {}.".format(var_H_E_first,var_H_E_second,var_H_E_third)
  440. else:
  441. var_H = var_H.split("/")
  442. if int(var_H[0]) <= 25:
  443. var_H_A_first = A_BA_1
  444. elif int(var_H[0]) <= 29:
  445. var_H_A_first = A_BA_2
  446. elif int(var_H[0]) <= 35:
  447. var_H_A_first = A_BA_3
  448. elif int(var_H[0]) <= 39:
  449. var_H_A_first = A_BA_4
  450. elif int(var_H[0]) >= 40:
  451. var_H_A_first = A_BA_5
  452.  
  453. if int(var_H[1]) <= 25:
  454. var_H_A_second = A_BA_1
  455. elif int(var_H[1]) <= 29:
  456. var_H_A_second = A_BA_2
  457. elif int(var_H[1]) <= 35:
  458. var_H_A_second = A_BA_3
  459. elif int(var_H[1]) <= 39:
  460. var_H_A_second = A_BA_4
  461. elif int(var_H[1]) >= 40:
  462. var_H_A_second = A_BA_5
  463.  
  464.  
  465. if int(var_H[2][:2]) <= 25:
  466. var_H_A_third = A_BA_1
  467. elif int(var_H[2][:2]) <= 29:
  468. var_H_A_third = A_BA_2
  469. elif int(var_H[2][:2]) <= 35:
  470. var_H_A_third = A_BA_3
  471. elif int(var_H[2][:2]) <= 39:
  472. var_H_A_third = A_BA_4
  473. elif int(var_H[2][:2]) >= 40:
  474. var_H_A_third = A_BA_5
  475.  
  476. if 'BRD' in var_H[2]:
  477. var_H_machine = type_BRD
  478. elif 'GRT' in var_H[2]:
  479. var_H_machine = type_GRT
  480. elif 'MUM' in var_H[2]:
  481. var_H_machine = type_MUM
  482. elif 'RFT' in var_H[2]:
  483. var_H_machine = type_RFT
  484. elif 'SFH' in var_H[2]:
  485. var_H_machine = type_SFH
  486. elif 'SFL' in var_H[2]:
  487. var_H_machine = type_SFL
  488. elif 'SKH' in var_H[2]:
  489. var_H_machine = type_SKH
  490. elif 'SKL' in var_H[2]:
  491. var_H_machine = type_SKL
  492. elif 'TAP' in var_H[2]:
  493. var_H_machine = type_TAP
  494. else:
  495. var_H_machine = 'Unknown'
  496. output_text = output_text + "\n" + "H)-->The runway's Measured(by machine) Friction (breaking action) at the first thrird is {}, at the second third is {},and at the third part is {}.\nThe measurement was made by a {}.".format(var_H_A_first,var_H_A_second,var_H_A_third,var_H_machine)
  497. except:
  498. pass
  499.  
  500.  
  501.  
  502.  
  503. regex_J = (r'J\)(.*?)\)')
  504. pattern = re.compile(regex_J,re.DOTALL)
  505. try:
  506. var_J = pattern.search(text).group()
  507. var_J = var_J[3:-3]
  508. var_J_1 = 0
  509. var_J_2 = 0
  510. if "L" in var_J:
  511. var_J_1 = 1
  512. var_J = var_J.replace("L","")
  513. if "R" in var_J:
  514. var_J_2 = 1
  515. var_J = var_J.replace("R","")
  516.  
  517. var_J_C = var_J.split("/")
  518.  
  519. if var_J_1 == 0 and var_J_2 == 0:
  520. output_text = output_text + "\n" + "J)-->There are critical snowbanks {}cm high,{} meters from the edge of the runway.".format(var_J_C[0],var_J_C[1])
  521. elif var_J_1 > 0 and var_J_2 > 0:
  522. output_text = output_text + "\n" + "J)-->There are critical snowbanks {}cm high,{} meters from the edge of the runway both at left and right side.".format(var_J_C[0],var_J_C[1])
  523. elif var_J_1 > 0 and var_J_2 == 0:
  524. output_text = output_text + "\n" + "J)-->There are critical snowbanks {}cm high,{} meters from the edge of the runway at the left side.".format(var_J_C[0],var_J_C[1])
  525. elif var_J_1 == 0 and var_J_2 > 0:
  526. output_text = output_text + "\n" + "J)-->There are critical snowbanks {}cm high,{} meters from the edge of the runway at the right side.".format(var_J_C[0],var_J_C[1])
  527. except:
  528. pass
  529.  
  530.  
  531. regex_K = (r'K\)(.*?)\)')
  532. pattern = re.compile(regex_K,re.DOTALL)
  533. try:
  534. var_K = pattern.search(text).group()
  535. var_K = var_K[3:-3]
  536. cnt_K1 = 0
  537. cnt_K2 = 0
  538. if "L" in var_K:
  539. cnt_K1 = 1
  540. if "R" in var_K:
  541. cnt_K2 = 1
  542.  
  543. if cnt_K1 == 0 and cnt_K2 == 0:
  544. output_text = output_text + "\n" + "K)-->The runway lights are obscured."
  545. elif cnt_K1 > 0 and cnt_K2 == 0:
  546. output_text = output_text + "\n" + "K)-->The runway lights are on the left side is obscured.\nInfo:As viewed from the threshold having the lower runway designation number."
  547. elif cnt_K1 == 0 and cnt_K2 > 0:
  548. output_text = output_text + "\n" + "K)-->The runway lights are on the right side is obscured.\nInfo:As viewed from the threshold having the lower runway designation number."
  549. elif cnt_K1 > 0 and cnt_K2 > 0:
  550. output_text = output_text + "\n" + "K)-->The runway lights are obscured on both sides of the runway."
  551. except:
  552. pass
  553.  
  554.  
  555.  
  556. regex_L = (r'L\)(.*?)\)')
  557. pattern = re.compile(regex_L,re.DOTALL)
  558. try:
  559. var_L = pattern.search(text).group()
  560. var_L = var_L[3:-3]
  561. if "TOTAL" in var_L:
  562. output_text = output_text + "\n" + "L)-->The whole runway will be cleared.\nInfo:If it is provided in item M) is the time in UTC when the runway will be cleared."
  563. else:
  564. var_L_c = var_L.split("/")
  565. output_text = output_text + "\n" + "L)-->Another {} meters in lenght and {} meters in width will be cleared.\nInfo:If it is provided in item M) is the time in UTC when the runway will be cleared.".format(var_L_c[0],var_L_c[1])
  566. except:
  567. pass
  568.  
  569.  
  570. regex_M = (r'M\)(.*?)\)')
  571. pattern = re.compile(regex_M,re.DOTALL)
  572. try:
  573. var_M = pattern.search(text).group()
  574. var_M = var_M[3:-3]
  575.  
  576. output_text = output_text + "\n" + "M)-->The runway is expected to be cleared by the time {} UTC.".format(var_M)
  577.  
  578. except:
  579. pass
  580.  
  581.  
  582. regex_N = (r'N\)(.*?)\)')
  583. pattern = re.compile(regex_N,re.DOTALL)
  584. try:
  585. var_N = pattern.search(text).group()
  586. var_N = var_N[3:-3]
  587.  
  588. output_text = output_text + "\n" + "N)-->The taxiway condition associated with the runway(typically in plain language or as runways but not in thirds).\nInfos:\nCheatSheet\n\t5 : Good\n\t4 : Medium/good\n\t3 : Medium\n\t2 : Medium/poor\n\t1 : Poor\n\t9 : Unreliable"
  589.  
  590. except:
  591. pass
  592.  
  593.  
  594. regex_P = (r'P\)(.*?)\)')
  595. pattern = re.compile(regex_P,re.DOTALL)
  596. try:
  597. var_P = pattern.search(text).group()
  598. var_P = var_P[3:-3]
  599. var_P = var_P.replace("YES","")
  600.  
  601. output_text = output_text + "\n" + "P)-->In taxiways connected to aerodrome there are various snowbanks greater than 60cm high,and the distance between them is about {} meters.".format(var_P)
  602.  
  603. except:
  604. pass
  605.  
  606.  
  607. regex_R = (r'R\)(.*?)\)')
  608. pattern = re.compile(regex_R,re.DOTALL)
  609. try:
  610. var_R = pattern.search(text).group()
  611. var_R = var_R[3:-3]
  612.  
  613. output_text = output_text + "\n" + "R)-->The Aprons conditions (typically in plain language or as runways but not in thirds).\nInfos:\nCheatSheet\n\t5 : Good\n\t4 : Medium/good\n\t3 : Medium\n\t2 : Medium/poor\n\t1 : Poor\n\t9 : Unreliable"
  614.  
  615. except:
  616. pass
  617.  
  618.  
  619.  
  620.  
  621.  
  622. regex_S = (r'S\)(.*?)\)')
  623. pattern = re.compile(regex_S,re.DOTALL)
  624. try:
  625. var_S = pattern.search(text).group()
  626. var_S = var_S[3:-3]
  627.  
  628.  
  629. output_text = output_text + "\n" + "S)-->Next observation from airport is anticipated at the {}nth Month at {}nth Day {}:{}UTC.".format(var_S[0:2],var_S[2:4],var_S[4:6],var_S[6:8])
  630.  
  631. except:
  632. pass
  633.  
  634.  
  635.  
  636. regex_T = (r'T\)(.*?)\)')
  637. pattern = re.compile(regex_T,re.DOTALL)
  638. try:
  639. var_T = pattern.search(text).group()
  640. var_T = var_T[3:-3]
  641.  
  642.  
  643. output_text = output_text + "\n" + "T)-->Open language remarks:{}".format(var_T)
  644.  
  645. except:
  646. pass
  647.  
  648.  
  649.  
  650. if len(list_multiple_runways) == 2:
  651. output_text = ""
  652. for x in list_all_text_double:
  653. output_text = output_text+"\n"
  654.  
  655. regex_A = (r'A\)(.*?)\)')
  656. pattern = re.compile(regex_A,re.DOTALL)
  657. try:
  658. var_A = pattern.search(str(x)).group()
  659. output_text = output_text + "\n" + "A)-->The aerodrome {} is the aerodrome the Snowtam is referred to.".format(var_A[3:-3])
  660.  
  661. except:
  662. pass
  663.  
  664.  
  665.  
  666.  
  667.  
  668. regex_B = (r'B\)(.*?)\)')
  669. pattern = re.compile(regex_B,re.DOTALL)
  670. try:
  671. var_B = pattern.search(str(x)).group()
  672. output_text = output_text + "\n" + "B)-->Observation of the Snowtam is at {}nth Month at {}nth Day {}:{}UTC.".format(var_B[3:5],var_B[5:7],var_B[7:9],var_B[9:-3])
  673.  
  674. except:
  675. pass
  676.  
  677.  
  678.  
  679. regex_C = (r'C\)(.*?)\)')
  680. pattern = re.compile(regex_C,re.DOTALL)
  681. try:
  682. var_C = pattern.search(str(x)).group()
  683. output_text = output_text + "\n" + "C)-->The runway,Snowtam refers to is runway {}.".format(var_C[3:-3])
  684.  
  685. except:
  686. pass
  687.  
  688. regex_D = (r'D\)(.*?)\)')
  689. pattern = re.compile(regex_D,re.DOTALL)
  690. try:
  691. var_D = pattern.search(str(x)).group()
  692. output_text = output_text + "\n" + "D)-->The runway's clear of deposits lenght region is {} meters.".format(var_D[3:-3])
  693.  
  694. except:
  695. pass
  696.  
  697.  
  698. regex_E = (r'E\)(.*?)\)')
  699. pattern = re.compile(regex_E,re.DOTALL)
  700. try:
  701. var_E = pattern.search(str(x)).group()
  702. output_text = output_text + "\n" + "E)-->The runway's clear of deposits width region is {} meters.\nInfo: If L or R is included here,the region is as viewed from the threshold having the lower runway designation number.".format(var_E[3:-3])
  703.  
  704. except:
  705. pass
  706.  
  707. regex_F = (r'F\)(.*?)\)')
  708. pattern = re.compile(regex_F,re.DOTALL)
  709. try:
  710.  
  711. var_F = pattern.search(str(x)).group()
  712. var_F = var_F[3:-3]
  713. var_F = var_F.split("/")
  714.  
  715.  
  716.  
  717. var_F_first = ''
  718. var_F_second = ''
  719. var_F_third = ''
  720.  
  721. for i in range (0,3):
  722. if var_F[i] == "NIL":
  723. if i == 0:
  724. var_F_first = var_d_NIL
  725. elif i == 1:
  726. var_F_second = var_d_NIL
  727. else:
  728. var_F_third = var_d_NIL
  729. elif var_F[i] == "1":
  730. if i == 0:
  731. var_F_first = var_d_1
  732. elif i == 1:
  733. var_F_second = var_d_1
  734. else:
  735. var_F_third = var_d_1
  736. elif var_F[i] == "2":
  737. if i == 0:
  738. var_F_first = var_d_2
  739. elif i == 1:
  740. var_F_second = var_d_2
  741. else:
  742. var_F_third = var_d_2
  743. elif var_F[i] == "3":
  744. if i == 0:
  745. var_F_first = var_d_3
  746. elif i == 1:
  747. var_F_second = var_d_3
  748. else:
  749. var_F_third = var_d_3
  750. elif var_F[i] == "4":
  751. if i == 0:
  752. var_F_first = var_d_4
  753. elif i == 1:
  754. var_F_second = var_d_4
  755. else:
  756. var_F_third = var_d_4
  757. elif var_F[i] == "5":
  758. if i == 0:
  759. var_F_first = var_d_5
  760. elif i == 1:
  761. var_F_second = var_d_5
  762. else:
  763. var_F_third = var_d_5
  764. elif var_F[i] == "6":
  765. if i == 0:
  766. var_F_first = var_d_6
  767. elif i == 1:
  768. var_F_second = var_d_6
  769. else:
  770. var_F_third = var_d_6
  771. elif var_F[i] == "7":
  772. if i == 0:
  773. var_F_first = var_d_7
  774. elif i == 1:
  775. var_F_second = var_d_7
  776. else:
  777. var_F_third = var_d_7
  778. elif var_F[i] == "8":
  779. if i == 0:
  780. var_F_first = var_d_8
  781. elif i == 1:
  782. var_F_second = var_d_8
  783. else:
  784. var_F_third = var_d_8
  785. elif var_F[i] == "9":
  786. if i == 0:
  787. var_F_first = var_d_9
  788. elif i == 1:
  789. var_F_second = var_d_9
  790. else:
  791. var_F_third = var_d_9
  792.  
  793. multiple_first_c = ''
  794. c1 = 0
  795. if len(var_F[0]) > 1:
  796. multiple_first = var_F[0]
  797. for i in reversed(multiple_first):
  798. if i == '1':
  799. multiple_first_c = multiple_first_c + var_d_1 +" and on top "
  800. if i == '2':
  801. multiple_first_c = multiple_first_c + var_d_2 +" and on top "
  802. if i == '3':
  803. multiple_first_c = multiple_first_c + var_d_3 +" and on top "
  804. if i == '4':
  805. multiple_first_c = multiple_first_c + var_d_4 +" and on top "
  806. if i == '5':
  807. multiple_first_c = multiple_first_c + var_d_5 +" and on top "
  808. if i == '6':
  809. multiple_first_c = multiple_first_c + var_d_6 +" and on top "
  810. if i == '7':
  811. multiple_first_c = multiple_first_c + var_d_7 +" and on top "
  812. if i == '8':
  813. multiple_first_c = multiple_first_c + var_d_8 +" and on top "
  814. if i == '9':
  815. multiple_first_c = multiple_first_c + var_d_9 +" and on top "
  816. c1 = 1
  817.  
  818. c2 = 0
  819. multiple_second_c = ''
  820. if len(var_F[1]) > 1:
  821. multiple_second = var_F[1]
  822. for i in reversed(multiple_second):
  823. if i == '1':
  824. multiple_second_c = multiple_second_c + var_d_1 +" and on top "
  825. if i == '2':
  826. multiple_second_c = multiple_second_c + var_d_2 +" and on top "
  827. if i == '3':
  828. multiple_second_c = multiple_second_c + var_d_3 +" and on top "
  829. if i == '4':
  830. multiple_second_c = multiple_second_c + var_d_4 +" and on top "
  831. if i == '5':
  832. multiple_second_c = multiple_second_c + var_d_5 +" and on top "
  833. if i == '6':
  834. multiple_second_c = multiple_second_c + var_d_6 +" and on top "
  835. if i == '7':
  836. multiple_second_c = multiple_second_c + var_d_7 +" and on top "
  837. if i == '8':
  838. multiple_second_c = multiple_second_c + var_d_8 +" and on top "
  839. if i == '9':
  840. multiple_second_c = multiple_second_c + var_d_9 +" and on top "
  841. c2 = 1
  842.  
  843. c3 = 0
  844. multiple_third_c = ''
  845. if len(var_F[2]) > 1:
  846. multiple_third = var_F[2]
  847. for i in reversed(multiple_third):
  848. if i == '1':
  849. multiple_third_c = multiple_third_c + var_d_1 +" and on top "
  850. if i == '2':
  851. multiple_third_c = multiple_third_c + var_d_2 +" and on top "
  852. if i == '3':
  853. multiple_third_c = multiple_third_c + var_d_3 +" and on top "
  854. if i == '4':
  855. multiple_third_c = multiple_third_c + var_d_4 +" and on top "
  856. if i == '5':
  857. multiple_third_c = multiple_third_c + var_d_5 +" and on top "
  858. if i == '6':
  859. multiple_third_c = multiple_third_c + var_d_6 +" and on top "
  860. if i == '7':
  861. multiple_third_c = multiple_third_c + var_d_7 +" and on top "
  862. if i == '8':
  863. multiple_third_c = multiple_third_c + var_d_8 +" and on top "
  864. if i == '9':
  865. multiple_third_c = multiple_third_c + var_d_9 +" and on top "
  866. c3 = 1
  867.  
  868. if c1 > 0:
  869. var_F_first = multiple_first_c[:-12]
  870. if c2 > 0:
  871. var_F_second = multiple_second_c[:-12]
  872. if c3 > 0:
  873. var_F_third = multiple_third_c[:-12]
  874.  
  875.  
  876. output_text = output_text + "\n" + "F)-->The runway's first thrird has {} , second third has {} ,and the third part has {}.\nInfo: Deposit over total runway length, observed on each third of the runway, starting from threshold having the lower runway designation number.".format(var_F_first,var_F_second,var_F_third)
  877.  
  878. except:
  879. pass
  880.  
  881.  
  882. regex_G = (r'G\)(.*?)\)')
  883. pattern = re.compile(regex_G,re.DOTALL)
  884. try:
  885. var_G = pattern.search(str(x)).group()
  886. var_G = var_G[3:-3]
  887. var_G = var_G.split('/')
  888. output_text = output_text + "\n" + "G)-->The runway's mean depth deposit at first thrird is {}mm , at second third is {}mm ,and the third part is {}mm.(All numbers in milimeters(mm))\nInfo:Observed on each third of the runway, starting from threshold having the lower runway designation number.\nIf XX , it means that the deposit is not measurable or operationally not significant.".format(var_G[0],var_G[1],var_G[2])
  889.  
  890. except:
  891. pass
  892.  
  893.  
  894. regex_H = (r'H\)(.*?)\)')
  895. pattern = re.compile(regex_H,re.DOTALL)
  896. var_H_E_first = ''
  897. var_H_E_second = ''
  898. var_H_E_third = ''
  899.  
  900. var_H_A_first = ''
  901. var_H_A_second = ''
  902. var_H_A_third = ''
  903.  
  904. var_H_machine = ''
  905.  
  906.  
  907. try:
  908. var_H = pattern.search(str(x)).group()
  909. var_H = var_H[3:-3]
  910. if len(var_H) < 7:
  911. var_H = var_H.split("/")
  912. if var_H[0] == "5":
  913. var_H_E_first = A_BA_5
  914. elif var_H[0] == "4":
  915. var_H_E_first = A_BA_4
  916. elif var_H[0] == "3":
  917. var_H_E_first = A_BA_3
  918. elif var_H[0] == "2":
  919. var_H_E_first = A_BA_2
  920. elif var_H[0] == "1":
  921. var_H_E_first = A_BA_1
  922. elif var_H[0] == "9":
  923. var_H_E_first = A_BA_9
  924.  
  925. if var_H[1] == "5":
  926. var_H_E_second = A_BA_5
  927. elif var_H[1] == "4":
  928. var_H_E_second = A_BA_4
  929. elif var_H[1] == "3":
  930. var_H_E_second = A_BA_3
  931. elif var_H[1] == "2":
  932. var_H_E_second = A_BA_2
  933. elif var_H[1] == "1":
  934. var_H_E_second = A_BA_1
  935. elif var_H[1] == "9":
  936. var_H_E_second = A_BA_9
  937.  
  938. if var_H[2] == "5":
  939. var_H_E_third = A_BA_5
  940. elif var_H[2] == "4":
  941. var_H_E_third = A_BA_4
  942. elif var_H[2] == "3":
  943. var_H_E_third = A_BA_3
  944. elif var_H[2] == "2":
  945. var_H_E_third = A_BA_2
  946. elif var_H[2] == "1":
  947. var_H_E_third = A_BA_1
  948. elif var_H[2] == "9":
  949. var_H_E_third = A_BA_9
  950. output_text = output_text + "\n" + "H)-->The runway's estimated(not from machine) Friction measurment(breaking action) at the first thrird is {}, at the second third is {},and at the third part is {}.".format(var_H_E_first,var_H_E_second,var_H_E_third)
  951. else:
  952. var_H = var_H.split("/")
  953. if int(var_H[0]) <= 25:
  954. var_H_A_first = A_BA_1
  955. elif int(var_H[0]) <= 29:
  956. var_H_A_first = A_BA_2
  957. elif int(var_H[0]) <= 35:
  958. var_H_A_first = A_BA_3
  959. elif int(var_H[0]) <= 39:
  960. var_H_A_first = A_BA_4
  961. elif int(var_H[0]) >= 40:
  962. var_H_A_first = A_BA_5
  963.  
  964. if int(var_H[1]) <= 25:
  965. var_H_A_second = A_BA_1
  966. elif int(var_H[1]) <= 29:
  967. var_H_A_second = A_BA_2
  968. elif int(var_H[1]) <= 35:
  969. var_H_A_second = A_BA_3
  970. elif int(var_H[1]) <= 39:
  971. var_H_A_second = A_BA_4
  972. elif int(var_H[1]) >= 40:
  973. var_H_A_second = A_BA_5
  974.  
  975.  
  976. if int(var_H[2][:2]) <= 25:
  977. var_H_A_third = A_BA_1
  978. elif int(var_H[2][:2]) <= 29:
  979. var_H_A_third = A_BA_2
  980. elif int(var_H[2][:2]) <= 35:
  981. var_H_A_third = A_BA_3
  982. elif int(var_H[2][:2]) <= 39:
  983. var_H_A_third = A_BA_4
  984. elif int(var_H[2][:2]) >= 40:
  985. var_H_A_third = A_BA_5
  986.  
  987. if 'BRD' in var_H[2]:
  988. var_H_machine = type_BRD
  989. elif 'GRT' in var_H[2]:
  990. var_H_machine = type_GRT
  991. elif 'MUM' in var_H[2]:
  992. var_H_machine = type_MUM
  993. elif 'RFT' in var_H[2]:
  994. var_H_machine = type_RFT
  995. elif 'SFH' in var_H[2]:
  996. var_H_machine = type_SFH
  997. elif 'SFL' in var_H[2]:
  998. var_H_machine = type_SFL
  999. elif 'SKH' in var_H[2]:
  1000. var_H_machine = type_SKH
  1001. elif 'SKL' in var_H[2]:
  1002. var_H_machine = type_SKL
  1003. elif 'TAP' in var_H[2]:
  1004. var_H_machine = type_TAP
  1005. else:
  1006. var_H_machine = 'Unknown'
  1007. output_text = output_text + "\n" + "H)-->The runway's Measured(by machine) Friction (breaking action) at the first thrird is {}, at the second third is {},and at the third part is {}.\nThe measurement was made by a {}.".format(var_H_A_first,var_H_A_second,var_H_A_third,var_H_machine)
  1008. except:
  1009. pass
  1010.  
  1011.  
  1012.  
  1013.  
  1014. regex_J = (r'J\)(.*?)\)')
  1015. pattern = re.compile(regex_J,re.DOTALL)
  1016. try:
  1017. var_J = pattern.search(str(x)).group()
  1018. var_J = var_J[3:-3]
  1019. var_J_1 = 0
  1020. var_J_2 = 0
  1021. if "L" in var_J:
  1022. var_J_1 = 1
  1023. var_J = var_J.replace("L","")
  1024. if "R" in var_J:
  1025. var_J_2 = 1
  1026. var_J = var_J.replace("R","")
  1027.  
  1028. var_J_C = var_J.split("/")
  1029.  
  1030. if var_J_1 == 0 and var_J_2 == 0:
  1031. output_text = output_text + "\n" + "J)-->There are critical snowbanks {}cm high,{} meters from the edge of the runway.".format(var_J_C[0],var_J_C[1])
  1032. elif var_J_1 > 0 and var_J_2 > 0:
  1033. output_text = output_text + "\n" + "J)-->There are critical snowbanks {}cm high,{} meters from the edge of the runway both at left and right side.".format(var_J_C[0],var_J_C[1])
  1034. elif var_J_1 > 0 and var_J_2 == 0:
  1035. output_text = output_text + "\n" + "J)-->There are critical snowbanks {}cm high,{} meters from the edge of the runway at the left side.".format(var_J_C[0],var_J_C[1])
  1036. elif var_J_1 == 0 and var_J_2 > 0:
  1037. output_text = output_text + "\n" + "J)-->There are critical snowbanks {}cm high,{} meters from the edge of the runway at the right side.".format(var_J_C[0],var_J_C[1])
  1038. except:
  1039. pass
  1040.  
  1041.  
  1042. regex_K = (r'K\)(.*?)\)')
  1043. pattern = re.compile(regex_K,re.DOTALL)
  1044. try:
  1045. var_K = pattern.search(str(x)).group()
  1046. var_K = var_K[3:-3]
  1047. cnt_K1 = 0
  1048. cnt_K2 = 0
  1049. if "L" in var_K:
  1050. cnt_K1 = 1
  1051. if "R" in var_K:
  1052. cnt_K2 = 1
  1053.  
  1054. if cnt_K1 == 0 and cnt_K2 == 0:
  1055. output_text = output_text + "\n" + "K)-->The runway lights are obscured."
  1056. elif cnt_K1 > 0 and cnt_K2 == 0:
  1057. output_text = output_text + "\n" + "K)-->The runway lights are on the left side is obscured.\nInfo:As viewed from the threshold having the lower runway designation number."
  1058. elif cnt_K1 == 0 and cnt_K2 > 0:
  1059. output_text = output_text + "\n" + "K)-->The runway lights are on the right side is obscured.\nInfo:As viewed from the threshold having the lower runway designation number."
  1060. elif cnt_K1 > 0 and cnt_K2 > 0:
  1061. output_text = output_text + "\n" + "K)-->The runway lights are obscured on both sides of the runway."
  1062. except:
  1063. pass
  1064.  
  1065.  
  1066.  
  1067. regex_L = (r'L\)(.*?)\)')
  1068. pattern = re.compile(regex_L,re.DOTALL)
  1069. try:
  1070. var_L = pattern.search(str(x)).group()
  1071. var_L = var_L[3:-3]
  1072. if "TOTAL" in var_L:
  1073. output_text = output_text + "\n" + "L)-->The whole runway will be cleared.\nInfo:If it is provided in item M) is the time in UTC when the runway will be cleared."
  1074. else:
  1075. var_L_c = var_L.split("/")
  1076. output_text = output_text + "\n" + "L)-->Another {} meters in lenght and {} meters in width will be cleared.\nInfo:If it is provided in item M) is the time in UTC when the runway will be cleared.".format(var_L_c[0],var_L_c[1])
  1077. except:
  1078. pass
  1079.  
  1080.  
  1081. regex_M = (r'M\)(.*?)\)')
  1082. pattern = re.compile(regex_M,re.DOTALL)
  1083. try:
  1084. var_M = pattern.search(str(x)).group()
  1085. var_M = var_M[3:-3]
  1086.  
  1087. output_text = output_text + "\n" + "M)-->The runway is expected to be cleared by the time {} UTC.".format(var_M)
  1088.  
  1089. except:
  1090. pass
  1091.  
  1092.  
  1093. regex_N = (r'N\)(.*?)\)')
  1094. pattern = re.compile(regex_N,re.DOTALL)
  1095. try:
  1096. var_N = pattern.search(str(x)).group()
  1097. var_N = var_N[3:-3]
  1098.  
  1099. output_text = output_text + "\n" + "N)-->The taxiway condition associated with the runway(typically in plain language or as runways but not in thirds).\nInfos:\nCheatSheet\n\t5 : Good\n\t4 : Medium/good\n\t3 : Medium\n\t2 : Medium/poor\n\t1 : Poor\n\t9 : Unreliable"
  1100.  
  1101. except:
  1102. pass
  1103.  
  1104.  
  1105. regex_P = (r'P\)(.*?)\)')
  1106. pattern = re.compile(regex_P,re.DOTALL)
  1107. try:
  1108. var_P = pattern.search(str(x)).group()
  1109. var_P = var_P[3:-3]
  1110. var_P = var_P.replace("YES","")
  1111.  
  1112. output_text = output_text + "\n" + "P)-->In taxiways connected to aerodrome there are various snowbanks greater than 60cm high,and the distance between them is about {} meters.".format(var_P)
  1113.  
  1114. except:
  1115. pass
  1116.  
  1117.  
  1118. regex_R = (r'R\)(.*?)\)')
  1119. pattern = re.compile(regex_R,re.DOTALL)
  1120. try:
  1121. var_R = pattern.search(str(x)).group()
  1122. var_R = var_R[3:-3]
  1123.  
  1124. output_text = output_text + "\n" + "R)-->The Aprons conditions (typically in plain language or as runways but not in thirds).\nInfos:\nCheatSheet\n\t5 : Good\n\t4 : Medium/good\n\t3 : Medium\n\t2 : Medium/poor\n\t1 : Poor\n\t9 : Unreliable"
  1125.  
  1126. except:
  1127. pass
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133. regex_S = (r'S\)(.*?)\)')
  1134. pattern = re.compile(regex_S,re.DOTALL)
  1135. try:
  1136. var_S = pattern.search(str(x)).group()
  1137. var_S = var_S[3:-3]
  1138.  
  1139.  
  1140. output_text = output_text + "\n" + "S)-->Next observation from airport is anticipated at the {}nth Month at {}nth Day {}:{}UTC.".format(var_S[0:2],var_S[2:4],var_S[4:6],var_S[6:8])
  1141.  
  1142. except:
  1143. pass
  1144.  
  1145.  
  1146.  
  1147. regex_T = (r'T\)(.*?)\)')
  1148. pattern = re.compile(regex_T,re.DOTALL)
  1149. try:
  1150. var_T = pattern.search(str(x)).group()
  1151. var_T = var_T[3:-3]
  1152.  
  1153.  
  1154. output_text = output_text + "\n" + "T)-->Open language remarks:{}".format(var_T)
  1155.  
  1156. except:
  1157. pass
  1158.  
  1159.  
  1160.  
  1161. if len(list_multiple_runways) > 2:
  1162. print ("Up to 2 runways")
  1163. else:
  1164. print (output_text)
Add Comment
Please, Sign In to add comment