Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context hook #326

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/usdb_syncer/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

if TYPE_CHECKING:
from usdb_syncer import usdb_song
from usdb_syncer.song_loader import _Context

# pylint currently lacks support for ParamSpec
# https://github.com/pylint-dev/pylint/issues/9424
Expand Down Expand Up @@ -45,3 +46,11 @@ class SongLoaderDidFinish(_Hook):
@classmethod
def call(cls, song: usdb_song.UsdbSong) -> None:
super().call(song)


class SongLoaderContextDidFinish(_Hook):
"""Called after song download as part of the download context."""

@classmethod
def call(cls, ctx: _Context) -> None:
super().call(ctx)
1 change: 1 addition & 0 deletions src/usdb_syncer/song_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def _run_inner(self) -> UsdbSong:
ctx.locations.move_to_target_folder()
_persist_tempfiles(ctx)
_write_sync_meta(ctx)
hooks.SongLoaderContextDidFinish.call(ctx)
hooks.SongLoaderDidFinish.call(ctx.song)
return ctx.song

Expand Down