gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] branch master updated: linting talerconfig


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated: linting talerconfig
Date: Wed, 22 Nov 2017 16:25:40 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository bank.

The following commit(s) were added to refs/heads/master by this push:
     new 8efe6f9  linting talerconfig
8efe6f9 is described below

commit 8efe6f999ecc7ff5b113f390bc451d6c701825f7
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Nov 22 16:25:27 2017 +0100

    linting talerconfig
---
 talerbank/talerconfig.py | 60 ++++++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 28 deletions(-)

diff --git a/talerbank/talerconfig.py b/talerbank/talerconfig.py
index e27caeb..ec4bd76 100644
--- a/talerbank/talerconfig.py
+++ b/talerbank/talerconfig.py
@@ -104,10 +104,10 @@ class OptionDict(collections.defaultdict):
         entry = Entry(self.config(), self.section_name, key)
         self[key] = entry
         return entry
-    def __getitem__(self, slice):
-        return super().__getitem__(slice.lower())
-    def __setitem__(self, slice, value):
-        super().__setitem__(slice.lower(), value)
+    def __getitem__(self, chunk):
+        return super().__getitem__(chunk.lower())
+    def __setitem__(self, chunk, value):
+        super().__setitem__(chunk.lower(), value)
 
 
 class SectionDict(collections.defaultdict):
@@ -117,17 +117,17 @@ class SectionDict(collections.defaultdict):
         value = OptionDict(self, key)
         self[key] = value
         return value
-    def __getitem__(self, slice):
-        return super().__getitem__(slice.lower())
-    def __setitem__(self, slice, value):
-        super().__setitem__(slice.lower(), value)
+    def __getitem__(self, chunk):
+        return super().__getitem__(chunk.lower())
+    def __setitem__(self, chunk, value):
+        super().__setitem__(chunk.lower(), value)
 
 
 class Entry:
-    def __init__(self, config, section, option, value=None, filename=None, 
lineno=None):
-        self.value = value
-        self.filename = filename
-        self.lineno = lineno
+    def __init__(self, config, section, option, **kwargs):
+        self.value = kwargs.get("value")
+        self.filename = kwargs.get("filename")
+        self.lineno = kwargs.get("lineno")
         self.section = section
         self.option = option
         self.config = weakref.ref(config)
@@ -146,11 +146,11 @@ class Entry:
         if self.value is None:
             if warn:
                 if default is not None:
-                    LOGGER.warn("Configuration is missing option '%s' in 
section '%s',\
-                                falling back to '%s'", self.option, 
self.section, default)
+                    LOGGER.warning("Configuration is missing option '%s' in 
section '%s',\
+                                   falling back to '%s'", self.option, 
self.section, default)
                 else:
-                    LOGGER.warn("Configuration ** is missing option '%s' in 
section '%s'",
-                                self.option.upper(), self.section.upper())
+                    LOGGER.warning("Configuration ** is missing option '%s' in 
section '%s'",
+                                   self.option.upper(), self.section.upper())
             return default
         return self.value
 
@@ -212,14 +212,17 @@ class TalerConfig:
         cfg.load_file(filename)
         return cfg
 
-    def value_string(self, section, option, default=None, required=None, 
warn=False):
-        return self.sections[section][option].value_string(default, required, 
warn)
+    def value_string(self, section, option, **kwargs):
+        return self.sections[section][option].value_string(
+            kwargs.get("default"), kwargs.get("required"), kwargs.get("warn"))
 
-    def value_filename(self, section, option, default=None, required=None, 
warn=False):
-        return self.sections[section][option].value_filename(default, 
required, warn)
+    def value_filename(self, section, option, **kwargs):
+        return self.sections[section][option].value_filename(
+            kwargs.get("default"), kwargs.get("required"), kwargs.get("warn"))
 
-    def value_int(self, section, option, default=None, required=None, 
warn=False):
-        return self.sections[section][option].value_int(default, required, 
warn)
+    def value_int(self, section, option, **kwargs):
+        return self.sections[section][option].value_int(
+            kwargs.get("default"), kwargs.get("required"), kwargs.get("warn"))
 
     def load_defaults(self):
         base_dir = os.environ.get("TALER_BASE_CONFIG")
@@ -236,7 +239,7 @@ class TalerConfig:
         if TALER_DATADIR:
             self.load_dir(os.path.join(TALER_DATADIR, "share/taler/config.d"))
             return
-        LOGGER.warn("no base directory found")
+        LOGGER.warning("no base directory found")
 
     @staticmethod
     def from_env(*args, **kwargs):
@@ -251,7 +254,7 @@ class TalerConfig:
         try:
             files = os.listdir(dirname)
         except FileNotFoundError:
-            LOGGER.warn("can't read config directory '%s'", dirname)
+            LOGGER.warning("can't read config directory '%s'", dirname)
             return
         for file in files:
             if not file.endswith(".conf"):
@@ -294,7 +297,8 @@ class TalerConfig:
                             LOGGER.error("mismatched quotes in line %s: %s", 
lineno, repr(line))
                         else:
                             value = value[:-1]
-                    entry = Entry(self.sections, current_section, key, value, 
filename, lineno)
+                    entry = Entry(self.sections, current_section, key,
+                                  value=value, filename=filename, 
lineno=lineno)
                     sections[current_section][key] = entry
         except FileNotFoundError:
             LOGGER.error("Configuration file (%s) not found", filename)
@@ -307,9 +311,9 @@ class TalerConfig:
             for option_name, entry in section.items():
                 print("%s = %s # %s" % (entry.option, entry.value, 
entry.location()))
 
-    def __getitem__(self, slice):
-        if isinstance(slice, str):
-            return self.sections[slice]
+    def __getitem__(self, chunk):
+        if isinstance(chunk, str):
+            return self.sections[chunk]
         raise TypeError("index must be string")
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]