Files
osxphotos/examples/photos_repl.py
2020-01-20 08:59:52 -08:00

35 lines
777 B
Python
Executable File

#!/usr/bin/env python3 -i
# open an interactive REPL with photosdb and photos defined
# as osxphotos.PhotosDB() and PhotosDB.photos respectively
# useful for debugging or exploring the Photos database
import sys
# click needed since this uses a couple of functions from CLI (__main__.py)
import click
import osxphotos
from osxphotos.__main__ import get_photos_db, _list_libraries
def main():
db = None
if len(sys.argv) > 1:
db = sys.argv[1]
else:
db = get_photos_db()
if db:
return osxphotos.PhotosDB(dbfile=db)
else:
_list_libraries()
sys.exit()
if __name__ == "__main__":
print(f"Version: {osxphotos._version.__version__}")
photosdb = main()
photos = photosdb.photos(images=True, movies=True)