Add digest_directory.
This commit is contained in:
parent
b9f4b2cf38
commit
7d2e5bd9a9
1 changed files with 26 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
import argparse
|
||||
import sys
|
||||
|
||||
from voussoirkit import getpermission
|
||||
from voussoirkit import pathclass
|
||||
|
||||
import etiquette
|
||||
|
@ -29,6 +30,23 @@ def find_photodb():
|
|||
|
||||
####################################################################################################
|
||||
|
||||
def digest_directory_argparse(args):
|
||||
directory = pathclass.Path(args.directory)
|
||||
photodb = find_photodb()
|
||||
digest = photodb.digest_directory(
|
||||
directory,
|
||||
make_albums=args.make_albums,
|
||||
recurse=args.recurse,
|
||||
new_photo_ratelimit=args.ratelimit,
|
||||
yield_albums=True,
|
||||
yield_photos=True,
|
||||
)
|
||||
for result in digest:
|
||||
print(result)
|
||||
|
||||
if args.autoyes or getpermission.getpermission('Commit?'):
|
||||
photodb.commit()
|
||||
|
||||
def search_by_argparse(args, yield_albums=False, yield_photos=False):
|
||||
photodb = find_photodb()
|
||||
cwd = pathclass.cwd()
|
||||
|
@ -84,6 +102,14 @@ def main(argv):
|
|||
continue
|
||||
mode.append(arg)
|
||||
|
||||
p_digest = subparsers.add_parser('digest', aliases=['digest_directory', 'digest-directory'])
|
||||
p_digest.add_argument('directory')
|
||||
p_digest.add_argument('--no_albums', '--no-albums', dest='make_albums', action='store_false', default=True)
|
||||
p_digest.add_argument('--ratelimit', dest='ratelimit', type=float, default=0.2)
|
||||
p_digest.add_argument('--no_recurse', '--no-recurse', dest='recurse', action='store_false', default=True)
|
||||
p_digest.add_argument('--yes', dest='autoyes', action='store_true')
|
||||
p_digest.set_defaults(func=digest_directory_argparse)
|
||||
|
||||
p_search = subparsers.add_parser('search')
|
||||
p_search.add_argument('--area', dest='area', default=None)
|
||||
p_search.add_argument('--width', dest='width', default=None)
|
||||
|
|
Loading…
Reference in a new issue