Fixed get_last_library_path and get_system_library_path to not raise KeyError
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.29.21"
|
__version__ = "0.29.22"
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ def dd_to_dms_str(lat, lon):
|
|||||||
|
|
||||||
def get_system_library_path():
|
def get_system_library_path():
|
||||||
""" return the path to the system Photos library as string """
|
""" return the path to the system Photos library as string """
|
||||||
""" only works on MacOS 10.15+ """
|
""" only works on MacOS 10.15 """
|
||||||
""" on earlier versions, returns None """
|
""" on earlier versions, returns None """
|
||||||
_, major, _ = _get_os_version()
|
_, major, _ = _get_os_version()
|
||||||
if int(major) < 15:
|
if int(major) < 15:
|
||||||
@@ -166,16 +166,10 @@ def get_system_library_path():
|
|||||||
with open(plist_file, "rb") as fp:
|
with open(plist_file, "rb") as fp:
|
||||||
pl = plistload(fp)
|
pl = plistload(fp)
|
||||||
else:
|
else:
|
||||||
logging.warning(f"could not find plist file: {str(plist_file)}")
|
logging.debug(f"could not find plist file: {str(plist_file)}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
photospath = pl.get("SystemLibraryPath")
|
return pl.get("SystemLibraryPath")
|
||||||
|
|
||||||
if photospath is not None:
|
|
||||||
return photospath
|
|
||||||
else:
|
|
||||||
logging.warning("Could not get path to Photos database")
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_last_library_path():
|
def get_last_library_path():
|
||||||
@@ -194,7 +188,7 @@ def get_last_library_path():
|
|||||||
|
|
||||||
# get the IPXDefaultLibraryURLBookmark from com.apple.Photos.plist
|
# get the IPXDefaultLibraryURLBookmark from com.apple.Photos.plist
|
||||||
# this is a serialized CFData object
|
# this is a serialized CFData object
|
||||||
photosurlref = pl["IPXDefaultLibraryURLBookmark"]
|
photosurlref = pl.get("IPXDefaultLibraryURLBookmark")
|
||||||
|
|
||||||
if photosurlref is not None:
|
if photosurlref is not None:
|
||||||
# use CFURLCreateByResolvingBookmarkData to de-serialize bookmark data into a CFURLRef
|
# use CFURLCreateByResolvingBookmarkData to de-serialize bookmark data into a CFURLRef
|
||||||
|
|||||||
Reference in New Issue
Block a user