Commit 2ae9506d7efad1b0389663f482f22f8cb7e5c503

Authored by Geoffrey PREUD'HOMME
1 parent f6d0d112

Affiche les évènements buggués dans le tableau 2

Showing 1 changed file with 18 additions and 18 deletions   Show diff stats
@@ -36,7 +36,7 @@ elif args.annee == 4: @@ -36,7 +36,7 @@ elif args.annee == 4:
36 else: 36 else:
37 raise ValueError('Année inconnue : ' + annee) 37 raise ValueError('Année inconnue : ' + annee)
38 38
39 -DAYS_PER_WEEK = 6 39 +DAYS_PER_WEEK = 5.5
40 40
41 TABLE_1_DATE_X = 1 41 TABLE_1_DATE_X = 1
42 TABLE_1_FIRST_SLOT_X = 2 42 TABLE_1_FIRST_SLOT_X = 2
@@ -159,7 +159,7 @@ class Event: @@ -159,7 +159,7 @@ class Event:
159 self.shortName = self.shortText 159 self.shortName = self.shortText
160 self.longName = self.longText 160 self.longName = self.longText
161 161
162 - if self.longName: 162 + if self.shortName:
163 self.active = True 163 self.active = True
164 164
165 if self.date and isinstance(self.begSlot, int) and isinstance(self.endSlot, int): 165 if self.date and isinstance(self.begSlot, int) and isinstance(self.endSlot, int):
@@ -250,25 +250,24 @@ days = dict() @@ -250,25 +250,24 @@ days = dict()
250 # Parsing table 1 250 # Parsing table 1
251 for line in tables[0]: 251 for line in tables[0]:
252 try: 252 try:
253 - day1date = datetime.datetime.strptime(line[TABLE_1_DATE_X], DATE_FORMAT) 253 + date = datetime.datetime.strptime(line[TABLE_1_DATE_X], DATE_FORMAT)
254 except (ValueError, TypeError): 254 except (ValueError, TypeError):
255 # This is not a date, no data to grab here 255 # This is not a date, no data to grab here
256 continue 256 continue
257 257
258 - for day in range(DAYS_PER_WEEK):  
259 - date = day1date + datetime.timedelta(days=day) 258 + for weekSlot in range(int(DAYS_PER_WEEK * len(SLOTS))):
  259 + daySlot = weekSlot % len(SLOTS)
  260 +
  261 + # New day
  262 + if daySlot == 0:
  263 + if weekSlot != 0:
  264 + date = date + datetime.timedelta(days=1)
260 265
261 - if date not in days:  
262 - days[date] = [Event() for s in range(len(SLOTS))] 266 + if date not in days:
  267 + days[date] = [Event() for s in range(len(SLOTS))]
263 268
264 - for slot in range(len(SLOTS)):  
265 - try:  
266 - cell = line[day * len(SLOTS) + slot + TABLE_1_FIRST_SLOT_X]  
267 - except IndexError:  
268 - # Out of the table: saturday afternoon  
269 - break  
270 - days[date][slot].feedShortText(cell)  
271 - continue 269 + cell = line[TABLE_1_FIRST_SLOT_X + weekSlot]
  270 + days[date][daySlot].feedShortText(cell)
272 271
273 # Parsing table 2 272 # Parsing table 2
274 for line in tables[1]: 273 for line in tables[1]:
@@ -290,13 +289,15 @@ for day in days: @@ -290,13 +289,15 @@ for day in days:
290 prevEvent = False 289 prevEvent = False
291 for slot in range(len(SLOTS)): 290 for slot in range(len(SLOTS)):
292 event = days[day][slot] 291 event = days[day][slot]
  292 + sameAsPrevious = False
293 if prevEvent: 293 if prevEvent:
294 - if prevEvent.longText == event.longText: 294 + sameAsPrevious = event.longText == prevEvent.longText if prevEvent.longText else event.shortText == prevEvent.shortText
  295 + if sameAsPrevious:
295 prevEvent.feedEndSlot(slot) 296 prevEvent.feedEndSlot(slot)
296 else: 297 else:
297 prevEvent.endFeed() 298 prevEvent.endFeed()
298 events.append(prevEvent) 299 events.append(prevEvent)
299 - if not prevEvent or (prevEvent and prevEvent.longText != event.longText): 300 + if not prevEvent or (prevEvent and not sameAsPrevious):
300 event.feedDate(day) 301 event.feedDate(day)
301 event.feedBegSlot(slot) 302 event.feedBegSlot(slot)
302 event.feedEndSlot(slot) 303 event.feedEndSlot(slot)
@@ -313,7 +314,6 @@ cal.add('x-wr-calname', 'Polytech IMA ' + str(args.annee) + ' ' + args.edt) @@ -313,7 +314,6 @@ cal.add('x-wr-calname', 'Polytech IMA ' + str(args.annee) + ' ' + args.edt)
313 314
314 for event in events: 315 for event in events:
315 if event.active: 316 if event.active:
316 - print(event, file=sys.stderr)  
317 cal.add_component(event.getEvent()) 317 cal.add_component(event.getEvent())
318 318
319 # Writing calendar to file 319 # Writing calendar to file