Page MenuHomeDevCentral

D4082.diff
No OneTemporary

D4082.diff

diff --git a/python/config.py b/python/config.py
new file mode 100644
--- /dev/null
+++ b/python/config.py
@@ -0,0 +1,25 @@
+import os
+import yaml
+
+# -------------------------------------------------------------
+# Configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def get_configuration_paths():
+ return [
+ ".foo.conf", # local
+ os.path.expanduser("~/.config/foo.conf"), # per user
+ "/usr/local/etc/foo.conf", # system (UNIX hierarchy)
+ "/etc/foo.conf", # system (linux convention)
+ ]
+
+
+def parse_configuration():
+ try:
+ for candidate in get_configuration_paths():
+ if os.path.exists(candidate):
+ with open(candidate) as fd:
+ return yaml.safe_load(fd) or {}
+ except OSError:
+ return {}

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 21, 02:51 (22 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3644957
Default Alt Text
D4082.diff (849 B)

Event Timeline