From f6f8dd8af3844b66edb6afe2824844da8d08c856 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 23 Aug 2014 19:07:57 +0400 Subject: [PATCH 1/2] Make condition function return path as expected by lib.config --- powerline/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/powerline/__init__.py b/powerline/__init__.py index 36210c12..1bd5a5d3 100644 --- a/powerline/__init__.py +++ b/powerline/__init__.py @@ -15,7 +15,9 @@ from threading import Lock, Event def _config_loader_condition(path): - return path and os.path.isfile(path) + if path and os.path.isfile(path): + return path + return None def _find_config_files(search_paths, config_file, config_loader=None, loader_callback=None): From 483b261019499f1f4292842c02dbd92dcd48ffd4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 23 Aug 2014 19:09:28 +0400 Subject: [PATCH 2/2] When processing exception from _load do not allow overwriting it If `self.loaded.pop` raises KeyError then this KeyError will be logged, not the initial exception from `self._load`. --- powerline/lib/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/lib/config.py b/powerline/lib/config.py index d56b3c68..8742667b 100644 --- a/powerline/lib/config.py +++ b/powerline/lib/config.py @@ -195,11 +195,11 @@ class ConfigLoader(MultiRunnedThread): try: self.loaded[path] = deepcopy(self._load(path)) except Exception as e: + self.exception('Error while loading {0}: {1}', path, str(e)) try: self.loaded.pop(path) except KeyError: pass - self.exception('Error while loading {0}: {1}', path, str(e)) try: self.loaded.pop(path) except KeyError: