From 0b398538ecc5ffab062921ea4826b530671f6918 Mon Sep 17 00:00:00 2001 From: Maximilian Zettler Date: Tue, 5 Sep 2023 16:29:32 +0200 Subject: [PATCH] reformat main app --- timebot/app.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/timebot/app.py b/timebot/app.py index 4c8d6e0..5ceca8d 100644 --- a/timebot/app.py +++ b/timebot/app.py @@ -43,13 +43,10 @@ def run(): # subparser command: `punch` parser_punch = subparsers.add_parser("punch", help="use this command to punch in, punch out, or create break entries") - parser_punch.add_argument("-t", - help=f"type of time entry; this can be {', '.join(PUNCH_COMMANDS)}", - default="punch_in", - choices=PUNCH_COMMANDS) - parser_punch.add_argument("-s", - help=f"timestamp in format `{DateFormats.SIMPLE_DATETIME.evalue}`, " - f"`{DateFormats.SIMPLE_TIME.evalue}` or `now`", default="now") + parser_punch.add_argument("-t", help=f"type of time entry; this can be {', '.join(PUNCH_COMMANDS)}", + default="punch_in", choices=PUNCH_COMMANDS) + parser_punch.add_argument("-s", help=f"timestamp in format `{DateFormats.SIMPLE_DATETIME.evalue}`, " + f"`{DateFormats.SIMPLE_TIME.evalue}` or `now`", default="now") # subparser command: `smart-punch` parser_smart_punch = subparsers.add_parser("smart-punch", @@ -69,8 +66,8 @@ def run(): config.read(args.c) if args.use_system_ca_store or config.get(section="general", option="use_system_ca_store", fallback="no") == "yes": - os.environ["REQUESTS_CA_BUNDLE"] = config["general"]["system_ca_store"] \ - if "system_ca_store" in config["general"] else "/etc/ssl/certs/ca-certificates.crt" + os.environ["REQUESTS_CA_BUNDLE"] = config["general"]["system_ca_store"] if "system_ca_store" in config[ + "general"] else "/etc/ssl/certs/ca-certificates.crt" user = args.u if args.u is not None else config.get(section="general", option="mobatime_user", fallback=None) if user is None: @@ -88,11 +85,9 @@ def run(): punch_datetime = datetime.datetime.now() else: punch_datetime = parse_user_time_input(args.s) - logger.info("running `{}` with date `{}` and time `{}`".format( - args.t, + logger.info("running `{}` with date `{}` and time `{}`".format(args.t, punch_datetime.strftime(DateFormats.SIMPLE_DATE.value), - punch_datetime.strftime(DateFormats.SIMPLE_TIME.value), - )) + punch_datetime.strftime(DateFormats.SIMPLE_TIME.value), )) getattr(tb, args.t)(punch_datetime) elif args.subparser_name == "smart-punch": if args.s == "now": @@ -117,9 +112,8 @@ def run(): from timebot.gui import MainWindow signal.signal(signal.SIGINT, lambda *_args: QApplication.quit()) app = QApplication(sys.argv) - main_window = MainWindow(timebot=tb, refresh_interval=config.get(section="gui", - option="refresh_interval", - fallback="1m")) + main_window = MainWindow(timebot=tb, + refresh_interval=config.get(section="gui", option="refresh_interval", fallback="1m")) main_window.show() sys.exit(app.exec()) else: