Mercurial > treepkg
changeset 147:cfeb0251055b
Add reportstatus.py flag --sort-on= to let the user choose the sort field.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 05 Jun 2008 11:06:58 +0000 |
parents | 1766e2ee9457 |
children | 25d4949ac2d8 |
files | bin/reportstatus.py |
diffstat | 1 files changed, 22 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/reportstatus.py Thu Jun 05 11:05:55 2008 +0000 +++ b/bin/reportstatus.py Thu Jun 05 11:06:58 2008 +0000 @@ -17,24 +17,35 @@ from treepkg.report import get_packager_group, prepare_report def parse_commandline(): - return create_parser().parse_args() + parser = create_parser() + parser.set_defaults(sort_on="start-date") + parser.add_option("--sort-on", + help=("Field to sort on;" + " either start-date (the default) or revision")) + return parser.parse_args() -def report_text(group): +def report_text(group, sort_on): report = prepare_report(group) - for revno, row in report.revisions.sorted_by_revision(): - for col in row: - if col: - print "%s %s: %s" % (col.name, revno, col.status.desc) - if col.status.start: - print " Start:", col.status.start - print " Stop:", col.status.stop - print + if sort_on == "revision": + sorted = (col for revno, row in report.revisions.sorted_by_revision() + for col in row + if col) + elif sort_on == "start-date": + sorted = (row for start, row in report.revisions.sorted_by_startdate()) + else: + raise ValueError("Unknown sort field %r" % sort_on) + + for item in sorted: + print "%s %s: %s" % (item.name, item.revno, item.status.desc) + print " Start:", item.status.start + print " Stop:", item.status.stop + print def main(): options, args = parse_commandline() group = get_packager_group(options.config_file) - report_text(group) + report_text(group, options.sort_on) main()