Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. Максим Емельяненко:
  2. def line_has_lesson(line):
  3. if len(line) >= 10 and line[10:14] != " ":
  4. return True
  5. else:
  6. return False
  7.  
  8. file = open('/home/overaid/Downloads/pdf2xml/Емельяненко Максим Владимирович. 01.09.2019 - 15.12.2019.(1).txt', 'r')
  9.  
  10. # Есть у нас разные дни недели, у них есть одинаковые атрибуты:
  11. # Номер данного урока в данный день недели, булеан дня недели
  12. # Количество пропусков, название дня недели. Че делать то
  13.  
  14. class schoolday(object):
  15. def init(self, weekday, lesson_number, ):
  16. self.weekday = self
  17. self.lesson_number = lesson_number
  18. self.is_weekday = False
  19. self.ncount = 0
  20. self.dayfile = ''
  21.  
  22.  
  23. # monday = schoolday(lesson_number=1)
  24. # tuesday = schoolday(lesson_number=1)
  25. # wednesday = schoolday(lesson_number=lesson_number)
  26. # thursday = schoolday(lesson_number=lesson_number)
  27. # friday = schoolday(lesson_number=lesson_number)
  28.  
  29. for ${WEEKDAY} in week
  30. for line in file:
  31. if ${WEEKDAY} in line:
  32. is_${WEEKDAY} = True # TODO: добавить обработку ДОПОЛНИТЕЛЬНОГО ОБРАЗОВАНИЯ
  33. is_${WEEKDAY-1} = False
  34. if is_${WEEKDAY} = True:
  35. if "8" >= line[0] >= "1": # parse schedule along with visits
  36. if line_has_lesson(line):
  37. schedule[line[0]] = line[10:36].strip() # strip removes whitespaces at the end of the string
  38. else:
  39. schedule[line[0]] = previous_line
  40. else:
  41. if line[0] == " ":
  42. previous_line = line[10:36].strip()
  43. else:
  44. pass
  45. ${LESSON_NUMBER} = line[0]
  46. if " н" in line:
  47. $_{WEEKDAY}_${LESSON_NUMBER}_count += 1
  48.  
  49. week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
  50. schedule = {}
  51. for weekday in week
  52. for line in file:
  53. if weekday in line:
  54. is_weekday = True # TODO: добавить обработку ДОПОЛНИТЕЛЬНОГО ОБРАЗОВАНИЯ
  55. is_last_weekday = False
  56. if is_weekday == True:
  57. if "8" >= line[0] >= "1": # parse schedule along with visits
  58. if line_has_lesson(line):
  59. schedule[line[0]] = line[10:36].strip() # strip removes whitespaces at the end of the string
  60. else:
  61. schedule[line[0]] = previous_line
  62. else:
  63. if line[0] == " ":
  64. previous_line = line[10:36].strip()
  65. else:
  66. pass
  67. LESSON_NUMBER = line[0]
  68. if " н" in line:
  69. $_{WEEKDAY}_LESSON_NUMBER_count += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement