Add delete command.
This commit is contained in:
		
							parent
							
								
									e717833d41
								
							
						
					
					
						commit
						60ac8116aa
					
				
					 1 changed files with 40 additions and 0 deletions
				
			
		|  | @ -179,6 +179,28 @@ def add_remove_tag_argparse(args, action): | |||
|     if args.autoyes or interactive.getpermission('Commit?'): | ||||
|         photodb.commit() | ||||
| 
 | ||||
| def delete_argparse(args): | ||||
|     photodb = find_photodb() | ||||
| 
 | ||||
|     need_commit = False | ||||
|     if args.photo_id_args or args.photo_search_args: | ||||
|         photos = get_photos_from_args(args) | ||||
|         for photo in photos: | ||||
|             photo.delete() | ||||
|             need_commit = True | ||||
| 
 | ||||
|     if args.album_id_args or args.album_search_args: | ||||
|         albums = get_albums_from_args(args) | ||||
|         for album in albums: | ||||
|             album.delete() | ||||
|             need_commit = True | ||||
| 
 | ||||
|     if not need_commit: | ||||
|         return | ||||
| 
 | ||||
|     if args.autoyes or interactive.getpermission('Commit?'): | ||||
|         photodb.commit() | ||||
| 
 | ||||
| def digest_directory_argparse(args): | ||||
|     directory = pathclass.Path(args.directory) | ||||
|     photodb = find_photodb() | ||||
|  | @ -386,6 +408,8 @@ Etiquette CLI | |||
| 
 | ||||
| {remove_tag} | ||||
| 
 | ||||
| {delete} | ||||
| 
 | ||||
| {digest} | ||||
| 
 | ||||
| {easybake} | ||||
|  | @ -437,6 +461,18 @@ remove_tag: | |||
|     > etiquette_cli.py remove_tag watchlist spongebob*.mp4 | ||||
| '''.strip(), | ||||
| 
 | ||||
| delete=''' | ||||
| delete: | ||||
|     Remove photos or albums from the database. | ||||
| 
 | ||||
|     > etiquette_cli.py delete --photos id id id | ||||
|     > etiquette_cli.py delete --search searchargs | ||||
|     > etiquette_cli.py delete --albums id id id | ||||
|     > etiquette_cli.py delete --album-search searchargs | ||||
| 
 | ||||
|     See search --help for more info about searchargs. | ||||
| '''.strip(), | ||||
| 
 | ||||
| digest=''' | ||||
| digest: | ||||
|     Digest a directory, adding new files as Photos into the database. | ||||
|  | @ -686,6 +722,10 @@ def main(argv): | |||
|     p_remove_tag.add_argument('--yes', dest='autoyes', action='store_true') | ||||
|     p_remove_tag.set_defaults(func=lambda args: add_remove_tag_argparse(args, action='remove')) | ||||
| 
 | ||||
|     p_delete = subparsers.add_parser('delete') | ||||
|     p_delete.add_argument('--yes', dest='autoyes', action='store_true') | ||||
|     p_delete.set_defaults(func=delete_argparse) | ||||
| 
 | ||||
|     p_digest = subparsers.add_parser('digest', aliases=['digest_directory', 'digest-directory']) | ||||
|     p_digest.add_argument('directory') | ||||
|     p_digest.add_argument('--no_albums', '--no-albums', dest='make_albums', action='store_false', default=True) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue