Bug fix for empty albums
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.30.9"
|
__version__ = "0.30.10"
|
||||||
|
|||||||
@@ -48,13 +48,16 @@ class AlbumInfo:
|
|||||||
try:
|
try:
|
||||||
return self._photos
|
return self._photos
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
uuid, sort_order = zip(*self._db._dbalbums_album[self.uuid])
|
if self.uuid in self._db._dbalbums_album:
|
||||||
self._photos = self._db.photos(uuid=uuid)
|
uuid, sort_order = zip(*self._db._dbalbums_album[self.uuid])
|
||||||
# PhotosDB.photos does not preserve order when passing in list of uuids
|
self._photos = self._db.photos(uuid=uuid)
|
||||||
# so need to build photo list one a time
|
# PhotosDB.photos does not preserve order when passing in list of uuids
|
||||||
# sort uuids by sort order
|
# so need to build photo list one a time
|
||||||
sorted_uuid = sorted(zip(sort_order, uuid))
|
# sort uuids by sort order
|
||||||
self._photos = [self._db.photos(uuid=[uuid])[0] for _, uuid in sorted_uuid]
|
sorted_uuid = sorted(zip(sort_order, uuid))
|
||||||
|
self._photos = [self._db.photos(uuid=[uuid])[0] for _, uuid in sorted_uuid]
|
||||||
|
else:
|
||||||
|
self._photos = []
|
||||||
return self._photos
|
return self._photos
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -233,6 +233,14 @@ def test_album_sort_order():
|
|||||||
uuids = [p.uuid for p in photos]
|
uuids = [p.uuid for p in photos]
|
||||||
assert uuids == ALBUM_SORT_ORDER
|
assert uuids == ALBUM_SORT_ORDER
|
||||||
|
|
||||||
|
def test_album_empty_album():
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
album = [a for a in photosdb.album_info if a.title == "EmptyAlbum"][0]
|
||||||
|
photos = album.photos
|
||||||
|
assert photos == []
|
||||||
|
|
||||||
def test_attributes():
|
def test_attributes():
|
||||||
import datetime
|
import datetime
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|||||||
Reference in New Issue
Block a user