diff -r e24da9a94ffb -r 0690d715385d log_source.py --- a/log_source.py Wed Feb 11 04:41:22 2009 +0200 +++ b/log_source.py Wed Feb 11 04:57:55 2009 +0200 @@ -168,8 +168,8 @@ If the datetime is not given, *all* lines are returned. - If after is given, only lines after said date will be returned, regardless of modification. - If until is given, only lines up to said date will be returned, regardless of modification. + If after is given, only lines from said date onwards will be returned, regardless of modification. + If until is given, only lines up to and including said date will be returned, regardless of modification. The LogLines should be in time order. """ @@ -420,8 +420,8 @@ """ Yields a series of naive datetime objects representing the logfiles that are available, in time order. - If after is given, only dates after said date will be returned - If until is given, only dates up to said date will be returned + If after is given, only dates from said date onwards will be returned + If until is given, only dates up to and including said date will be returned """ # listdir @@ -430,28 +430,26 @@ # sort filenames.sort() + + # iter files for filename in filenames : try : # parse date - date = datetime.datetime.strptime(filename, self.filename_fmt).replace(tzinfo=self.tz) + date = self.tz.localize(datetime.datetime.strptime(filename, self.filename_fmt)) except : # ignore continue else : - # ignore before? - if after and date < after : - continue - - # ignore after? - if until and date > until : - continue - - else : + if (not after or date >= after) and (not until or date <= until) : # yield yield date + + else : + # ignore + continue def _iter_date_reverse (self, dt=None) : """