Materialliste ebenfalls aus .json config auslesen. Erste Fassung der Klasse implementiert
This commit is contained in:
@@ -57,5 +57,33 @@ class TOSGroupsConfig:
|
||||
with open(self.config_path, 'r', encoding='utf-8') as fh:
|
||||
self.tos_hierarchy = json.loads(fh.read())
|
||||
|
||||
|
||||
class MaterialConfig:
|
||||
"""Auslesen der Config Angaben zu allen Materialangaben"""
|
||||
|
||||
config_dir = os.environ.get('CREMIG_CFG')
|
||||
config_path = os.path.join(config_dir, 'Materialübersetzung.json')
|
||||
|
||||
def __init__(self):
|
||||
self.materials = None
|
||||
|
||||
def load_materials(self):
|
||||
"""lade die gegebenen Hierarchy aus dem Config File in eine json Objekt"""
|
||||
with open(self.config_path, 'r', encoding='utf-8') as fh:
|
||||
self.materials = json.loads(fh.read())
|
||||
|
||||
def get_all_materials(self):
|
||||
"""hole alle Materialien, welche in der config Datei definiert sind"""
|
||||
|
||||
if not self.materials:
|
||||
self.load_materials()
|
||||
ret = list()
|
||||
for k in self.materials.keys():
|
||||
ret.append(k)
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
Reference in New Issue
Block a user