Rename Groupable.children -> get_children.
This commit is contained in:
		
							parent
							
								
									75effafaf5
								
							
						
					
					
						commit
						fdcf07940a
					
				
					 6 changed files with 25 additions and 25 deletions
				
			
		|  | @ -29,7 +29,7 @@ def album_zip_directories(album, recursive=True): | |||
| 
 | ||||
|     directories[album] = root_folder | ||||
|     if recursive: | ||||
|         for child_album in album.children(): | ||||
|         for child_album in album.get_children(): | ||||
|             child_directories = album_zip_directories(child_album, recursive=True) | ||||
|             for (child_album, child_directory) in child_directories.items(): | ||||
|                 child_directory = os.path.join(root_folder, child_directory) | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ def album(a, minimal=False): | |||
|             j['parent'] = album(parent, minimal=True) | ||||
|         else: | ||||
|             j['parent'] = None | ||||
|         j['sub_albums'] = [child.id for child in a.children()] | ||||
|         j['sub_albums'] = [child.id for child in a.get_children()] | ||||
| 
 | ||||
|     return j | ||||
| 
 | ||||
|  |  | |||
|  | @ -94,22 +94,6 @@ class GroupableMixin: | |||
|             self.photodb.log.debug('Committing - add to group') | ||||
|             self.photodb.commit() | ||||
| 
 | ||||
|     def children(self): | ||||
|         cur = self.photodb.sql.cursor() | ||||
| 
 | ||||
|         cur.execute('SELECT memberid FROM %s WHERE parentid == ?' % self.group_table, [self.id]) | ||||
|         fetches = cur.fetchall() | ||||
|         results = [] | ||||
|         for fetch in fetches: | ||||
|             memberid = fetch[0] | ||||
|             child = self.group_getter(id=memberid) | ||||
|             results.append(child) | ||||
|         if isinstance(self, Tag): | ||||
|             results.sort(key=lambda x: x.name) | ||||
|         else: | ||||
|             results.sort(key=lambda x: x.id) | ||||
|         return results | ||||
| 
 | ||||
|     @decorators.transaction | ||||
|     def delete(self, *, delete_children=False, commit=True): | ||||
|         ''' | ||||
|  | @ -127,7 +111,7 @@ class GroupableMixin: | |||
|         self.photodb._cached_frozen_children = None | ||||
|         cur = self.photodb.sql.cursor() | ||||
|         if delete_children: | ||||
|             for child in self.children(): | ||||
|             for child in self.get_children(): | ||||
|                 child.delete(delete_children=delete_children, commit=False) | ||||
|         else: | ||||
|             # Lift children | ||||
|  | @ -156,6 +140,22 @@ class GroupableMixin: | |||
|             self.photodb.log.debug('Committing - delete tag') | ||||
|             self.photodb.commit() | ||||
| 
 | ||||
|     def get_children(self): | ||||
|         cur = self.photodb.sql.cursor() | ||||
| 
 | ||||
|         cur.execute('SELECT memberid FROM %s WHERE parentid == ?' % self.group_table, [self.id]) | ||||
|         fetches = cur.fetchall() | ||||
|         results = [] | ||||
|         for fetch in fetches: | ||||
|             memberid = fetch[0] | ||||
|             child = self.group_getter(id=memberid) | ||||
|             results.append(child) | ||||
|         if isinstance(self, Tag): | ||||
|             results.sort(key=lambda x: x.name) | ||||
|         else: | ||||
|             results.sort(key=lambda x: x.id) | ||||
|         return results | ||||
| 
 | ||||
|     def get_parent(self): | ||||
|         ''' | ||||
|         Return the group of which this is a member, or None. | ||||
|  | @ -204,7 +204,7 @@ class GroupableMixin: | |||
| 
 | ||||
|     def walk_children(self): | ||||
|         yield self | ||||
|         for child in self.children(): | ||||
|         for child in self.get_children(): | ||||
|             yield from child.walk_children() | ||||
| 
 | ||||
|     def walk_parents(self): | ||||
|  | @ -453,7 +453,7 @@ class Album(ObjectBase, GroupableMixin): | |||
|         if recurse: | ||||
|             if self._sum_bytes_recursive is None: | ||||
|                 #print(self, 'sumbytes cache miss recursive') | ||||
|                 child_bytes = sum(child.sum_bytes(recurse=True) for child in self.children()) | ||||
|                 child_bytes = sum(child.sum_bytes(recurse=True) for child in self.get_children()) | ||||
|                 self._sum_bytes_recursive = self._sum_bytes_local + child_bytes | ||||
|             total = self._sum_bytes_recursive | ||||
| 
 | ||||
|  | @ -467,7 +467,7 @@ class Album(ObjectBase, GroupableMixin): | |||
|             #print(self, 'sumphotos cache miss') | ||||
|             total = 0 | ||||
|             total += sum(1 for x in self.photos()) | ||||
|             total += sum(child.sum_photos() for child in self.children()) | ||||
|             total += sum(child.sum_photos() for child in self.get_children()) | ||||
|             self._sum_photos_recursive = total | ||||
| 
 | ||||
|         return self._sum_photos_recursive | ||||
|  |  | |||
|  | @ -325,7 +325,7 @@ class PDBPhotoMixin: | |||
|     def purge_empty_albums(self, *, commit=True): | ||||
|         albums = self.get_albums() | ||||
|         for album in albums: | ||||
|             if album.children() or album.photos(): | ||||
|             if album.get_children() or album.photos(): | ||||
|                 continue | ||||
|             album.delete(commit=False) | ||||
|         if commit: | ||||
|  |  | |||
|  | @ -87,7 +87,7 @@ def qualified_names(tags): | |||
| 
 | ||||
| def stdout(tags, depth=0): | ||||
|     for tag in tags: | ||||
|         children = tag.children() | ||||
|         children = tag.get_children() | ||||
|         synonyms = tag.synonyms() | ||||
| 
 | ||||
|         pad = '    ' * depth | ||||
|  |  | |||
|  | @ -74,7 +74,7 @@ p | |||
|         <ul> | ||||
|             <li>You are here</li> | ||||
|             <ul> | ||||
|                 {% set sub_albums = album.children() %} | ||||
|                 {% set sub_albums = album.get_children() %} | ||||
|                 {% for sub_album in sub_albums|sort(attribute='title') %} | ||||
|                 <li><a href="/album/{{sub_album.id}}{{viewparam}}">{{sub_album.display_name}}</a></li> | ||||
|                 {% endfor %} | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue