music-kraken-core/src/music_kraken/utils/config/config.py

47 lines
1.7 KiB
Python
Raw Normal View History

2023-04-14 15:01:32 +00:00
from typing import Union, Tuple
import logging
import os
2023-04-13 21:45:50 +00:00
2023-04-14 15:01:32 +00:00
from ..path_manager import LOCATIONS
from .base_classes import Description, Attribute, Section, EmptyLine
from .audio import AUDIO_SECTION
from .logging import LOGGING_SECTION
2023-04-14 09:22:47 +00:00
2023-04-13 21:45:50 +00:00
2023-04-14 15:01:32 +00:00
class Config:
def __init__(self):
self.config_elements: Tuple[Union[Description, Attribute, Section], ...] = (
Description("IMPORTANT: If you modify this file, the changes for the actual setting, will be kept as is.\n"
"The changes you make to the comments, will be discarded, next time you run music-kraken. "
"Have fun!"),
Description("Those are all Settings for the audio codec.\n"
"If you, for some reason wanna fill your drive real quickly, I mean enjoy HIFI music,\n"
"feel free to tinker with the Bitrate or smth. :)"),
AUDIO_SECTION,
Description("For all your Logging needs.\n"
"If you found a bug, and wan't to report it, please set the Logging level to 0,\n"
"reproduce the bug, and attach the logfile in the bugreport. ^w^"),
LOGGING_SECTION,
Description("🏳️‍⚧️🏳️‍⚧️ Protect trans youth. 🏳️‍⚧️🏳️‍⚧️"),
EmptyLine()
)
2023-04-14 11:03:48 +00:00
2023-04-14 10:40:52 +00:00
@property
2023-04-14 15:01:32 +00:00
def config_string(self) -> str:
return "\n\n".join(str(element) for element in self.config_elements)
2023-04-14 10:40:52 +00:00
2023-04-14 15:01:32 +00:00
def write_to_config_file(self, path: os.PathLike):
with open(path, "w") as conf_file:
conf_file.write(self.config_string)
2023-04-14 10:40:52 +00:00
2023-04-13 21:45:50 +00:00
2023-04-14 15:01:32 +00:00
config = Config()
2023-04-14 09:22:47 +00:00
2023-04-14 11:03:48 +00:00
2023-04-14 15:01:32 +00:00
def read():
pass
2023-04-13 21:45:50 +00:00
2023-04-14 09:22:47 +00:00
2023-04-14 15:01:32 +00:00
def write():
config.write_to_config_file(LOCATIONS.CONFIG_FILE)