started the config with loging
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .logging import LOGGING_SECTION
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, List, Union
|
||||
|
||||
COMMENT_PREFIX = "// "
|
||||
|
||||
|
||||
@dataclass
|
||||
class Attribute:
|
||||
@@ -8,16 +10,25 @@ class Attribute:
|
||||
description: Optional[str]
|
||||
value: Union[str, List[str]]
|
||||
|
||||
@property
|
||||
def description_as_comment(self):
|
||||
lines = self.description.split("\n")
|
||||
|
||||
return "\n".join(f"{COMMENT_PREFIX}{line}" for line in lines)
|
||||
|
||||
@property
|
||||
def object_from_value(self):
|
||||
return self.value
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.description_as_comment}\n{self.name}={self.value}"
|
||||
|
||||
|
||||
class SingleAttribute(Attribute):
|
||||
value: str
|
||||
|
||||
|
||||
class StringAttribute(Attribute):
|
||||
class StringAttribute(SingleAttribute):
|
||||
@property
|
||||
def object_from_value(self) -> str:
|
||||
return self.value
|
||||
@@ -26,9 +37,32 @@ class StringAttribute(Attribute):
|
||||
class ListAttribute(Attribute):
|
||||
value: List[str]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.description_as_comment}\n" + \
|
||||
"\n".join(f"{self.name}={element}" for element in self.value)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Description:
|
||||
description: str
|
||||
|
||||
def __str__(self):
|
||||
return f"\n{self.description}"
|
||||
|
||||
|
||||
class EmptyLine(Description):
|
||||
def __init__(self):
|
||||
self.description = "\n"
|
||||
|
||||
|
||||
class Section:
|
||||
"""
|
||||
A placeholder class
|
||||
"""
|
||||
pass
|
||||
attribute_list: List[Union[
|
||||
Attribute,
|
||||
Description
|
||||
]]
|
||||
|
||||
def __str__(self):
|
||||
return "\n".join(attribute.__str__() for attribute in self.attribute_list)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
from typing import Callable
|
||||
|
||||
from .config import SingleAttribute, ListAttribute, StringAttribute, Section
|
||||
from .config import SingleAttribute, StringAttribute, Section, Description, EmptyLine
|
||||
|
||||
LOG_LEVELS = {
|
||||
"CRITICAL": 50,
|
||||
@@ -99,3 +99,22 @@ class LoggingSection(Section):
|
||||
description="The logger for the genius scraper",
|
||||
value="genius"
|
||||
)
|
||||
|
||||
self.attribute_list = [
|
||||
Description("Logging settings for the actual logging:"),
|
||||
self.FORMAT,
|
||||
self.LOG_LEVEL,
|
||||
Description("Just the names for different logger, for different parts of the programm:"),
|
||||
self.DOWNLOAD_LOGGER,
|
||||
self.TAGGING_LOGGER,
|
||||
self.CODEX_LOGGER,
|
||||
self.OBJECT_LOGGER,
|
||||
self.DATABASE_LOGGER,
|
||||
self.MUSIFY_LOGGER,
|
||||
self.YOUTUBE_LOGGER,
|
||||
self.ENCYCLOPAEDIA_METALLUM_LOGGER,
|
||||
self.GENIUS_LOGGER
|
||||
]
|
||||
|
||||
|
||||
LOGGING_SECTION = LoggingSection()
|
||||
|
||||
Reference in New Issue
Block a user