Return 0 from ecli functions.

This commit is contained in:
voussoir 2021-10-15 20:58:10 -07:00
parent 775287d8a8
commit d5e51aa2ea
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -159,6 +159,8 @@ def add_remove_tag_argparse(args, action):
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def delete_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
@ -176,11 +178,13 @@ def delete_argparse(args):
need_commit = True
if not need_commit:
return
return 0
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def digest_directory_argparse(args):
directories = pipeable.input(args.directory, strip=True, skip_blank=True)
directories = [pathclass.Path(d) for d in directories]
@ -209,11 +213,13 @@ def digest_directory_argparse(args):
need_commit = True
if not need_commit:
return
return 0
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def easybake_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
for eb_string in args.eb_strings:
@ -224,6 +230,8 @@ def easybake_argparse(args):
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def export_symlinks_argparse(args):
destination = pathclass.Path(args.destination)
destination.makedirs(exist_ok=True)
@ -249,7 +257,7 @@ def export_symlinks_argparse(args):
total_paths.update(export)
if not args.prune or args.dry_run:
return
return 0
symlinks = spinal.walk(destination, yield_directories=True, yield_files=True)
symlinks = set(path for path in symlinks if path.is_link)
@ -269,6 +277,8 @@ def export_symlinks_argparse(args):
os.rmdir(check.absolute_path)
checkdirs.add(check.parent)
return 0
def generate_thumbnail_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
@ -286,14 +296,17 @@ def generate_thumbnail_argparse(args):
pass
if not need_commit:
return
return 0
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def init_argparse(args):
photodb = etiquette.photodb.PhotoDB(create=True)
photodb.commit()
return 0
def purge_deleted_files_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
@ -310,11 +323,13 @@ def purge_deleted_files_argparse(args):
print(deleted)
if not need_commit:
return
return 0
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def purge_empty_albums_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
@ -333,11 +348,13 @@ def purge_empty_albums_argparse(args):
print(deleted)
if not need_commit:
return
return 0
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def reload_metadata_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
@ -371,11 +388,13 @@ def reload_metadata_argparse(args):
pass
if not need_commit:
return
return 0
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def relocate_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
@ -385,11 +404,15 @@ def relocate_argparse(args):
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def search_argparse(args):
photos = search_by_argparse(args, yield_photos=True)
for photo in photos:
print(photo.real_path.absolute_path)
return 0
def show_associated_directories_argparse(args):
if args.album_id_args or args.album_search_args:
albums = get_albums_from_args(args)
@ -404,6 +427,8 @@ def show_associated_directories_argparse(args):
directories = ' '.join(directories)
print(f'{album} | {directories}')
return 0
def set_unset_searchhidden_argparse(args, searchhidden):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
@ -427,6 +452,8 @@ def set_unset_searchhidden_argparse(args, searchhidden):
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def tag_breplace_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
renames = []
@ -455,7 +482,7 @@ def tag_breplace_argparse(args):
for (tag_name, new_name, printline) in renames:
print(printline)
if not interactive.getpermission('Ok?', must_pick=True):
return
return 0
for (tag_name, new_name, printline) in renames:
print(printline)
@ -467,6 +494,8 @@ def tag_breplace_argparse(args):
if args.autoyes or interactive.getpermission('Commit?'):
photodb.commit()
return 0
def tag_list_argparse(args):
photodb = etiquette.photodb.PhotoDB.closest_photodb()
tags = photodb.get_all_tag_names()
@ -478,6 +507,8 @@ def tag_list_argparse(args):
else:
print(key)
return 0
DOCSTRING = '''
Etiquette CLI
=============