From 3b59622a682d49a0829083a2610f33965b3ce478 Mon Sep 17 00:00:00 2001 From: gryf Date: Fri, 14 May 2021 13:46:15 +0200 Subject: [PATCH] Added warning if config file doesn't exists. --- box.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/box.py b/box.py index e71314f..3ab7a3d 100755 --- a/box.py +++ b/box.py @@ -285,10 +285,14 @@ class Config: conf = yaml.safe_load(USER_DATA) # read user custom cloud config (if present) and update config dict - if self.user_data and os.path.exists(self.user_data): - with open(self.user_data) as fobj: - custom_conf = yaml.safe_load(fobj) - conf = self._update(conf, custom_conf) + if self.user_data: + if os.path.exists(self.user_data): + with open(self.user_data) as fobj: + custom_conf = yaml.safe_load(fobj) + conf = self._update(conf, custom_conf) + else: + print(f"WARNING: Provided user_data: {self.user_data} doesn't" + " exists.") # update the attributes with data from read user cloud config for key, val in conf.get('boxpy_data', {}).items():