music-kraken-core/music_kraken/pages/__init__.py

52 lines
1.4 KiB
Python
Raw Normal View History

import importlib
import inspect
2024-05-24 13:46:42 +00:00
import logging
import pkgutil
import sys
from collections import defaultdict
from copy import copy
2024-05-24 13:46:42 +00:00
from pathlib import Path
2024-05-23 15:27:24 +00:00
from typing import Dict, Generator, List, Set, Type
2024-05-23 15:27:24 +00:00
from ._bandcamp import Bandcamp
from ._encyclopaedia_metallum import EncyclopaediaMetallum
2024-05-23 15:27:24 +00:00
from ._genius import Genius
from ._musify import Musify
from ._youtube import YouTube
from ._youtube_music import YoutubeMusic
2024-05-24 13:46:42 +00:00
def import_children():
_page_directory = Path(__file__).parent
_stem_blacklist = set(["__pycache__", "__init__"])
for _file in _page_directory.iterdir():
if _file.stem in _stem_blacklist:
continue
logging.debug(f"importing {_file.absolute()}")
exec(f"from . import {_file.stem}")
# module_blacklist = set(sys.modules.keys())
import_children()
"""
classes = set()
print(__name__)
for module_name, module in sys.modules.items():
if module_name in module_blacklist or not module_name.startswith(__name__):
2024-05-24 13:46:42 +00:00
continue
print("scanning module", module_name)
for name, obj in inspect.getmembers(module, predicate=inspect.isclass):
_module = obj.__module__
if _module.startswith(__name__) and hasattr(obj, "SOURCE_TYPE"):
print("checking object", name, obj.__module__)
classes.add(obj)
print()
print(*(c.__name__ for c in classes), sep=",\t")
__all__ = [c.__name__ for c in classes]
"""