Changed AlbumInfo and FolderInfo interface to maintain backwards compatibility with PhotosDB.albums
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
""" version info """
|
||||
|
||||
__version__ = "0.27.0"
|
||||
__version__ = "0.27.1"
|
||||
|
||||
@@ -126,7 +126,7 @@ class FolderInfo:
|
||||
return self._uuid
|
||||
|
||||
@property
|
||||
def albums(self):
|
||||
def album_info(self):
|
||||
""" return list of albums (as AlbumInfo objects) contained in the folder """
|
||||
try:
|
||||
return self._albums
|
||||
@@ -156,7 +156,7 @@ class FolderInfo:
|
||||
return self._parent
|
||||
|
||||
@property
|
||||
def folders(self):
|
||||
def subfolders(self):
|
||||
""" return list of folders (as FolderInfo objects) contained in the folder """
|
||||
try:
|
||||
return self._folders
|
||||
@@ -173,4 +173,4 @@ class FolderInfo:
|
||||
|
||||
def __len__(self):
|
||||
""" returns count of folders + albums contained in the folder """
|
||||
return len(self.folders) + len(self.albums)
|
||||
return len(self.subfolders) + len(self.album_info)
|
||||
|
||||
@@ -28,6 +28,7 @@ from ._constants import (
|
||||
)
|
||||
from .exiftool import ExifTool
|
||||
from .placeinfo import PlaceInfo4, PlaceInfo5
|
||||
from .albuminfo import AlbumInfo
|
||||
from .utils import (
|
||||
_copy_file,
|
||||
_export_photo_uuid_applescript,
|
||||
@@ -256,6 +257,15 @@ class PhotoInfo:
|
||||
albums.append(self._db._dbalbum_details[album]["title"])
|
||||
return albums
|
||||
|
||||
@property
|
||||
def album_info(self):
|
||||
""" list of AlbumInfo objects representing albums the photos is contained in """
|
||||
albums = []
|
||||
for album in self._info["albums"]:
|
||||
albums.append(AlbumInfo(db=self._db, uuid=album))
|
||||
|
||||
return albums
|
||||
|
||||
@property
|
||||
def keywords(self):
|
||||
""" list of keywords for picture """
|
||||
|
||||
@@ -340,8 +340,8 @@ class PhotosDB:
|
||||
return list(persons)
|
||||
|
||||
@property
|
||||
def folders(self):
|
||||
""" return list of top-level folders in the photos database """
|
||||
def folder_info(self):
|
||||
""" return list FolderInfo objects representing top-level folders in the photos database """
|
||||
if self._db_version < _PHOTOS_5_VERSION:
|
||||
logging.warning("Folders not yet implemented for this DB version")
|
||||
return []
|
||||
@@ -356,7 +356,7 @@ class PhotosDB:
|
||||
return folders
|
||||
|
||||
@property
|
||||
def folder_names(self):
|
||||
def folders(self):
|
||||
""" return list of top-level folder names in the photos database """
|
||||
if self._db_version < _PHOTOS_5_VERSION:
|
||||
logging.warning("Folders not yet implemented for this DB version")
|
||||
@@ -371,9 +371,8 @@ class PhotosDB:
|
||||
]
|
||||
return folder_names
|
||||
|
||||
|
||||
@property
|
||||
def albums(self):
|
||||
def album_info(self):
|
||||
""" return list of AlbumInfo objects for each album in the photos database """
|
||||
|
||||
albums = [
|
||||
@@ -385,7 +384,7 @@ class PhotosDB:
|
||||
return albums
|
||||
|
||||
@property
|
||||
def albums_shared(self):
|
||||
def album_info_shared(self):
|
||||
""" return list of AlbumInfo objects for each shared album in the photos database
|
||||
only valid for Photos 5; on Photos <= 4, prints warning and returns empty list """
|
||||
# if _dbalbum_details[key]["cloudownerhashedpersonid"] is not None, then it's a shared album
|
||||
@@ -405,7 +404,7 @@ class PhotosDB:
|
||||
return albums_shared
|
||||
|
||||
@property
|
||||
def album_names(self):
|
||||
def albums(self):
|
||||
""" return list of albums found in photos database """
|
||||
|
||||
# Could be more than one album with same name
|
||||
@@ -420,7 +419,7 @@ class PhotosDB:
|
||||
return list(albums)
|
||||
|
||||
@property
|
||||
def album_names_shared(self):
|
||||
def albums_shared(self):
|
||||
""" return list of shared albums found in photos database
|
||||
only valid for Photos 5; on Photos <= 4, prints warning and returns empty list """
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ TEMPLATE_SUBSTITUTIONS = {
|
||||
# Permitted multi-value substitutions (each of these returns None or 1 or more values)
|
||||
TEMPLATE_SUBSTITUTIONS_MULTI_VALUED = {
|
||||
"{album}": "Album(s) photo is contained in",
|
||||
# "{folder}": "Folder path + album photo is contained in. e.g. Folder/Subfolder/Album",
|
||||
"{keyword}": "Keyword(s) assigned to photo",
|
||||
"{person}": "Person(s) / face(s) in a photo",
|
||||
}
|
||||
@@ -321,6 +322,13 @@ def render_filepath_template(template, photo, none_str="_"):
|
||||
values = photo.persons
|
||||
# remove any _UNKNOWN_PERSON values
|
||||
values = [val for val in values if val != _UNKNOWN_PERSON]
|
||||
# elif field == "folder":
|
||||
# folders = []
|
||||
# # photos must be in an album to be in a folder
|
||||
# albums = photo.albums
|
||||
# for album in albums:
|
||||
# zzz
|
||||
|
||||
else:
|
||||
raise ValueError(f"Unhandleded template value: {field}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user