Mercurial > roundup-cc
diff display_issues_demo.py @ 26:761ee2351f58
Change the parameter read in.
* The structure was changed and better names used.
author | Magnus Schieder <mschieder@intevation.de> |
---|---|
date | Tue, 13 Nov 2018 17:55:10 +0100 |
parents | 7161ce4e7ab1 |
children | e2864dabdb8c |
line wrap: on
line diff
--- a/display_issues_demo.py Mon Nov 12 18:03:26 2018 +0100 +++ b/display_issues_demo.py Tue Nov 13 17:55:10 2018 +0100 @@ -16,36 +16,43 @@ import argparse from display_issues import * -STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved" - -parser = argparse.ArgumentParser() -parser.add_argument("config_file", type=str, metavar="[config file]") -args = parser.parse_args() +def main(): + PRIO = "critical, urgent, bug, feature, wish" + STATES = "unread, deferred, chatting, need_eg, in_progress, testing, done_cbb, resolved" -config = configparser.ConfigParser() -config.read(args.config_file) + parser = argparse.ArgumentParser() + parser.add_argument("config_file", type=str, metavar="[config file]") + args = parser.parse_args() -db = config.get("DB", "DatabaseFile") -keywords = config.get("SEARCH", "Keywords", fallback="") + config = configparser.ConfigParser() + config.read(args.config_file) + db = config.get("DB", "DatabaseFile") + keywords = config.get("SEARCH", "Keywords", fallback="") -status = config.get("SEARCH", "Status", fallback="") -columns = config.get("SEARCH", "Columns", fallback="critical, urgent, bug, feature, wish") -noPrio = config.get("SEARCH", "IncludeNoPrio", fallback=False) -search = config.get("SEARCH", "Search", fallback="prio") -if search == "status": - if status == "": - columns = STATES + search = config.get("SEARCH", "Search", fallback="prio") + if search == "prio": + status = config.get("SEARCH", "Status", fallback="") + columns = config.get("SEARCH", "Priority", fallback=PRIO) + noPrio = config.get("SEARCH", "IncludeNoPrio", fallback=False) + if noPrio: + columns += ", None" + + elif search == "status": + columns = config.get("SEARCH", "Status", fallback=STATES) + status = "" + else: - columns = status - noPrio = False + print("Incorrect [SEARCH]Search parameter. (prio, status)") + return -if noPrio: - columns += ", None" -cgitb.enable() # (optional) HTML traceback to browser -#render_db_stats_as_html("./demo1.db", rcd.SELECT_ALL) -render_db_stats_as_html(db, - rcd.build_sql_select(columns).format("timestamp > date('now', '-2 month')"), - columns, status, keywords) + cgitb.enable() # (optional) HTML traceback to browser + #render_db_stats_as_html("./demo1.db", rcd.SELECT_ALL) + render_db_stats_as_html(db, + rcd.build_sql_select(columns).format("timestamp > date('now', '-2 month')"), + columns, status, keywords) + +if __name__ == '__main__': + main()