feat: added trace

This commit is contained in:
Hazel 2024-04-10 10:25:05 +02:00
parent 0e2de49831
commit 4e52c0478a
6 changed files with 27 additions and 7 deletions

View File

@ -17,6 +17,7 @@
"python.formatting.provider": "none",
"cSpell.words": [
"Bandcamp",
"levenshtein"
"levenshtein",
"OKBLUE"
]
}

View File

@ -6,9 +6,8 @@ logging.getLogger().setLevel(logging.DEBUG)
if __name__ == "__main__":
commands = [
"s: #a PTK",
"26",
"d: 1",
"s: #a Toxoplasma",
"d: 16",
]

View File

@ -67,6 +67,8 @@ class OuterProxy:
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
UPWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
TITEL = "id"
def __init__(self, _id: int = None, dynamic: bool = False, **kwargs):
_automatic_id: bool = False
@ -218,3 +220,7 @@ class OuterProxy:
def __repr__(self):
return f"{type(self).__name__}({', '.join(key + ': ' + str(val) for key, val in self.indexing_values)})"
@property
def title_string(self) -> str:
return str(self.__getattribute__(self.TITEL))

View File

@ -79,6 +79,7 @@ class Song(Base):
Base.__init__(**locals())
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("album_collection", "main_artist_collection", "feature_artist_collection")
TITEL = "title"
def __init_collections__(self) -> None:
self.album_collection.contain_given_in_attribute = {
@ -214,9 +215,10 @@ class Album(Base):
"artist_collection": Collection,
"song_collection": Collection,
"label_collection": Collection,
}
TITEL = "title"
# This is automatically generated
def __init__(self, title: str = None, unified_title: str = None, album_status: AlbumStatus = None,
album_type: AlbumType = None, language: Language = None, date: ID3Timestamp = None,
@ -430,6 +432,8 @@ class Artist(Base):
"label_collection": Collection,
}
TITEL = "name"
# This is automatically generated
def __init__(self, name: str = "", unified_name: str = None, country: Country = None,
formed_in: ID3Timestamp = None, notes: FormattedText = None, lyrical_themes: List[str] = None,
@ -643,6 +647,8 @@ class Label(Base):
"unified_name": lambda: None,
}
TITEL = "name"
def __init__(self, name: str = None, unified_name: str = None, notes: FormattedText = None,
source_list: List[Source] = None, contact_list: List[Contact] = None,
album_list: List[Album] = None, current_artist_list: List[Artist] = None, **kwargs) -> None:

View File

@ -28,6 +28,7 @@ from ..utils.config import main_settings
from ..utils.support_classes.query import Query
from ..utils.support_classes.download_result import DownloadResult
from ..utils.string_processing import fit_to_file_system
from ..utils import trace
INDEPENDENT_DB_OBJECTS = Union[Label, Album, Artist, Song]
INDEPENDENT_DB_TYPES = Union[Type[Song], Type[Album], Type[Artist], Type[Label]]
@ -235,6 +236,8 @@ class Page:
:return detailed_music_object: IT MODIFIES THE INPUT OBJ
"""
trace(f"fetching {type(music_object).__name__} ({music_object.title_string})")
# creating a new object, of the same type
new_music_object: Optional[DatabaseObject] = None
@ -332,6 +335,7 @@ class Page:
def _download(self, music_object: DatabaseObject, naming_dict: NamingDict, download_all: bool = False,
skip_details: bool = False, process_metadata_anyway: bool = False) -> DownloadResult:
trace(f"downloading {type(music_object).__name__} ({music_object.title_string})")
skip_next_details = skip_details
# Skips all releases, that are defined in shared.ALBUM_TYPE_BLACKLIST, if download_all is False

View File

@ -8,8 +8,6 @@ from .config import config, read_config, write_config
from .enums.colors import BColors
from .path_manager import LOCATIONS
DEBUG = False
"""
IO functions
"""
@ -48,6 +46,12 @@ def dump_to_file(file_name: str, payload: str, is_json: bool = False, exit_after
exit()
def trace(msg: str):
if DEBUG_LOGGING:
logging.debug(msg)
output("trace: " + msg, BColors.OKBLUE)
"""
misc functions