fixed dumb fuck up

This commit is contained in:
Hellow2 2023-04-18 09:02:03 +02:00
parent cae25fb053
commit 1eb2301a23
4 changed files with 19 additions and 3 deletions

View File

@ -7,11 +7,12 @@ import gc
import musicbrainzngs import musicbrainzngs
from . import objects, pages from . import objects, pages
from .utils import exception, shared from .utils import exception, shared, path_manager
from .utils.config import config, read, write, PATHS_SECTION from .utils.config import config, read, write, PATHS_SECTION
from .utils.shared import MUSIC_DIR, MODIFY_GC, NOT_A_GENRE_REGEX, get_random_message from .utils.shared import MUSIC_DIR, MODIFY_GC, NOT_A_GENRE_REGEX, get_random_message
from .utils.string_processing import fit_to_file_system from .utils.string_processing import fit_to_file_system
if MODIFY_GC: if MODIFY_GC:
""" """
At the start I modify the garbage collector to run a bit fewer times. At the start I modify the garbage collector to run a bit fewer times.

View File

@ -60,6 +60,12 @@ if __name__ == "__main__":
action="store_true" action="store_true"
) )
parser.add_argument(
"-r",
help="Resets the config file to the default one.",
action="store_true"
)
arguments = parser.parse_args() arguments = parser.parse_args()
if arguments.verbose or arguments.test: if arguments.verbose or arguments.test:
@ -83,6 +89,12 @@ if __name__ == "__main__":
music_kraken.paths() music_kraken.paths()
exit() exit()
if arguments.r:
import os
if os.path.exists(music_kraken.shared.CONFIG_FILE):
os.remove(music_kraken.shared.CONFIG_FILE)
music_kraken.read()
# getting the genre # getting the genre
genre: str = arguments.genre genre: str = arguments.genre
if arguments.test: if arguments.test:

View File

@ -10,12 +10,12 @@ from .config_directory import get_config_directory
class Locations: class Locations:
def __init__(self, application_name: os.PathLike = "music-kraken"): def __init__(self, application_name: os.PathLike = "music-kraken"):
self.TEMP_DIRECTORY = Path(tempfile.gettempdir(), application_name) self.TEMP_DIRECTORY = Path(tempfile.gettempdir(), application_name)
self.TEMP_DIRECTORY.mkdirs(exist_ok=True) self.TEMP_DIRECTORY.mkdir(exist_ok=True, parents=True)
self.MUSIC_DIRECTORY = get_music_directory() self.MUSIC_DIRECTORY = get_music_directory()
self.CONFIG_DIRECTORY = get_config_directory(str(application_name)) self.CONFIG_DIRECTORY = get_config_directory(str(application_name))
self.CONFIG_DIRECTORY.mkdirs(exist_ok=True) self.CONFIG_DIRECTORY.mkdir(exist_ok=True, parents=True)
self.CONFIG_FILE = Path(self.CONFIG_DIRECTORY, f"{application_name}.conf") self.CONFIG_FILE = Path(self.CONFIG_DIRECTORY, f"{application_name}.conf")
def get_log_file(self, file_name: os.PathLike) -> Path: def get_log_file(self, file_name: os.PathLike) -> Path:

View File

@ -6,6 +6,9 @@ from typing import List, Tuple
from .path_manager import LOCATIONS from .path_manager import LOCATIONS
from .config import LOGGING_SECTION, AUDIO_SECTION, CONNECTION_SECTION, MISC_SECTION, PATHS_SECTION from .config import LOGGING_SECTION, AUDIO_SECTION, CONNECTION_SECTION, MISC_SECTION, PATHS_SECTION
CONFIG_FILE = LOCATIONS.CONFIG_FILE
# modifies the garbage collector to speed up the program # modifies the garbage collector to speed up the program
# https://mkennedy.codes/posts/python-gc-settings-change-this-and-make-your-app-go-20pc-faster/ # https://mkennedy.codes/posts/python-gc-settings-change-this-and-make-your-app-go-20pc-faster/
# https://web.archive.org/web/20221124122222/https://mkennedy.codes/posts/python-gc-settings-change-this-and-make-your-app-go-20pc-faster/ # https://web.archive.org/web/20221124122222/https://mkennedy.codes/posts/python-gc-settings-change-this-and-make-your-app-go-20pc-faster/