Skip to content

Commit

Permalink
lastgenre: Add comments over groups of methods
Browse files Browse the repository at this point in the history
trying to get a little order in the chaos. Maybe reordering and/or
moving out of the main plugin logic would be a better idea for some
methods but don't put much more refactoring into this PR to keep it
readable.
  • Loading branch information
JOJ0 committed Jan 1, 2025
1 parent a97149c commit 42a2191
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion beetsplug/lastgenre/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def sources(self):
elif source == "artist":
return ("artist",)

# More canonicalization and general helpers.

def _get_depth(self, tag):
"""Find the depth of a tag in the genres tree."""
depth = None
Expand Down Expand Up @@ -255,7 +257,7 @@ def _is_allowed(self, genre):
return True
return False

# Cached entity lookups.
# Cached last.fm entity lookups.

def _last_lookup(self, entity, method, *args):
"""Get a genre based on the named entity using the callable `method`
Expand Down Expand Up @@ -303,6 +305,8 @@ def fetch_track_genre(self, obj):
"track", LASTFM.get_track, obj.artist, obj.title
)

# Main processing: _get_genre() and helpers.

def _get_existing_genres(self, obj, separator):
"""Return a list of genres for this Item or Album."""
if isinstance(obj, library.Item):
Expand Down Expand Up @@ -444,6 +448,8 @@ def _get_genre(self, obj):

return None, None

# Beets plugin hooks and CLI.

def commands(self):
lastgenre_cmd = ui.Subcommand("lastgenre", help="fetch genres")
lastgenre_cmd.parser.add_option(
Expand Down

0 comments on commit 42a2191

Please sign in to comment.