本文整理匯總了Python中models.Album.photos方法的典型用法代碼示例。如果您正苦於以下問題:Python Album.photos方法的具體用法?Python Album.photos怎麽用?Python Album.photos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Album
的用法示例。
在下文中一共展示了Album.photos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: loadAlbum
# 需要導入模塊: from models import Album [as 別名]
# 或者: from models.Album import photos [as 別名]
def loadAlbum(self, path, title = None):
album = Album()
if title not in (None, ''):
album.name = title
else:
album.name = path[path.rfind(os.sep)+1:]
album.albums = {}
album.photos = []
album.path = path
files = os.listdir(path)
files.sort()
tmpPhotos = []
for fl in files:
if not os.path.isfile(path + os.sep + fl):
album.albums[fl] = self.loadAlbum(path + os.sep + fl)
else:
if self.isImageFile(path + os.sep + fl):
ph = None
if os.path.exists(path + os.sep + fl + ".sidecar"):
ph = Photo.load(path + os.sep + fl + ".sidecar")
else:
ph = Photo()
ph.comment = ""
ph.keywords = {}
ph.srcPath = None
ph.path = path + os.sep + fl
exif = loadExif(path + os.sep + fl, EXIF_TAGS)
ph.setExif(exif)
ph.save(path + os.sep + fl)
ph.path = path + os.sep + fl
tmpPhotos.append(ph)
album.photos = sorted(tmpPhotos, key = lambda photo: photo.date)
return album