From 11d5af59df024a8a2b36cc190aa1ee92784ce38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jochum?= Date: Fri, 9 Aug 2019 20:38:36 +0200 Subject: [PATCH] Bugfixes --- todoist_taskwarrior/cli.py | 30 ++++++++++++++++-------------- todoist_taskwarrior/utils.py | 3 +++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/todoist_taskwarrior/cli.py b/todoist_taskwarrior/cli.py index b1342e4..e3c09cc 100644 --- a/todoist_taskwarrior/cli.py +++ b/todoist_taskwarrior/cli.py @@ -30,23 +30,25 @@ def cli(): is_help_cmd = '-h' in sys.argv or '--help' in sys.argv rcfile = os.path.expanduser(TITWSYNCRC) - with open(rcfile, 'r') as stream: - config = yaml.safe_load(stream) - if 'todoist' not in config or 'api_key' not in config['todoist'] \ - and not is_help_cmd: - log.error('Run configure first. Exiting.') - exit(1) + if os.path.exists(rcfile): + with open(rcfile, 'r') as stream: + config = yaml.safe_load(stream) - todoist = TodoistAPI(config['todoist']['api_key'], cache=TODOIST_CACHE) + if 'todoist' not in config or 'api_key' not in config['todoist'] \ + and not is_help_cmd: + log.error('Run configure first. Exiting.') + exit(1) - # Create the TaskWarrior client, overriding config to - # create a `todoist_id` field which we'll use to - # prevent duplicates - taskwarrior = TaskWarrior(config_overrides={ - 'uda.todoist_id.type': 'string', - 'uda.todoist_sync.type': 'date', - }) + todoist = TodoistAPI(config['todoist']['api_key'], cache=TODOIST_CACHE) + + # Create the TaskWarrior client, overriding config to + # create a `todoist_id` field which we'll use to + # prevent duplicates + taskwarrior = TaskWarrior(config_overrides={ + 'uda.todoist_id.type': 'string', + 'uda.todoist_sync.type': 'date', + }) @cli.command() diff --git a/todoist_taskwarrior/utils.py b/todoist_taskwarrior/utils.py index 4577d39..cb82866 100644 --- a/todoist_taskwarrior/utils.py +++ b/todoist_taskwarrior/utils.py @@ -44,6 +44,9 @@ def tw_priority_to_ti(priority): def maybe_quote_ws(value): """Surrounds a value with single quotes if it contains whitespace. """ + if value is None: + return value + if any(x == ' ' or x == '\t' for x in value): return "'" + value + "'" return value