added config for paths
This commit is contained in:
@@ -2,6 +2,7 @@ from .logging import LOGGING_SECTION
|
||||
from .audio import AUDIO_SECTION
|
||||
from .connection import CONNECTION_SECTION
|
||||
from .misc import MISC_SECTION
|
||||
from .paths import PATHS_SECTION
|
||||
|
||||
from .config import read, write, config
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from .audio import AUDIO_SECTION
|
||||
from .logging import LOGGING_SECTION
|
||||
from .connection import CONNECTION_SECTION
|
||||
from .misc import MISC_SECTION
|
||||
from .paths import PATHS_SECTION
|
||||
|
||||
|
||||
LOGGER = logging.getLogger("config")
|
||||
@@ -26,6 +27,8 @@ class Config:
|
||||
AUDIO_SECTION,
|
||||
Description("Modify how Music-Kraken connects to the internet:"),
|
||||
CONNECTION_SECTION,
|
||||
Description("Modify all your paths, except your config file..."),
|
||||
PATHS_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^"),
|
||||
|
||||
52
src/music_kraken/utils/config/paths.py
Normal file
52
src/music_kraken/utils/config/paths.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from pathlib import Path
|
||||
|
||||
from ..path_manager import LOCATIONS
|
||||
from .base_classes import Section, StringAttribute, ListAttribute
|
||||
|
||||
|
||||
class PathAttribute(StringAttribute):
|
||||
@property
|
||||
def object_from_value(self) -> Path:
|
||||
return Path(self.value.strip())
|
||||
|
||||
|
||||
class PathsSection(Section):
|
||||
def __init__(self):
|
||||
self.MUSIC_DIRECTORY = PathAttribute(
|
||||
name="music_directory",
|
||||
description="The directory, all the music will be downloaded to.",
|
||||
value=str(LOCATIONS.MUSIC_DIRECTORY)
|
||||
)
|
||||
|
||||
self.TEMP_DIRECTORY = PathAttribute(
|
||||
name="temp_directory",
|
||||
description="All temporary stuff is gonna be dumped in this directory.",
|
||||
value=str(LOCATIONS.TEMP_DIRECTORY)
|
||||
)
|
||||
|
||||
self.LOG_PATH = PathAttribute(
|
||||
name="log_file",
|
||||
description="The path to the logging file",
|
||||
value=str(LOCATIONS.get_log_file("download_logs.log"))
|
||||
)
|
||||
|
||||
self.NOT_A_GENRE_REGEX = ListAttribute(
|
||||
name="not_a_genre_regex",
|
||||
description="These regular expressions tell music-kraken, which sub-folders of the music-directory\n"
|
||||
"it should ignore, and not count to genres",
|
||||
value=[
|
||||
r'^\.' # is hidden/starts with a "."
|
||||
]
|
||||
)
|
||||
|
||||
self.attribute_list = [
|
||||
self.MUSIC_DIRECTORY,
|
||||
self.TEMP_DIRECTORY,
|
||||
self.LOG_PATH,
|
||||
self.NOT_A_GENRE_REGEX
|
||||
]
|
||||
|
||||
super().__init__()
|
||||
|
||||
|
||||
PATHS_SECTION = PathsSection()
|
||||
Reference in New Issue
Block a user