mirror of
https://github.com/beetbox/beets.git
synced 2025-12-31 13:02:47 +01:00
Document/check non-emptiness in add_album
This commit is contained in:
parent
a81d01b969
commit
0b315cf8c8
1 changed files with 8 additions and 3 deletions
|
|
@ -985,10 +985,15 @@ class Library(dbcore.Database):
|
|||
return obj.id
|
||||
|
||||
def add_album(self, items):
|
||||
"""Create a new album consisting of a list of items. The items
|
||||
are added to the database if they don't yet have an ID. Return a
|
||||
new :class:`Album` object.
|
||||
"""Create a new album consisting of a list of items.
|
||||
|
||||
The items are added to the database if they don't yet have an
|
||||
ID. Return a new :class:`Album` object. The list items must not
|
||||
be empty.
|
||||
"""
|
||||
if not items:
|
||||
raise ValueError(u'need at least one item')
|
||||
|
||||
# Create the album structure using metadata from the first item.
|
||||
values = dict((key, items[0][key]) for key in Album.item_keys)
|
||||
album = Album(self, **values)
|
||||
|
|
|
|||
Loading…
Reference in a new issue