etiquette/frontends/etiquette_repl.py

48 lines
971 B
Python
Raw Normal View History

2016-09-18 08:33:46 +00:00
# Use with
# py -i etiquette_easy.py
2017-11-12 05:40:18 +00:00
import argparse
2016-10-30 01:46:23 +00:00
import os
import sys
2017-11-12 05:40:18 +00:00
import traceback
import etiquette
2017-02-05 04:01:03 +00:00
P = etiquette.photodb.PhotoDB()
2016-09-18 08:33:46 +00:00
def easytagger():
while True:
i = input('> ')
if i.startswith('?'):
i = i.split('?')[1] or None
try:
etiquette.tag_export.stdout([P.get_tag(i)])
2016-09-18 08:33:46 +00:00
except:
traceback.print_exc()
2016-10-18 05:13:12 +00:00
else:
P.easybake(i)
2016-09-18 08:33:46 +00:00
def photag(photo_id):
photo = P.get_photo_by_id(photo_id)
2016-09-18 08:33:46 +00:00
print(photo.tags())
while True:
photo.add_tag(input('> '))
2017-11-12 05:40:18 +00:00
get = P.get_tag
def erepl_argparse(args):
if args.exec_statement:
exec(args.exec_statement)
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('--exec', dest='exec_statement', default=None)
parser.set_defaults(func=erepl_argparse)
args = parser.parse_args(argv)
args.func(args)
if __name__ == '__main__':
main(sys.argv[1:])