Refactored PhotosDB and CLI to require explicity passing the database to avoid non-deterministic behavior when last database can't be found. This may break existing code.

This commit is contained in:
Rhet Turnbull
2020-01-17 16:32:10 -08:00
parent ba1a2b32ad
commit ede56ffc31
6 changed files with 409 additions and 166 deletions

View File

@@ -1,8 +1,14 @@
import osxphotos
import os.path
def main():
photosdb = osxphotos.PhotosDB()
db = osxphotos.utils.get_system_library_path()
if db is None:
# Note: get_system_library_path only works on MacOS 10.15+
db = os.path.expanduser("~/Pictures/Photos Library.photoslibrary")
photosdb = osxphotos.PhotosDB(db)
print(f"db file = {photosdb.db_path}")
print(f"db version = {photosdb.db_version}")