Minor cleanup
This commit is contained in:
		
							parent
							
								
									43bc1e74fc
								
							
						
					
					
						commit
						06522ee372
					
				
					 3 changed files with 16 additions and 12 deletions
				
			
		|  | @ -175,8 +175,6 @@ class GroupableMixin: | ||||||
|         ''' |         ''' | ||||||
|         Leave the current group, then call `group.add(self)`. |         Leave the current group, then call `group.add(self)`. | ||||||
|         ''' |         ''' | ||||||
|         if isinstance(group, str): |  | ||||||
|             group = self.photodb.get_tag(group) |  | ||||||
|         if not isinstance(group, type(self)): |         if not isinstance(group, type(self)): | ||||||
|             raise TypeError('Group must also be %s' % type(self)) |             raise TypeError('Group must also be %s' % type(self)) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -263,13 +263,16 @@ class PDBAlbumMixin: | ||||||
|         Return the album with the `associated_directory` of this value, |         Return the album with the `associated_directory` of this value, | ||||||
|         NOT case-sensitive. |         NOT case-sensitive. | ||||||
|         ''' |         ''' | ||||||
|         filepath = os.path.abspath(filepath) |         filepath = pathclass.Path(filepath).absolute_path | ||||||
|         cur = self.sql.cursor() |         cur = self.sql.cursor() | ||||||
|         cur.execute('SELECT * FROM album_associated_directories WHERE directory == ?', [filepath]) |         cur.execute( | ||||||
|  |             'SELECT albumid FROM album_associated_directories WHERE directory == ?', | ||||||
|  |             [filepath] | ||||||
|  |         ) | ||||||
|         fetch = cur.fetchone() |         fetch = cur.fetchone() | ||||||
|         if fetch is None: |         if fetch is None: | ||||||
|             raise exceptions.NoSuchAlbum(filepath) |             raise exceptions.NoSuchAlbum(filepath) | ||||||
|         album_id = fetch[constants.SQL_ALBUM_DIRECTORY['albumid']] |         album_id = fetch[0] | ||||||
|         return self.get_album(album_id) |         return self.get_album(album_id) | ||||||
| 
 | 
 | ||||||
|     def get_albums(self): |     def get_albums(self): | ||||||
|  | @ -336,7 +339,7 @@ class PDBAlbumMixin: | ||||||
|             query = 'INSERT INTO album_associated_directories VALUES(%s)' % qmarks |             query = 'INSERT INTO album_associated_directories VALUES(%s)' % qmarks | ||||||
|             cur.execute(query, bindings) |             cur.execute(query, bindings) | ||||||
| 
 | 
 | ||||||
|         if photos: |         if photos is not None: | ||||||
|             for photo in photos: |             for photo in photos: | ||||||
|                 photo = self.get_photo(photo) |                 photo = self.get_photo(photo) | ||||||
|                 album.add_photo(photo, commit=False) |                 album.add_photo(photo, commit=False) | ||||||
|  | @ -666,7 +669,7 @@ class PDBPhotoMixin: | ||||||
|             _helper = lambda tagset: searchhelpers.normalize_tag_mmf( |             _helper = lambda tagset: searchhelpers.normalize_tag_mmf( | ||||||
|                 photodb=self, |                 photodb=self, | ||||||
|                 tags=tagset, |                 tags=tagset, | ||||||
|                 warning_bag=warning_bag |                 warning_bag=warning_bag, | ||||||
|             ) |             ) | ||||||
|             tag_musts = _helper(tag_musts) |             tag_musts = _helper(tag_musts) | ||||||
|             tag_mays = _helper(tag_mays) |             tag_mays = _helper(tag_mays) | ||||||
|  | @ -765,6 +768,8 @@ class PDBPhotoMixin: | ||||||
|             else: |             else: | ||||||
|                 frozen_children = self.export_tags(tag_export_totally_flat) |                 frozen_children = self.export_tags(tag_export_totally_flat) | ||||||
|                 self._cached_frozen_children = frozen_children |                 self._cached_frozen_children = frozen_children | ||||||
|  |         else: | ||||||
|  |             frozen_children = None | ||||||
| 
 | 
 | ||||||
|         if tag_expression: |         if tag_expression: | ||||||
|             tag_expression_tree = searchhelpers.tag_expression_tree_builder( |             tag_expression_tree = searchhelpers.tag_expression_tree_builder( | ||||||
|  | @ -1230,14 +1235,15 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs | ||||||
|         If a Photo object already exists for a file, it will be added to the |         If a Photo object already exists for a file, it will be added to the | ||||||
|         correct album. |         correct album. | ||||||
|         ''' |         ''' | ||||||
|         if not os.path.isdir(directory): |         directory = pathclass.Path(directory) | ||||||
|  |         if not directory.is_dir: | ||||||
|             raise ValueError('Not a directory: %s' % directory) |             raise ValueError('Not a directory: %s' % directory) | ||||||
|  | 
 | ||||||
|         if exclude_directories is None: |         if exclude_directories is None: | ||||||
|             exclude_directories = self.config['digest_exclude_dirs'] |             exclude_directories = self.config['digest_exclude_dirs'] | ||||||
|         if exclude_filenames is None: |         if exclude_filenames is None: | ||||||
|             exclude_filenames = self.config['digest_exclude_files'] |             exclude_filenames = self.config['digest_exclude_files'] | ||||||
| 
 | 
 | ||||||
|         directory = spinal.str_to_fp(directory) |  | ||||||
|         directory.correct_case() |         directory.correct_case() | ||||||
|         generator = spinal.walk_generator( |         generator = spinal.walk_generator( | ||||||
|             directory, |             directory, | ||||||
|  |  | ||||||
|  | @ -69,15 +69,15 @@ body | ||||||
|     <div id="left"> |     <div id="left"> | ||||||
|         <ul> |         <ul> | ||||||
|             {% for tag in tags %} |             {% for tag in tags %} | ||||||
|             {% set qualname = tag.qualified_name() %} |             {% set qualified_name = tag.qualified_name() %} | ||||||
|             <li> |             <li> | ||||||
|                 <a target="_blank" class="tag_object" href="/search?tag_musts={{tag.name}}">{{qualname}}</a><!-- |                 <a target="_blank" class="tag_object" href="/search?tag_musts={{tag.name}}">{{qualified_name}}</a><!-- | ||||||
|                 --><button class="remove_tag_button" onclick="delete_tag('{{tag.name}}', receive_callback);"></button> |                 --><button class="remove_tag_button" onclick="delete_tag('{{tag.name}}', receive_callback);"></button> | ||||||
|             </li> |             </li> | ||||||
|             {% if include_synonyms %} |             {% if include_synonyms %} | ||||||
|                 {% for synonym in tag.synonyms() %} |                 {% for synonym in tag.synonyms() %} | ||||||
|                 <li> |                 <li> | ||||||
|                     <a target="_blank" class="tag_object" href="/search?tag_musts={{tag.name}}">{{qualname + "+" + synonym}}</a><!-- |                     <a target="_blank" class="tag_object" href="/search?tag_musts={{tag.name}}">{{qualified_name + "+" + synonym}}</a><!-- | ||||||
|                     --><button class="remove_tag_button" onclick="delete_tag_synonym('{{synonym}}', receive_callback);"></button> |                     --><button class="remove_tag_button" onclick="delete_tag_synonym('{{synonym}}', receive_callback);"></button> | ||||||
|                 </li> |                 </li> | ||||||
|                 {% endfor %} |                 {% endfor %} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue