Clean up the erepl code a little bit.
This commit is contained in:
		
							parent
							
								
									a4b875b9ff
								
							
						
					
					
						commit
						c75071ad2d
					
				
					 1 changed files with 22 additions and 3 deletions
				
			
		|  | @ -1,12 +1,14 @@ | ||||||
| # Use with | # Use with | ||||||
| # py -i etiquette_easy.py | # py -i etiquette_easy.py | ||||||
| 
 | 
 | ||||||
| import etiquette | import argparse | ||||||
| import os | import os | ||||||
| import sys | import sys | ||||||
|  | import traceback | ||||||
|  | 
 | ||||||
|  | import etiquette | ||||||
| 
 | 
 | ||||||
| P = etiquette.photodb.PhotoDB() | P = etiquette.photodb.PhotoDB() | ||||||
| import traceback |  | ||||||
| 
 | 
 | ||||||
| def easytagger(): | def easytagger(): | ||||||
|     while True: |     while True: | ||||||
|  | @ -26,3 +28,20 @@ def photag(photoid): | ||||||
|     while True: |     while True: | ||||||
|         photo.add_tag(input('> ')) |         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:]) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue