summaryrefslogtreecommitdiff
path: root/xbackup/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'xbackup/config.py')
-rw-r--r--xbackup/config.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/xbackup/config.py b/xbackup/config.py
new file mode 100644
index 0000000..4c72915
--- /dev/null
+++ b/xbackup/config.py
@@ -0,0 +1,25 @@
+#!/usr/bin/python3
+# vim: shiftwidth=4 softtabstop=4 tabstop=4 expandtab
+
+
+"""Module for Configuration Parsing Functionality of xbackup"""
+
+
+import json
+
+
+def get(path):
+ """read and parse the xbackup configuration file"""
+
+ with open(path, "r", encoding="utf-8") as _file:
+ content = _file.read()
+
+ return json.loads(content)
+
+def dump(config, pretty=True):
+ """returns the given configuration as JSON string"""
+
+ if pretty:
+ return json.dumps(config, indent=4)
+
+ return json.dumps(config)