From 36fcdb901b8698a257a263763474faa46912cc4a Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Sat, 23 Oct 2021 00:23:31 +0200 Subject: [PATCH] conditional exists --- tww/lib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tww/lib.py b/tww/lib.py index e8ce18b..3591329 100644 --- a/tww/lib.py +++ b/tww/lib.py @@ -487,7 +487,10 @@ def tzinfo_from_offset(offset: str) -> pytz.timezone: def custom_dt_parse(query): - with open(os.path.join(basepath, "data", "custom_dt.csv")) as f: + custom_dt_file = os.path.join(basepath, "data", "custom_dt.csv") + if not os.path.exists(custom_dt_file): + return query + with open(custom_dt_file) as f: cfile = csv.reader(f) for row in cfile: entry = row[0]