refactor(server): register loaded module in sys.modules, add __all__
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ between the REST API and the CLI; musicfetch itself is unchanged."""
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
|
||||
_HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
_MF_PATH = os.environ.get("MUSICFETCH_BIN", os.path.join(_HERE, "..", "musicfetch"))
|
||||
@@ -14,6 +15,7 @@ _loader = importlib.machinery.SourceFileLoader("musicfetch_core", _MF_PATH)
|
||||
_spec = importlib.util.spec_from_loader("musicfetch_core", _loader)
|
||||
_mod = importlib.util.module_from_spec(_spec)
|
||||
_spec.loader.exec_module(_mod) # safe: musicfetch guards main() behind __main__
|
||||
sys.modules["musicfetch_core"] = _mod
|
||||
|
||||
Hit = _mod.Hit
|
||||
build_combined_hits = _mod.build_combined_hits
|
||||
@@ -22,3 +24,6 @@ act_youtube = _mod.act_youtube
|
||||
act_lidarr_album = _mod.act_lidarr_album
|
||||
act_lidarr_artist = _mod.act_lidarr_artist
|
||||
QUALITY_CHOICES = _mod.QUALITY_CHOICES
|
||||
|
||||
__all__ = ["Hit", "build_combined_hits", "pick", "act_youtube",
|
||||
"act_lidarr_album", "act_lidarr_artist", "QUALITY_CHOICES"]
|
||||
|
||||
Reference in New Issue
Block a user