Added show() to photos_repl.py

This commit is contained in:
Rhet Turnbull
2020-06-16 22:46:46 -07:00
parent d77e9747cd
commit e98c3fe429

View File

@@ -7,6 +7,7 @@
# If you run this using python from command line, do so with -i flag:
# python3 -i examples/photos_repl.py
import os
import sys
import time
@@ -17,6 +18,23 @@ import osxphotos
from osxphotos.__main__ import get_photos_db, _list_libraries
def show(photo):
""" open image with default image viewer
Note: This is for debugging only -- it will actually open any filetype which could
be very, very bad.
Args:
photo: PhotoInfo object or a path to a photo on disk
"""
photopath = photo.path if isinstance(photo, osxphotos.PhotoInfo) else photo
if not os.path.isfile(photopath):
return f"'{photopath}' does not appear to be a valid photo path"
os.system(f"open '{photopath}'")
def main():
db = None