import argparse
import sys
import jinja2
import textwrap
from voussoirkit import betterhelp
from voussoirkit import pathclass
from voussoirkit import pipeable
from voussoirkit import vlogging
log = vlogging.getLogger(__name__, 'imagegallery')
def imagegallery_argparse(args):
patterns = pipeable.input_many(args.patterns)
files = list(pathclass.glob_many_files(patterns))
files.sort()
html = jinja2.Template(textwrap.dedent('''
{% if title %}
{{title}}
{% endif %}
{% if title %}
{{title}}
{% endif %}
Click each photo to view its full resolution. Click the number to download it.
{% for file in files %}
#{{loop.index}}/{{files|length}}
{% endfor %}
''')).render(
files=files,
title=args.title,
urlroot=args.urlroot or '',
)
pathclass.Path('gallery.html').open('w', encoding='utf-8').write(html)
return 0
@vlogging.main_decorator
def main(argv):
parser = argparse.ArgumentParser(
description='''
''',
)
parser.add_argument(
'patterns',
nargs='*',
help='''
''',
)
parser.add_argument(
'--title',
default=None,
help='''
''',
)
parser.add_argument(
'--urlroot',
default=None,
help='''
''',
)
parser.set_defaults(func=imagegallery_argparse)
return betterhelp.go(parser, argv)
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))