From c75071ad2dd8c2e5efdef660f1aa33ffa28f0613 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 11 Nov 2017 21:40:18 -0800 Subject: [PATCH] Clean up the erepl code a little bit. --- frontends/etiquette_repl.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/frontends/etiquette_repl.py b/frontends/etiquette_repl.py index 69faebb..b76c00d 100644 --- a/frontends/etiquette_repl.py +++ b/frontends/etiquette_repl.py @@ -1,12 +1,14 @@ # Use with # py -i etiquette_easy.py -import etiquette +import argparse import os import sys +import traceback + +import etiquette P = etiquette.photodb.PhotoDB() -import traceback def easytagger(): while True: @@ -25,4 +27,21 @@ def photag(photoid): print(photo.tags()) while True: photo.add_tag(input('> ')) -get=P.get_tag +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:])