mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 13:07:09 +01:00
Replaced unnecessary code with one line.
This commit is contained in:
parent
514fa6cf0c
commit
7c0d828a2e
1 changed files with 6 additions and 13 deletions
|
|
@ -79,25 +79,18 @@ def _is_allowed(genre):
|
|||
return False
|
||||
|
||||
def _find_allowed(genres):
|
||||
"""Return the first string in the sequence `genres` that is present
|
||||
in the genre whitelist or None if no genre is suitable.
|
||||
"""Return a string composed of comma delimited genres in the sequence
|
||||
`genres` that is present in the genre whitelist or an empty string
|
||||
if no genre is suitable.
|
||||
"""
|
||||
allowed_genres = []
|
||||
allowed_genres_copy = []
|
||||
|
||||
for genre in list(genres):
|
||||
if _is_allowed(genre):
|
||||
allowed_genres.append(genre.title())
|
||||
|
||||
for genre in allowed_genres[:-1]:
|
||||
genre = genre + ', '
|
||||
allowed_genres_copy.append(genre)
|
||||
else:
|
||||
if allowed_genres:
|
||||
allowed_genres_copy.append(allowed_genres[-1])
|
||||
|
||||
genre_str = ''
|
||||
return genre_str.join(allowed_genres_copy)
|
||||
|
||||
return ','.join(allowed_genres)
|
||||
|
||||
def _strings_to_genre(tags):
|
||||
"""Given a list of strings, return a genre. Returns the first string
|
||||
that is present in the genre whitelist (or the canonicalization
|
||||
|
|
|
|||
Loading…
Reference in a new issue