summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <pochu@debian.org>2019-11-27 13:45:27 +0100
committerEmilio Pozuelo Monfort <pochu@debian.org>2020-02-26 12:31:30 +0100
commit47899605d19e6b28b36444a1ca1a2809363e00c2 (patch)
treeaa7b687c159bc47c891940e75e690477753d6073 /lib
parent70c1a8a46bf246c3aa0ad985ce286b22c878c26f (diff)
config.py: add python module to read config.json
Diffstat (limited to 'lib')
-rw-r--r--lib/python/config.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/python/config.py b/lib/python/config.py
new file mode 100644
index 0000000000..61f633ee28
--- /dev/null
+++ b/lib/python/config.py
@@ -0,0 +1,52 @@
+# config.py -- methods to read global configuration from data/config.json
+# Copyright (C) 2019 Emilio Pozuelo Monfort <pochu@debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import json
+import os
+
+_config = None
+
+def get_config():
+ global _config
+ if not _config:
+ d = os.path.dirname(os.path.abspath(__file__))
+
+ with open(d + '/../../data/config.json') as f:
+ config = json.load(f)
+
+ _config = config['distributions']
+
+ return _config
+
+def get_supported_releases():
+ config = get_config()
+
+ return [d for d in config.keys() if 'release' in config[d]]
+
+def get_release_codename(release, suffix=''):
+ config = get_config()
+
+ for r in config.keys():
+ if 'release' in config[r] and config[r]['release'] == release:
+ return r + suffix
+
+ return None
+
+def get_release_alias(codename):
+ config = get_config()
+
+ return config[codename]['release']

© 2014-2024 Faster IT GmbH | imprint | privacy policy