From f2b300d9e01547628cd409f9666d457b5ea045ee Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 7 Jul 2025 08:31:38 +0200 Subject: Added error message --- configuration.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'configuration.py') 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() - -- cgit v1.2.3