Skip to content

Commit

Permalink
➕ Use kajihs_utils package
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajiih committed Dec 11, 2024
1 parent a1845ee commit f35bbaf
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 133 deletions.
2 changes: 1 addition & 1 deletion dev/bundling/scripts/pyinstaller_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

import PyInstaller.__main__
from cyclopts import App, Parameter
from kajihs_utils.loguru import setup_logging
from loguru import logger

from musicbrainz2notion.__about__ import PROJECT_ROOT # noqa: PLC2701
from musicbrainz2notion.utils import setup_logging

# Define variables for distribution paths and application name
SPEC_PATH = Path("dev/bundling")
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ classifiers = [ # https://pypi.org/classifiers/
dependencies = [
"bs4>=0.0.2",
"cyclopts>=2.9.9",
"frosch<=0.1.5", # 0.1.6
"frosch<=0.1.5", # 0.1.6

"kajihs-utils[loguru]>=0.2.0",
"loguru>=0.7.2",
"musicbrainzngs>=0.7.1",
"notion-client>=2.2.1",
Expand Down
2 changes: 1 addition & 1 deletion src/musicbrainz2notion/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent

__app_name__ = "musicbrainz2notion"
__version__ = "0.4.1"
__version__ = "0.4.2"
__author__ = "Kajih"
__author_email__ = "[email protected]"
__repo_url__ = "https://github.com/Kajiih/musicbrainz2notion"
Expand Down
10 changes: 5 additions & 5 deletions src/musicbrainz2notion/canonical_data_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,32 @@ class NoDumpDirectoriesInIndexPageError(Exception):
"""Raised when no dump directories are found in the index page."""

def __init__(self, base_url: str) -> None:
self.base_url = base_url
self.base_url: str = base_url
super().__init__(f"No dump directories found at URL: {base_url}")


class FailedToFetchDumpDirectoryError(Exception):
"""Raised when the request to fetch the canonical data dump index page fails."""

def __init__(self, base_url: str) -> None:
self.base_url = base_url
self.base_url: str = base_url
super().__init__(f"Failed to fetch dump directory from URL: {base_url}")


class FailedToFetchDumpFileError(Exception):
"""Raised when the request to fetch the dump file list from the dump directory fails."""

def __init__(self, dump_url: str) -> None:
self.dump_url = dump_url
self.dump_url: str = dump_url
super().__init__(f"Failed to fetch dump files from URL: {dump_url}")


class WrongDumpFileNumberError(Exception):
"""Raised when the number of expected files in the dump directory is incorrect."""

def __init__(self, dump_url: str, file_links: list[str]) -> None:
self.dump_url = dump_url
self.file_links = file_links
self.dump_url: str = dump_url
self.file_links: list[str] = file_links
expected_files = 3 # Should be .tar.zst, .md5, and .sha256
super().__init__(
f"Expected {expected_files} files (compressed dump and checksums) in {dump_url}, but found {len(file_links)}: {file_links}"
Expand Down
13 changes: 13 additions & 0 deletions src/musicbrainz2notion/environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Utils for musicbrainz2notion library."""

from enum import StrEnum


class EnvironmentVar(StrEnum):
"""Environment variable keys used in the application."""

NOTION_API_KEY = "MB2NT_NOTION_API_KEY"
ARTIST_DB_ID = "MB2NT_ARTIST_DB_ID"
RELEASE_DB_ID = "MB2NT_RELEASE_DB_ID"
TRACK_DB_ID = "MB2NT_TRACK_DB_ID"
FANART_API_KEY = "MB2NT_FANART_API_KEY"
3 changes: 2 additions & 1 deletion src/musicbrainz2notion/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import typed_settings as ts
from cyclopts import App, Parameter
from dotenv import load_dotenv
from kajihs_utils.loguru import prompt, setup_logging
from loguru import logger
from notion_client import Client
from toolz import dicttoolz # pyright: ignore[reportMissingTypeStubs]
Expand Down Expand Up @@ -44,6 +45,7 @@
get_release_map_with_auto_update,
move_to_trash_outdated_entity_pages,
)
from musicbrainz2notion.environment import EnvironmentVar
from musicbrainz2notion.musicbrainz_data_retrieval import (
browse_release_groups_by_artist,
extract_recording_mbids_and_track_number,
Expand All @@ -60,7 +62,6 @@
is_valid_notion_key,
is_valid_page_id,
)
from musicbrainz2notion.utils import EnvironmentVar, prompt, setup_logging

frosch.hook() # enable frosch for easier debugging

Expand Down
2 changes: 1 addition & 1 deletion src/musicbrainz2notion/musicbrainz_data_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import TYPE_CHECKING

import dateutil.parser
import musicbrainzngs
import musicbrainzngs # pyright: ignore[reportMissingTypeStubs]
from loguru import logger

from musicbrainz2notion.musicbrainz_utils import (
Expand Down
2 changes: 1 addition & 1 deletion src/musicbrainz2notion/thumbnails_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from loguru import logger

from musicbrainz2notion.config import global_settings
from musicbrainz2notion.environment import EnvironmentVar
from musicbrainz2notion.musicbrainz_utils import MBID, CoverSize, EntityType, MBDataDict
from musicbrainz2notion.utils import EnvironmentVar

dotenv.load_dotenv()
FANART_API_KEY = os.getenv(EnvironmentVar.FANART_API_KEY)
Expand Down
87 changes: 0 additions & 87 deletions src/musicbrainz2notion/utils.py

This file was deleted.

Loading

0 comments on commit f35bbaf

Please sign in to comment.