implemented config cli

This commit is contained in:
Hellow
2023-04-15 11:54:17 +02:00
parent 5f99e4e41b
commit 9331c39028
5 changed files with 78 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
from .logging import LOGGING_SECTION
from .audio import AUDIO_SECTION
from .config import read, write
from .config import read, write, config
read()

View File

@@ -1,4 +1,4 @@
from typing import Union, Tuple, Dict, Iterable
from typing import Union, Tuple, Dict, Iterable, List
import logging
import os
@@ -25,6 +25,7 @@ class Config:
Description("🏳️‍⚧️🏳️‍⚧️ Protect trans youth. 🏳️‍⚧️🏳️‍⚧️\n"),
)
self._length = 0
self._section_list: List[Section] = []
self._name_section_map: Dict[str, Section] = dict()
@@ -40,6 +41,7 @@ class Config:
f"{element.__class__.__name__} {self._name_section_map[name].__class__.__name__}")
self._name_section_map[name] = element
self._length += 1
def set_name_to_value(self, name: str, value: str):
if name not in self._name_section_map:
@@ -47,6 +49,9 @@ class Config:
self._name_section_map[name][name] = value
def __len__(self):
return self._length
@property
def config_string(self) -> str:
return "\n\n".join(str(element) for element in self.config_elements)