From c35a446150b37a36881626b7d2c76138ecb3a4cc Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Thu, 14 Mar 2019 10:35:19 -0700 Subject: [PATCH] solve empty query --- tz.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tz.py b/tz.py index b03a0f7..1d71a9d 100644 --- a/tz.py +++ b/tz.py @@ -172,7 +172,12 @@ def parse_query(query): """ Parses the user query to the datetime, tz/loc parts """ - to_query = ' '.join(query).split(" to ") + query = ' '.join(query) + query = query.strip() + if not query: + logger.critical("Use a query like ['to' ]") + exit(1) + to_query = query.split(" to ") logger.debug("to_query: {}".format(to_query)) if len(to_query) == 1: # only datetime @@ -231,7 +236,7 @@ def solve_query(human_dt, human_tz_loc): def format_result(result, fmt): if result is None: - logger.critical("Could not s query") + logger.critical("Could not solve query") exit(1) logger.debug("Format: {}".format(fmt)) format_result = result.strftime(fmt)