Refactored _query. Still hairy, but less so.
This commit is contained in:
@@ -80,7 +80,8 @@ DB_OPTION = click.option(
|
||||
DB_ARGUMENT = click.argument("photos_library", nargs=-1, type=click.Path(exists=True))
|
||||
|
||||
JSON_OPTION = click.option(
|
||||
"--json", "json_",
|
||||
"--json",
|
||||
"json_",
|
||||
required=False,
|
||||
is_flag=True,
|
||||
default=False,
|
||||
@@ -572,37 +573,37 @@ def query(
|
||||
return
|
||||
|
||||
photos = _query(
|
||||
db,
|
||||
keyword,
|
||||
person,
|
||||
album,
|
||||
uuid,
|
||||
title,
|
||||
no_title,
|
||||
description,
|
||||
no_description,
|
||||
ignore_case,
|
||||
edited,
|
||||
external_edit,
|
||||
favorite,
|
||||
not_favorite,
|
||||
hidden,
|
||||
not_hidden,
|
||||
missing,
|
||||
not_missing,
|
||||
shared,
|
||||
not_shared,
|
||||
isphoto,
|
||||
ismovie,
|
||||
uti,
|
||||
burst,
|
||||
not_burst,
|
||||
live,
|
||||
not_live,
|
||||
cloudasset,
|
||||
not_cloudasset,
|
||||
incloud,
|
||||
not_incloud,
|
||||
db=db,
|
||||
keyword=keyword,
|
||||
person=person,
|
||||
album=album,
|
||||
uuid=uuid,
|
||||
title=title,
|
||||
no_title=no_title,
|
||||
description=description,
|
||||
no_description=no_description,
|
||||
ignore_case=ignore_case,
|
||||
edited=edited,
|
||||
external_edit=external_edit,
|
||||
favorite=favorite,
|
||||
not_favorite=not_favorite,
|
||||
hidden=hidden,
|
||||
not_hidden=not_hidden,
|
||||
missing=missing,
|
||||
not_missing=not_missing,
|
||||
shared=shared,
|
||||
not_shared=not_shared,
|
||||
isphoto=isphoto,
|
||||
ismovie=ismovie,
|
||||
uti=uti,
|
||||
burst=burst,
|
||||
not_burst=not_burst,
|
||||
live=live,
|
||||
not_live=not_live,
|
||||
cloudasset=cloudasset,
|
||||
not_cloudasset=not_cloudasset,
|
||||
incloud=incloud,
|
||||
not_incloud=not_incloud,
|
||||
)
|
||||
print_photo_info(photos, cli_obj.json or json_)
|
||||
|
||||
@@ -764,37 +765,37 @@ def export(
|
||||
return
|
||||
|
||||
photos = _query(
|
||||
db,
|
||||
keyword,
|
||||
person,
|
||||
album,
|
||||
uuid,
|
||||
title,
|
||||
no_title,
|
||||
description,
|
||||
no_description,
|
||||
ignore_case,
|
||||
edited,
|
||||
external_edit,
|
||||
favorite,
|
||||
not_favorite,
|
||||
hidden,
|
||||
not_hidden,
|
||||
None, # missing -- won't export these but will warn user
|
||||
None, # not-missing
|
||||
shared,
|
||||
not_shared,
|
||||
isphoto,
|
||||
ismovie,
|
||||
uti,
|
||||
burst,
|
||||
not_burst,
|
||||
live,
|
||||
not_live,
|
||||
False, # cloudasset
|
||||
False, # not_cloudasset
|
||||
False, # incloud
|
||||
False, # not_incloud
|
||||
db=db,
|
||||
keyword=keyword,
|
||||
person=person,
|
||||
album=album,
|
||||
uuid=uuid,
|
||||
title=title,
|
||||
no_title=no_title,
|
||||
description=description,
|
||||
no_description=no_description,
|
||||
ignore_case=ignore_case,
|
||||
edited=edited,
|
||||
external_edit=external_edit,
|
||||
favorite=favorite,
|
||||
not_favorite=not_favorite,
|
||||
hidden=hidden,
|
||||
not_hidden=not_hidden,
|
||||
missing=None, # missing -- won't export these but will warn user
|
||||
not_missing=None,
|
||||
shared=shared,
|
||||
not_shared=not_shared,
|
||||
isphoto=isphoto,
|
||||
ismovie=ismovie,
|
||||
uti=uti,
|
||||
burst=burst,
|
||||
not_burst=not_burst,
|
||||
live=live,
|
||||
not_live=not_live,
|
||||
cloudasset=False,
|
||||
not_cloudasset=False,
|
||||
incloud=False,
|
||||
not_incloud=False,
|
||||
)
|
||||
|
||||
if photos:
|
||||
@@ -939,45 +940,43 @@ def print_photo_info(photos, json=False):
|
||||
|
||||
|
||||
def _query(
|
||||
db,
|
||||
keyword,
|
||||
person,
|
||||
album,
|
||||
uuid,
|
||||
title,
|
||||
no_title,
|
||||
description,
|
||||
no_description,
|
||||
ignore_case,
|
||||
edited,
|
||||
external_edit,
|
||||
favorite,
|
||||
not_favorite,
|
||||
hidden,
|
||||
not_hidden,
|
||||
missing,
|
||||
not_missing,
|
||||
shared,
|
||||
not_shared,
|
||||
isphoto,
|
||||
ismovie,
|
||||
uti,
|
||||
burst,
|
||||
not_burst,
|
||||
live,
|
||||
not_live,
|
||||
cloudasset,
|
||||
not_cloudasset,
|
||||
incloud,
|
||||
not_incloud,
|
||||
db=None,
|
||||
keyword=None,
|
||||
person=None,
|
||||
album=None,
|
||||
uuid=None,
|
||||
title=None,
|
||||
no_title=None,
|
||||
description=None,
|
||||
no_description=None,
|
||||
ignore_case=None,
|
||||
edited=None,
|
||||
external_edit=None,
|
||||
favorite=None,
|
||||
not_favorite=None,
|
||||
hidden=None,
|
||||
not_hidden=None,
|
||||
missing=None,
|
||||
not_missing=None,
|
||||
shared=None,
|
||||
not_shared=None,
|
||||
isphoto=None,
|
||||
ismovie=None,
|
||||
uti=None,
|
||||
burst=None,
|
||||
not_burst=None,
|
||||
live=None,
|
||||
not_live=None,
|
||||
cloudasset=None,
|
||||
not_cloudasset=None,
|
||||
incloud=None,
|
||||
not_incloud=None,
|
||||
):
|
||||
""" run a query against PhotosDB to extract the photos based on user supply criteria """
|
||||
""" used by query and export commands """
|
||||
""" arguments must be passed in same order as query and export """
|
||||
""" if either is modified, need to ensure all three functions are updated """
|
||||
|
||||
# TODO: this is getting too hairy -- need to change to named args
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=db)
|
||||
photos = photosdb.photos(
|
||||
keywords=keyword,
|
||||
|
||||
Reference in New Issue
Block a user