def main(self):
# TODO: move to Project and unit test it
cutoff = datetime.datetime.strptime(self.args.month, "%Y-%m").date()
cutoff = cutoff.replace(day=calendar.monthrange(cutoff.year, cutoff.month)[1])
e = self.make_egt(self.args.projects)
archive_results = {}
for p in e.projects:
# TODO: copy timebase and entry, ignore commands
# TODO: generate initial timebase in archived log
entries = list(l for l in p.log.entries if l.begin.date() <= cutoff)
if not entries: continue
archive_results[p.name] = self.write_archive(p, entries, cutoff)
duration = sum(e.duration for e in entries)
# TODO: use Meta.print
if "name" not in p.meta._raw:
print("Name:", p.name)
p.meta.print()
print("{}: {}".format("Total", format_duration(duration)))
print()
# TODO: use Log.print or entry.print
for l in entries:
l.print()
print()
for name, res in sorted(archive_results.items()):
print("Archived {}: {}".format(name, res))
评论列表
文章目录