db: Use the new match / case statement in user.py:do_factory()
This is cleaner than using a bunch of elif-s to pick the right playlist type Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
289420e504
commit
0c7a4a4a4c
24
db/user.py
24
db/user.py
|
@ -140,17 +140,19 @@ class UserTable(playlist.Model):
|
|||
sql.execute("DROP TABLE temp_playlist_map")
|
||||
|
||||
def do_factory(self, row):
|
||||
if row["name"] == "Collection":
|
||||
return Collection(row)
|
||||
elif row["name"] == "Favorites":
|
||||
return UserPlaylist(row, "emmental-favorites", "playlist_map")
|
||||
elif row["name"] == "New Tracks":
|
||||
return UserPlaylist(row, "starred", "temp_playlist_map")
|
||||
elif row["name"] == "Previous":
|
||||
return Previous(row)
|
||||
elif row["name"] == "Queued Tracks":
|
||||
return QueuedTracks(row)
|
||||
return UserPlaylist(row, "audio-x-generic", "playlist_map")
|
||||
match row["name"]:
|
||||
case "Collection":
|
||||
return Collection(row)
|
||||
case "Favorites":
|
||||
return UserPlaylist(row, "emmental-favorites", "playlist_map")
|
||||
case "New Tracks":
|
||||
return UserPlaylist(row, "starred", "temp_playlist_map")
|
||||
case "Previous":
|
||||
return Previous(row)
|
||||
case "Queued Tracks":
|
||||
return QueuedTracks(row)
|
||||
case _:
|
||||
return UserPlaylist(row, "audio-x-generic", "playlist_map")
|
||||
|
||||
def do_insert(self, plstate, name):
|
||||
return sql.execute("INSERT INTO playlists (plstateid, name, sort) "
|
||||
|
|
Loading…
Reference in New Issue