mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix: importlib import bugs :sigh!
This commit is contained in:
@@ -2,12 +2,11 @@ import sys
|
||||
import pathlib
|
||||
import argparse
|
||||
import multiprocessing
|
||||
from importlib.metadata import version
|
||||
|
||||
from swingmusic import settings
|
||||
from swingmusic.logger import setup_logger
|
||||
from swingmusic import tools as swing_tools
|
||||
from swingmusic.settings import AssetHandler
|
||||
from swingmusic.settings import AssetHandler, Metadata
|
||||
from swingmusic.start_swingmusic import start_swingmusic
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -17,7 +16,7 @@ parser = argparse.ArgumentParser(
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-v", "--version", action="version", version=f"swingmusic v{version('swingmusic')}"
|
||||
"-v", "--version", action="version", version=f"swingmusic v{Metadata.version}"
|
||||
)
|
||||
parser.add_argument("--host", default="0.0.0.0", help="Host to run the app on.")
|
||||
parser.add_argument(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import importlib.resources
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from dataclasses import dataclass, asdict, field, InitVar
|
||||
from swingmusic.data import ARTIST_SPLIT_IGNORE_LIST
|
||||
from swingmusic.settings import Paths, Singleton
|
||||
|
||||
|
||||
@@ -25,10 +25,7 @@ def load_default_artist_ignore_list() -> set[str]:
|
||||
Loads the default artist-ignore-list from the text file.
|
||||
Returns an empty set if the file doesn't exist.
|
||||
"""
|
||||
text = importlib.resources.read_text("swingmusic.data","artist_split_ignore.txt")
|
||||
# only return unique and not empty lines
|
||||
lines = text.splitlines()
|
||||
return set([ line.strip() for line in lines if line.strip() ])
|
||||
return ARTIST_SPLIT_IGNORE_LIST
|
||||
|
||||
|
||||
def load_user_artist_ignore_list() -> set[str]:
|
||||
@@ -91,7 +88,6 @@ class UserConfig(metaclass=Singleton):
|
||||
lastfmApiSecret: str = "5e5306fbf3e8e3bc92f039b6c6c4bd4e"
|
||||
lastfmSessionKeys: dict[str, str] = field(default_factory=dict)
|
||||
|
||||
|
||||
def __post_init__(self, _config_path, _artist_split_ignore_file_name):
|
||||
"""
|
||||
Loads the config file and sets the values to this instance
|
||||
@@ -119,7 +115,6 @@ class UserConfig(metaclass=Singleton):
|
||||
self._config_path = config_path
|
||||
self._finished = True
|
||||
|
||||
|
||||
def setup_config_file(self) -> None:
|
||||
"""
|
||||
Creates the config file with the default settings
|
||||
@@ -130,7 +125,6 @@ class UserConfig(metaclass=Singleton):
|
||||
if not config.exists():
|
||||
self.write_to_file(asdict(self))
|
||||
|
||||
|
||||
def load_config(self, path: Path) -> dict[str, Any]:
|
||||
"""
|
||||
Reads the settings from the config file.
|
||||
@@ -138,7 +132,6 @@ class UserConfig(metaclass=Singleton):
|
||||
"""
|
||||
return json.loads(path.read_text())
|
||||
|
||||
|
||||
def write_to_file(self, settings: dict[str, Any]):
|
||||
"""
|
||||
Writes the settings to the config file
|
||||
@@ -149,7 +142,6 @@ class UserConfig(metaclass=Singleton):
|
||||
with self._config_path.open(mode="w") as f:
|
||||
json.dump(settings, f, indent=4, default=list)
|
||||
|
||||
|
||||
def __setattr__(self, key: str, value: Any) -> None:
|
||||
"""
|
||||
Writes to the config file whenever a value is set
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
ARTIST_SPLIT_IGNORE_LIST = {
|
||||
"AC/DC",
|
||||
"Bob marley & the wailers",
|
||||
"Crosby, Stills, Nash & Young",
|
||||
"Smith & Thell",
|
||||
"Peter, Paul & Mary",
|
||||
"Simon & Garfunkel",
|
||||
"Judy & Mary",
|
||||
"Florence & The Machine",
|
||||
"Belle & Sebastian",
|
||||
"C&C Music Factory",
|
||||
"C & C Music Factory",
|
||||
"FO&O",
|
||||
"The Product G&B",
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
AC/DC
|
||||
Bob marley & the wailers
|
||||
Crosby, Stills, Nash & Young
|
||||
Smith & Thell
|
||||
Peter, Paul & Mary
|
||||
Simon & Garfunkel
|
||||
Judy & Mary
|
||||
Florence & The Machine
|
||||
Belle & Sebastian
|
||||
C&C Music Factory
|
||||
C & C Music Factory
|
||||
FO&O
|
||||
The Product G&B
|
||||
@@ -90,7 +90,6 @@ class AssetHandler:
|
||||
if (path / "index.html").exists():
|
||||
return True
|
||||
|
||||
log.error("Client zip could not be found. Please provide a valid path.")
|
||||
return False
|
||||
|
||||
with zipfile.ZipFile(client_zip_path, "r") as zip_ref:
|
||||
|
||||
Reference in New Issue
Block a user