From aec86f93ea29c62275aeb4ebedb98d57976c93cb Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sun, 15 Aug 2021 13:50:37 -0700 Subject: [PATCH] Added inspect() to repl, closes #501 --- osxphotos/_version.py | 2 +- osxphotos/cli.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/osxphotos/_version.py b/osxphotos/_version.py index 2a09eb95..0a0fc1f2 100644 --- a/osxphotos/_version.py +++ b/osxphotos/_version.py @@ -1,3 +1,3 @@ """ version info """ -__version__ = "0.42.72" +__version__ = "0.42.73" diff --git a/osxphotos/cli.py b/osxphotos/cli.py index c8d6812e..0b06ecc1 100644 --- a/osxphotos/cli.py +++ b/osxphotos/cli.py @@ -4074,6 +4074,10 @@ def _get_selected(photosdb): @click.pass_context def repl(ctx, cli_obj, db): """Run interactive osxphotos shell""" + + from osxphotos import PhotosDB, PhotoInfo, ExifTool + from rich import inspect as _inspect + pretty.install() print(f"python version: {sys.version}") print(f"osxphotos version: {osxphotos._version.__version__}") @@ -4090,6 +4094,10 @@ def repl(ctx, cli_obj, db): show = _show_photo get_selected = _get_selected(photosdb) + def inspect(obj): + """inspect object""" + return _inspect(obj, methods=True) + print(f"Found {len(photos)} photos in {tictoc:0.2f} seconds") print("The following variables are defined:") print(f"- photosdb: PhotosDB() instance for {photosdb.library_path}") @@ -4105,5 +4113,8 @@ def repl(ctx, cli_obj, db): print( f"- help(object): print help text including list of methods for object; for example, help(PhotosDB)" ) + print( + f"- inspect(object): print information about an object; for example inspect(photosdb)" + ) print(f"- quit(): exit this interactive shell\n") code.interact(banner="", local=locals())