Skip to content

Commit

Permalink
Fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Oct 18, 2024
1 parent 78a1cbb commit fe56463
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/palace/manager/core/classifier/simplified.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from urllib.parse import unquote

from palace.manager.core.classifier import (
NO_VALUE,
Classifier,
Lowercased,
fiction_genres,
genres,
nonfiction_genres,
)
from palace.manager.core import classifier
from palace.manager.core.classifier import NO_VALUE, Classifier, Lowercased


class SimplifiedGenreClassifier(Classifier):
Expand All @@ -27,27 +21,27 @@ def scrub_identifier(cls, identifier):
@classmethod
def genre(cls, identifier, name, fiction=None, audience=None):
if fiction == True:
all_genres = fiction_genres
all_genres = classifier.fiction_genres
elif fiction == False:
all_genres = nonfiction_genres
all_genres = classifier.nonfiction_genres
else:
all_genres = fiction_genres + nonfiction_genres
all_genres = classifier.fiction_genres + classifier.nonfiction_genres
return cls._genre_by_name(identifier.original, all_genres)

@classmethod
def is_fiction(cls, identifier, name):
if not genres.get(identifier.original):
if not classifier.genres.get(identifier.original):
return None
return genres[identifier.original].is_fiction
return classifier.genres[identifier.original].is_fiction

@classmethod
def _genre_by_name(cls, name, genres):
for genre in genres:
if genre == name:
return genres[name]
return classifier.genres[name]
elif isinstance(genre, dict):
if name == genre["name"] or name in genre.get("subgenres", []):
return genres[name]
return classifier.genres[name]
return None


Expand Down

0 comments on commit fe56463

Please sign in to comment.