From 15c78cd6a6f145fff7f1a25d02be508b1342f7ad Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 18 Nov 2017 14:56:44 +0100 Subject: [PATCH] [core/themes] Add theme merging from different locations Theme files with the same name, but in different theme locations, are now merged together. see #203 --- bumblebee/theme.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 4224c0c..ff4ab00 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -132,6 +132,7 @@ class Theme(object): def load(self, name, path=theme_path()): """Load and parse a theme file""" + result = None if not isinstance(path, list): path = [path] for p in path: @@ -140,11 +141,14 @@ class Theme(object): if os.path.isfile(themefile): try: with io.open(themefile, encoding="utf-8") as data: - return json.load(data) + if result is None: + result = json.load(data) + else: + self._merge(result, json.load(data)) except ValueError as exception: raise bumblebee.error.ThemeLoadError("JSON error: {}".format(exception)) - return {} + return result def _get(self, widget, name, default=None): """Return the config value 'name' for 'widget'"""