aboutsummaryrefslogtreecommitdiff
path: root/configuration.py
diff options
context:
space:
mode:
Diffstat (limited to 'configuration.py')
-rw-r--r--configuration.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/configuration.py b/configuration.py
index fceef14..78cce27 100644
--- a/configuration.py
+++ b/configuration.py
@@ -1,7 +1,15 @@
+""" The configuration from the user.
+"""
+
from collections import OrderedDict
from os import path
import json
+from zope import component
+from interfaces.message import Error
class Mapping():
+ """Represent the configuration. This class is provided as an utility and is
+ used in the IDesktop interfaces.
+ """
def __init__(self, configuration):
self.init_mapping = configuration["mapping"]
@@ -10,7 +18,7 @@ class Mapping():
for key in tmp_mapping.keys() :
json_file = self.init_mapping[key]
if not path.exists(json_file):
- print("The file '%s' does not exists" % json_file)
+ component.handle(Error(f"The file '{json_file}' does not exists"))
continue
with open(json_file, "r") as file:
json_data = file.read()
@@ -27,6 +35,8 @@ class Mapping():
del self.mapping[key]
def get(self, key, default):
+ """ This function return the mapping associated with the given key.
+ """
return self.mapping.get(key, default)
def __getitem__(self, key):
@@ -44,4 +54,3 @@ class Mapping():
""" Implement the keys method from the dictionnary
"""
return self.mapping.keys()
-