Updated some doc strings

This commit is contained in:
Rhet Turnbull
2019-11-16 07:28:45 -08:00
parent b0a9e87d00
commit 0c152c8c91

View File

@@ -70,6 +70,8 @@ def _check_file_exists(filename):
class PhotosDB: class PhotosDB:
def __init__(self, dbfile=None): def __init__(self, dbfile=None):
""" create a new PhotosDB object """
""" optional: dbfile=path to photos.db from the Photos library """
# Check OS version # Check OS version
system = platform.system() system = platform.system()
(_, major, _) = _get_os_version() (_, major, _) = _get_os_version()
@@ -141,6 +143,7 @@ class PhotosDB:
self._process_database() self._process_database()
def _cleanup_tmp_files(self): def _cleanup_tmp_files(self):
""" removes all temporary files whose names are stored in self.tmp_files """
print(f"DEBUG: tmp files ={self._tmp_files}") print(f"DEBUG: tmp files ={self._tmp_files}")
for f in self._tmp_files: for f in self._tmp_files:
print(f"DEBUG: cleaning up {f}") print(f"DEBUG: cleaning up {f}")
@@ -154,7 +157,7 @@ class PhotosDB:
self._cleanup_tmp_files() self._cleanup_tmp_files()
def keywords_as_dict(self): def keywords_as_dict(self):
# return keywords as dict of keyword, count in reverse sorted order (descending) """ return keywords as dict of keyword, count in reverse sorted order (descending) """
keywords = {} keywords = {}
for k in self._dbkeywords_keyword.keys(): for k in self._dbkeywords_keyword.keys():
keywords[k] = len(self._dbkeywords_keyword[k]) keywords[k] = len(self._dbkeywords_keyword[k])
@@ -162,7 +165,7 @@ class PhotosDB:
return keywords return keywords
def persons_as_dict(self): def persons_as_dict(self):
# return persons as dict of person, count in reverse sorted order (descending) """ return persons as dict of person, count in reverse sorted order (descending) """
persons = {} persons = {}
for k in self._dbfaces_person.keys(): for k in self._dbfaces_person.keys():
persons[k] = len(self._dbfaces_person[k]) persons[k] = len(self._dbfaces_person[k])
@@ -170,7 +173,7 @@ class PhotosDB:
return persons return persons
def albums_as_dict(self): def albums_as_dict(self):
# return albums as dict of albums, count in reverse sorted order (descending) """ return albums as dict of albums, count in reverse sorted order (descending) """
albums = {} albums = {}
for k in self._dbalbums_album.keys(): for k in self._dbalbums_album.keys():
albums[k] = len(self._dbalbums_album[k]) albums[k] = len(self._dbalbums_album[k])
@@ -178,22 +181,22 @@ class PhotosDB:
return albums return albums
def keywords(self): def keywords(self):
# return list of keywords found in photos database """ return list of keywords found in photos database """
keywords = self._dbkeywords_keyword.keys() keywords = self._dbkeywords_keyword.keys()
return list(keywords) return list(keywords)
def persons(self): def persons(self):
# return persons as dict of person, count in reverse sorted order (descending) """ return persons as dict of person, count in reverse sorted order (descending) """
persons = self._dbfaces_person.keys() persons = self._dbfaces_person.keys()
return list(persons) return list(persons)
def albums(self): def albums(self):
# return albums as dict of albums, count in reverse sorted order (descending) """ return albums as dict of albums, count in reverse sorted order (descending) """
albums = self._dbalbums_album.keys() albums = self._dbalbums_album.keys()
return list(albums) return list(albums)
# Various AppleScripts we need
def _setup_applescript(self): def _setup_applescript(self):
""" setup various applescripts used internally (e.g. to close Photos) """
self._scpt_export = "" self._scpt_export = ""
self._scpt_launch = "" self._scpt_launch = ""
self._scpt_quit = "" self._scpt_quit = ""
@@ -233,7 +236,7 @@ class PhotosDB:
) )
def get_db_version(self): def get_db_version(self):
# return the database version as stored in LiGlobals table """ return the database version as stored in LiGlobals table """
return self.__db_version return self.__db_version
def get_db_path(self): def get_db_path(self):
@@ -241,8 +244,8 @@ class PhotosDB:
return os.path.abspath(self._dbfile) return os.path.abspath(self._dbfile)
def get_photos_library_path(self): def get_photos_library_path(self):
""" return the path to the Photos library """
# TODO: move this to a module-level function # TODO: move this to a module-level function
# return the path to the Photos library
plist_file = Path( plist_file = Path(
str(Path.home()) str(Path.home())
+ "/Library/Containers/com.apple.Photos/Data/Library/Preferences/com.apple.Photos.plist" + "/Library/Containers/com.apple.Photos/Data/Library/Preferences/com.apple.Photos.plist"