From d2a7853c5dd4e2b0d23f0e5c28fc2e1e3b105d44 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Thu, 30 Apr 2015 11:33:00 +0200 Subject: [PATCH] [OE-Drucken] Improved documentation and error handling Signed-off-by: Jim Martens --- oe/Drucken/oeprint/config.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/oe/Drucken/oeprint/config.py b/oe/Drucken/oeprint/config.py index bd49738..efb549e 100644 --- a/oe/Drucken/oeprint/config.py +++ b/oe/Drucken/oeprint/config.py @@ -12,18 +12,21 @@ class Config: def load_build(self, build): """ - Loads the data of a particular build + Loads the data of a particular build or an empty object if no such build exists :type build: str - :rtype: object + :rtype: dict """ - build_data = self.config_data[build] + if build in self.config_data: + build_data = self.config_data[build] + else: + build_data = {} return build_data def load_json_file(self): """ Loads the JSON configuration file :type self: config.Config - :rtype : object + :rtype : dict """ file = open(self.config_file, 'r', encoding='utf-8') json_data = json.load(file)