2017-11-26 10:37:11 +00:00
|
|
|
import logging
|
|
|
|
handler = logging.StreamHandler()
|
|
|
|
log_format = '{levelname}:etiquette.{module}.{funcName}: {message}'
|
|
|
|
handler.setFormatter(logging.Formatter(log_format, style='{'))
|
|
|
|
logging.getLogger().addHandler(handler)
|
|
|
|
|
2017-11-12 05:40:18 +00:00
|
|
|
import argparse
|
2020-02-19 21:15:03 +00:00
|
|
|
import code
|
2016-10-30 01:46:23 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2017-11-12 05:40:18 +00:00
|
|
|
import traceback
|
|
|
|
|
2020-02-21 02:57:08 +00:00
|
|
|
from voussoirkit import getpermission
|
|
|
|
|
2017-11-12 05:40:18 +00:00
|
|
|
import etiquette
|
2017-06-12 05:55:45 +00:00
|
|
|
|
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:
|
2018-02-17 06:25:56 +00:00
|
|
|
etiquette.tag_export.stdout([P.get_tag(name=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
|
|
|
|
2017-11-12 06:38:51 +00:00
|
|
|
def photag(photo_id):
|
|
|
|
photo = P.get_photo_by_id(photo_id)
|
2018-02-17 07:07:21 +00:00
|
|
|
print(photo.get_tags())
|
2016-09-18 08:33:46 +00:00
|
|
|
while True:
|
|
|
|
photo.add_tag(input('> '))
|
2017-11-12 05:40:18 +00:00
|
|
|
|
2020-02-19 21:15:03 +00:00
|
|
|
get = P.get_tag
|
2017-11-12 05:40:18 +00:00
|
|
|
|
2020-02-19 21:15:03 +00:00
|
|
|
################################################################################
|
2017-11-12 05:40:18 +00:00
|
|
|
def erepl_argparse(args):
|
|
|
|
if args.exec_statement:
|
|
|
|
exec(args.exec_statement)
|
2020-02-21 02:57:08 +00:00
|
|
|
P.commit()
|
2020-02-19 21:15:03 +00:00
|
|
|
else:
|
|
|
|
import code
|
2020-02-21 02:57:08 +00:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
code.interact(banner='', local=dict(globals(), **locals()))
|
|
|
|
except SystemExit:
|
|
|
|
pass
|
|
|
|
if len(P.savepoints) == 0:
|
|
|
|
break
|
|
|
|
print('You have uncommited changes, are you sure you want to quit?')
|
|
|
|
if getpermission.getpermission():
|
|
|
|
break
|
2017-11-12 05:40:18 +00:00
|
|
|
|
|
|
|
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)
|
2020-02-09 01:24:57 +00:00
|
|
|
return args.func(args)
|
2017-11-12 05:40:18 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-02-09 01:24:57 +00:00
|
|
|
raise SystemExit(main(sys.argv[1:]))
|