Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344057 )

Change subject: Comments and cleanup for config
......................................................................

Comments and cleanup for config

Change-Id: Ia1afe7fe3770866d33781a4cd4626a46a5aae09a
---
M processcontrol/config.py
1 file changed, 17 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/process-control 
refs/changes/57/344057/1

diff --git a/processcontrol/config.py b/processcontrol/config.py
index 69fa24e..4914ea8 100644
--- a/processcontrol/config.py
+++ b/processcontrol/config.py
@@ -1,4 +1,4 @@
-import glob
+import copy
 import os
 import yaml
 
@@ -9,6 +9,13 @@
         self.values = defaults
 
     def get(self, path, default=None):
+        """Get a value from configuration.
+        You can get a nested property by using a path delimited by
+        forward slashes (/).
+        If you provide a default value, it will be used when the
+        desired property does not exist. If there is no default,
+        trying to get a missing property raises a MissingKeyException.
+        """
         parts = path.split("/")
         current = self.values
 
@@ -21,6 +28,9 @@
         return current
 
     def has(self, path):
+        """Test for existance of a property.
+        As with get(), use forward slashes to represent nested properties.
+        """
         try:
             self.get(path)
         except MissingKeyException:
@@ -52,11 +62,11 @@
         ]
 
     def load_global_config(self):
-        # load configuration from global config paths
-        # later entries override earlier entries
-        for search_path in self.global_config_paths():
-            file_paths = glob.glob(search_path)
-            for file_path in file_paths:
+        """Load configuration from global config paths.
+        Later entries override earlier entries.
+        """
+        for file_path in self.global_config_paths():
+            if os.access(file_path, os.R_OK):
                 config = yaml.safe_load(open(file_path, "r"))
                 self.values.update(config)
 
@@ -65,7 +75,7 @@
 
     def __init__(self, global_config, config_path):
         if global_config.has("default_job_config"):
-            defaults = global_config.get("default_job_config").copy()
+            defaults = copy.deepcopy(global_config.get("default_job_config"))
         else:
             defaults = {}
         Configuration.__init__(self, defaults)

-- 
To view, visit https://gerrit.wikimedia.org/r/344057
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1afe7fe3770866d33781a4cd4626a46a5aae09a
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/process-control
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to