From 02ca3d3a508988ea02de9dfab274fba4a323e433 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 14 Aug 2019 15:00:35 +1000 Subject: [PATCH] create config if it doesn't exist --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index a224607..b270a11 100755 --- a/main.py +++ b/main.py @@ -30,7 +30,10 @@ cfg = { "strip_paired_punctuation": False } -cfg.update(json.load(open(args.cfg, 'r'))) +try: + cfg.update(json.load(open(args.cfg, 'r'))) +except FileNotFoundError: + open(args.cfg, "w").write("{}") print("Using {} as configuration file".format(args.cfg))