def filter(root, required_builds): files = os.sort_by_rule(root,"log([0-9]*).*.xml", 'asc') len_of_files = len(files) if required_builds < len_of_files : for i in range(0, len_of_files - required_builds) : files.pop(0) return files
def filter_by_days(root, rule, days): if days == None or days == 0: return [] files = os.sort_by_rule(root, rule, 'asc'); ndays_before = __ndays_before__(files[len(files) - 1], days) filtered = [] for file in files: current_date = util.datetimeutils.cctimestamp_as_date(file) if current_date >= ndays_before: filtered.append(file) return filtered
def latest_log(self): files = os.sort_by_rule(self.logdir(),"log([0-9]*).*.xml", 'desc') return os.path.join(self.logdir(), files[0])
def testShouldSortTheFilesBasedOnTheRuleDesc(self): files = os.sort_by_rule(self.root, 'log([0-9]*).*.xml', 'desc') self.assertEquals('log20080924062941.xml', files[0]) self.assertEquals('log20080624064201Lbuild.70.xml', files[54])