Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Максим Емельяненко:
- def line_has_lesson(line):
- if len(line) >= 10 and line[10:14] != " ":
- return True
- else:
- return False
- file = open('/home/overaid/Downloads/pdf2xml/Емельяненко Максим Владимирович. 01.09.2019 - 15.12.2019.(1).txt', 'r')
- # Есть у нас разные дни недели, у них есть одинаковые атрибуты:
- # Номер данного урока в данный день недели, булеан дня недели
- # Количество пропусков, название дня недели. Че делать то
- class schoolday(object):
- def init(self, weekday, lesson_number, ):
- self.weekday = self
- self.lesson_number = lesson_number
- self.is_weekday = False
- self.ncount = 0
- self.dayfile = ''
- # monday = schoolday(lesson_number=1)
- # tuesday = schoolday(lesson_number=1)
- # wednesday = schoolday(lesson_number=lesson_number)
- # thursday = schoolday(lesson_number=lesson_number)
- # friday = schoolday(lesson_number=lesson_number)
- for ${WEEKDAY} in week
- for line in file:
- if ${WEEKDAY} in line:
- is_${WEEKDAY} = True # TODO: добавить обработку ДОПОЛНИТЕЛЬНОГО ОБРАЗОВАНИЯ
- is_${WEEKDAY-1} = False
- if is_${WEEKDAY} = True:
- if "8" >= line[0] >= "1": # parse schedule along with visits
- if line_has_lesson(line):
- schedule[line[0]] = line[10:36].strip() # strip removes whitespaces at the end of the string
- else:
- schedule[line[0]] = previous_line
- else:
- if line[0] == " ":
- previous_line = line[10:36].strip()
- else:
- pass
- ${LESSON_NUMBER} = line[0]
- if " н" in line:
- $_{WEEKDAY}_${LESSON_NUMBER}_count += 1
- week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
- schedule = {}
- for weekday in week
- for line in file:
- if weekday in line:
- is_weekday = True # TODO: добавить обработку ДОПОЛНИТЕЛЬНОГО ОБРАЗОВАНИЯ
- is_last_weekday = False
- if is_weekday == True:
- if "8" >= line[0] >= "1": # parse schedule along with visits
- if line_has_lesson(line):
- schedule[line[0]] = line[10:36].strip() # strip removes whitespaces at the end of the string
- else:
- schedule[line[0]] = previous_line
- else:
- if line[0] == " ":
- previous_line = line[10:36].strip()
- else:
- pass
- LESSON_NUMBER = line[0]
- if " н" in line:
- $_{WEEKDAY}_LESSON_NUMBER_count += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement