From 052b230626a8ba5e40cf3ef9f2c71c4032dcbb09 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Thu, 26 Sep 2024 16:45:03 -0600 Subject: [PATCH] util inspect-auth: fix unauthenticated case to print the right message Fixes minor bug in #780. --- gcalcli/cli.py | 2 +- gcalcli/utils.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/gcalcli/cli.py b/gcalcli/cli.py index b5d9de9..47605f8 100755 --- a/gcalcli/cli.py +++ b/gcalcli/cli.py @@ -368,7 +368,7 @@ def main(): auth_data = utils.inspect_auth() for k, v in auth_data.items(): printer.msg(f"{k}: {v}\n") - if 'format' in auth_data: + if auth_data.get('format', 'unknown') != 'unknown': printer.msg( "\n" "The grant's entry under " diff --git a/gcalcli/utils.py b/gcalcli/utils.py index 6b8ff48..37602fa 100644 --- a/gcalcli/utils.py +++ b/gcalcli/utils.py @@ -257,6 +257,7 @@ def inspect_auth() -> dict[str, Any]: auth_data['format'] = 'json' except (OSError, ValueError, EOFError): pass + auth_data.setdefault('format', 'unknown') if 'format' in auth_data: for k in [ 'client_id', @@ -268,6 +269,4 @@ def inspect_auth() -> dict[str, Any]: ]: if hasattr(creds, k): auth_data[k] = getattr(creds, k) - else: - auth_data['format'] = 'unknown' return auth_data