admintools/config.py

33 lines
821 B
Python

from entry import Entry
class Config:
def __init__(self):
self._entries = []
def add_entry(self, entry: Entry):
self._entries.append(entry)
def get_next_entry(self):
return self._entries.pop()
def __next__(self):
self.get_next_entry()
def __iter__(self):
return iter(self._entries)
def read_config(self, *args, **kwargs):
with open('config.txt', 'r') as file:
for line in file:
self._create_entry(line)
def _create_entry(self, line):
splitts = line.split(';')
assert(len(splitts) == 4)
name = splitts[0]
action, act_param = splitts[1].strip().split(' ')
success, suc_param = splitts[2].strip().split(' ', 1)
fail, fail_param = splitts[3].strip().split(' ', 1)