166 """ |
166 """ |
167 Returns a sequence of LogLines that may have been *modified* from their old values since the given datetime. |
167 Returns a sequence of LogLines that may have been *modified* from their old values since the given datetime. |
168 |
168 |
169 If the datetime is not given, *all* lines are returned. |
169 If the datetime is not given, *all* lines are returned. |
170 |
170 |
171 If after is given, only lines after said date will be returned, regardless of modification. |
171 If after is given, only lines from said date onwards will be returned, regardless of modification. |
172 If until is given, only lines up to said date will be returned, regardless of modification. |
172 If until is given, only lines up to and including said date will be returned, regardless of modification. |
173 |
173 |
174 The LogLines should be in time order. |
174 The LogLines should be in time order. |
175 """ |
175 """ |
176 |
176 |
177 abstract |
177 abstract |
418 |
418 |
419 def _iter_logfile_dates (self, after=None, until=None) : |
419 def _iter_logfile_dates (self, after=None, until=None) : |
420 """ |
420 """ |
421 Yields a series of naive datetime objects representing the logfiles that are available, in time order. |
421 Yields a series of naive datetime objects representing the logfiles that are available, in time order. |
422 |
422 |
423 If after is given, only dates after said date will be returned |
423 If after is given, only dates from said date onwards will be returned |
424 If until is given, only dates up to said date will be returned |
424 If until is given, only dates up to and including said date will be returned |
425 """ |
425 """ |
426 |
426 |
427 # listdir |
427 # listdir |
428 filenames = os.listdir(self.path) |
428 filenames = os.listdir(self.path) |
429 |
429 |
430 # sort |
430 # sort |
431 filenames.sort() |
431 filenames.sort() |
|
432 |
|
433 |
432 |
434 |
433 # iter files |
435 # iter files |
434 for filename in filenames : |
436 for filename in filenames : |
435 try : |
437 try : |
436 # parse date |
438 # parse date |
437 date = datetime.datetime.strptime(filename, self.filename_fmt).replace(tzinfo=self.tz) |
439 date = self.tz.localize(datetime.datetime.strptime(filename, self.filename_fmt)) |
438 |
440 |
439 except : |
441 except : |
440 # ignore |
442 # ignore |
441 continue |
443 continue |
442 |
444 |
443 else : |
445 else : |
444 # ignore before? |
446 if (not after or date >= after) and (not until or date <= until) : |
445 if after and date < after : |
|
446 continue |
|
447 |
|
448 # ignore after? |
|
449 if until and date > until : |
|
450 continue |
|
451 |
|
452 else : |
|
453 # yield |
447 # yield |
454 yield date |
448 yield date |
|
449 |
|
450 else : |
|
451 # ignore |
|
452 continue |
455 |
453 |
456 def _iter_date_reverse (self, dt=None) : |
454 def _iter_date_reverse (self, dt=None) : |
457 """ |
455 """ |
458 Yields an infinite series of naive date objects in our timezone, iterating backwards in time starting at the |
456 Yields an infinite series of naive date objects in our timezone, iterating backwards in time starting at the |
459 given *datetime*, or the the current date, if none given |
457 given *datetime*, or the the current date, if none given |