Replace create_or_get_photos with singular.
This commit is contained in:
		
							parent
							
								
									7d2e5bd9a9
								
							
						
					
					
						commit
						6eb4d887ba
					
				
					 1 changed files with 15 additions and 18 deletions
				
			
		|  | @ -1552,13 +1552,11 @@ class PDBUtilMixin: | ||||||
|             photo.relocate(filepath.absolute_path) |             photo.relocate(filepath.absolute_path) | ||||||
|             return photo |             return photo | ||||||
| 
 | 
 | ||||||
|         def create_or_fetch_photos(filepaths, new_photo_kwargs): |         def create_or_fetch_photo(filepath, new_photo_kwargs): | ||||||
|             ''' |             ''' | ||||||
|             Given an iterable of filepaths, find the corresponding Photo object |             Given a filepath, find the corresponding Photo object if it exists, | ||||||
|             if it exists, otherwise create it and then return it. |             otherwise create it and then return it. | ||||||
|             ''' |             ''' | ||||||
|             photos = [] |  | ||||||
|             for filepath in filepaths: |  | ||||||
|             try: |             try: | ||||||
|                 photo = self.get_photo_by_path(filepath) |                 photo = self.get_photo_by_path(filepath) | ||||||
|             except exceptions.NoSuchPhoto: |             except exceptions.NoSuchPhoto: | ||||||
|  | @ -1570,8 +1568,7 @@ class PDBUtilMixin: | ||||||
|                 if new_photo_ratelimit is not None: |                 if new_photo_ratelimit is not None: | ||||||
|                     new_photo_ratelimit.limit() |                     new_photo_ratelimit.limit() | ||||||
| 
 | 
 | ||||||
|                 photos.append(photo) |             return photo | ||||||
|             return photos |  | ||||||
| 
 | 
 | ||||||
|         def create_or_fetch_current_albums(albums_by_path, current_directory): |         def create_or_fetch_current_albums(albums_by_path, current_directory): | ||||||
|             current_albums = albums_by_path.get(current_directory.absolute_path, None) |             current_albums = albums_by_path.get(current_directory.absolute_path, None) | ||||||
|  | @ -1625,7 +1622,7 @@ class PDBUtilMixin: | ||||||
|             if natural_sort: |             if natural_sort: | ||||||
|                 files = sorted(files, key=lambda f: helpers.natural_sorter(f.basename)) |                 files = sorted(files, key=lambda f: helpers.natural_sorter(f.basename)) | ||||||
| 
 | 
 | ||||||
|             photos = create_or_fetch_photos(files, new_photo_kwargs=new_photo_kwargs) |             photos = [create_or_fetch_photo(file, new_photo_kwargs=new_photo_kwargs) for file in files] | ||||||
| 
 | 
 | ||||||
|             if yield_photos: |             if yield_photos: | ||||||
|                 yield from photos |                 yield from photos | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue