mirror of
https://github.com/2martens/uni.git
synced 2026-05-06 19:36:26 +02:00
[OE-Drucken] Started implementation of config parser
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
30
oe/Drucken/oeprint/config.py
Normal file
30
oe/Drucken/oeprint/config.py
Normal file
@ -0,0 +1,30 @@
|
||||
"""config.py: Provides functions to read the config"""
|
||||
|
||||
__author__ = 'Jim Martens'
|
||||
|
||||
import json
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self, config_file):
|
||||
self.config_file = config_file
|
||||
self.config_data = self.load_json_file()
|
||||
|
||||
def load_build(self, build):
|
||||
"""
|
||||
Loads the data of a particular build
|
||||
:type build: str
|
||||
:rtype: object
|
||||
"""
|
||||
build_data = self.config_data[build]
|
||||
return build_data
|
||||
|
||||
def load_json_file(self):
|
||||
"""
|
||||
Loads the JSON config file
|
||||
:type self: oeprint.config.Config
|
||||
:rtype : object
|
||||
"""
|
||||
file = open(self.config_file, 'r', encoding='utf-8')
|
||||
json_data = json.load(file)
|
||||
return json_data
|
||||
Reference in New Issue
Block a user