gh-60 Accept a list of inputs instead of source/file arguments
This commit is contained in:
		
							parent
							
								
									1d86856a07
								
							
						
					
					
						commit
						198983156b
					
				
							
								
								
									
										22
									
								
								elodie.py
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								elodie.py
									
									
									
									
									
								
							| @ -27,8 +27,7 @@ def usage(): | |||||||
|     """Return usage message |     """Return usage message | ||||||
|     """ |     """ | ||||||
|     return """ |     return """ | ||||||
| Usage: elodie.py import --source=<s> --destination=<d> [--album-from-folder] | Usage: elodie.py import --destination=<d> [--album-from-folder] INPUT ... | ||||||
|        elodie.py import --file=<f> --destination=<d> [--album-from-folder] |  | ||||||
|        elodie.py update [--time=<t>] [--location=<l>] [--album=<a>] [--title=<t>] INPUT ... |        elodie.py update [--time=<t>] [--location=<l>] [--album=<a>] [--title=<t>] INPUT ... | ||||||
| 
 | 
 | ||||||
|        -h --help    show this |        -h --help    show this | ||||||
| @ -41,6 +40,13 @@ FILESYSTEM = FileSystem() | |||||||
| def import_file(_file, destination, album_from_folder): | def import_file(_file, destination, album_from_folder): | ||||||
|     """Set file metadata and move it to destination. |     """Set file metadata and move it to destination. | ||||||
|     """ |     """ | ||||||
|  |     if not os.path.exists(_file): | ||||||
|  |         if constants.debug: | ||||||
|  |             print 'Could not find %s' % _file | ||||||
|  |         print '{"source":"%s", "error_msg":"Could not find %s"}' % \ | ||||||
|  |             (_file, _file) | ||||||
|  |         return | ||||||
|  | 
 | ||||||
|     media = Media.get_class_by_file(_file, [Audio, Photo, Video]) |     media = Media.get_class_by_file(_file, [Audio, Photo, Video]) | ||||||
|     if not media: |     if not media: | ||||||
|         if constants.debug: |         if constants.debug: | ||||||
| @ -65,11 +71,13 @@ def _import(params): | |||||||
|     """ |     """ | ||||||
|     destination = os.path.expanduser(params['--destination']) |     destination = os.path.expanduser(params['--destination']) | ||||||
| 
 | 
 | ||||||
|     if params['--source']: |     files = set() | ||||||
|         source = os.path.expanduser(params['--source']) |     for path in params['INPUT']: | ||||||
|         files = FILESYSTEM.get_all_files(source, None) |         path = os.path.expanduser(path) | ||||||
|     elif params['--file']: |         if os.path.isdir(path): | ||||||
|         files = [os.path.expanduser(params['--file'])] |             files.update(FILESYSTEM.get_all_files(path, None)) | ||||||
|  |         else: | ||||||
|  |             files.add(path) | ||||||
| 
 | 
 | ||||||
|     for current_file in files: |     for current_file in files: | ||||||
|         import_file(current_file, destination, params['--album-from-folder']) |         import_file(current_file, destination, params['--album-from-folder']) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nathan Ostgard
						Nathan Ostgard