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 |     directories[album] = root_folder | ||||||
|     if recursive: |     if recursive: | ||||||
|         for child_album in album.children(): |         for child_album in album.get_children(): | ||||||
|             child_directories = album_zip_directories(child_album, recursive=True) |             child_directories = album_zip_directories(child_album, recursive=True) | ||||||
|             for (child_album, child_directory) in child_directories.items(): |             for (child_album, child_directory) in child_directories.items(): | ||||||
|                 child_directory = os.path.join(root_folder, child_directory) |                 child_directory = os.path.join(root_folder, child_directory) | ||||||
|  |  | ||||||
|  | @ -16,7 +16,7 @@ def album(a, minimal=False): | ||||||
|             j['parent'] = album(parent, minimal=True) |             j['parent'] = album(parent, minimal=True) | ||||||
|         else: |         else: | ||||||
|             j['parent'] = None |             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 |     return j | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -94,22 +94,6 @@ class GroupableMixin: | ||||||
|             self.photodb.log.debug('Committing - add to group') |             self.photodb.log.debug('Committing - add to group') | ||||||
|             self.photodb.commit() |             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 |     @decorators.transaction | ||||||
|     def delete(self, *, delete_children=False, commit=True): |     def delete(self, *, delete_children=False, commit=True): | ||||||
|         ''' |         ''' | ||||||
|  | @ -127,7 +111,7 @@ class GroupableMixin: | ||||||
|         self.photodb._cached_frozen_children = None |         self.photodb._cached_frozen_children = None | ||||||
|         cur = self.photodb.sql.cursor() |         cur = self.photodb.sql.cursor() | ||||||
|         if delete_children: |         if delete_children: | ||||||
|             for child in self.children(): |             for child in self.get_children(): | ||||||
|                 child.delete(delete_children=delete_children, commit=False) |                 child.delete(delete_children=delete_children, commit=False) | ||||||
|         else: |         else: | ||||||
|             # Lift children |             # Lift children | ||||||
|  | @ -156,6 +140,22 @@ class GroupableMixin: | ||||||
|             self.photodb.log.debug('Committing - delete tag') |             self.photodb.log.debug('Committing - delete tag') | ||||||
|             self.photodb.commit() |             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): |     def get_parent(self): | ||||||
|         ''' |         ''' | ||||||
|         Return the group of which this is a member, or None. |         Return the group of which this is a member, or None. | ||||||
|  | @ -204,7 +204,7 @@ class GroupableMixin: | ||||||
| 
 | 
 | ||||||
|     def walk_children(self): |     def walk_children(self): | ||||||
|         yield self |         yield self | ||||||
|         for child in self.children(): |         for child in self.get_children(): | ||||||
|             yield from child.walk_children() |             yield from child.walk_children() | ||||||
| 
 | 
 | ||||||
|     def walk_parents(self): |     def walk_parents(self): | ||||||
|  | @ -453,7 +453,7 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|         if recurse: |         if recurse: | ||||||
|             if self._sum_bytes_recursive is None: |             if self._sum_bytes_recursive is None: | ||||||
|                 #print(self, 'sumbytes cache miss recursive') |                 #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 |                 self._sum_bytes_recursive = self._sum_bytes_local + child_bytes | ||||||
|             total = self._sum_bytes_recursive |             total = self._sum_bytes_recursive | ||||||
| 
 | 
 | ||||||
|  | @ -467,7 +467,7 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|             #print(self, 'sumphotos cache miss') |             #print(self, 'sumphotos cache miss') | ||||||
|             total = 0 |             total = 0 | ||||||
|             total += sum(1 for x in self.photos()) |             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 |             self._sum_photos_recursive = total | ||||||
| 
 | 
 | ||||||
|         return self._sum_photos_recursive |         return self._sum_photos_recursive | ||||||
|  |  | ||||||
|  | @ -325,7 +325,7 @@ class PDBPhotoMixin: | ||||||
|     def purge_empty_albums(self, *, commit=True): |     def purge_empty_albums(self, *, commit=True): | ||||||
|         albums = self.get_albums() |         albums = self.get_albums() | ||||||
|         for album in albums: |         for album in albums: | ||||||
|             if album.children() or album.photos(): |             if album.get_children() or album.photos(): | ||||||
|                 continue |                 continue | ||||||
|             album.delete(commit=False) |             album.delete(commit=False) | ||||||
|         if commit: |         if commit: | ||||||
|  |  | ||||||
|  | @ -87,7 +87,7 @@ def qualified_names(tags): | ||||||
| 
 | 
 | ||||||
| def stdout(tags, depth=0): | def stdout(tags, depth=0): | ||||||
|     for tag in tags: |     for tag in tags: | ||||||
|         children = tag.children() |         children = tag.get_children() | ||||||
|         synonyms = tag.synonyms() |         synonyms = tag.synonyms() | ||||||
| 
 | 
 | ||||||
|         pad = '    ' * depth |         pad = '    ' * depth | ||||||
|  |  | ||||||
|  | @ -74,7 +74,7 @@ p | ||||||
|         <ul> |         <ul> | ||||||
|             <li>You are here</li> |             <li>You are here</li> | ||||||
|             <ul> |             <ul> | ||||||
|                 {% set sub_albums = album.children() %} |                 {% set sub_albums = album.get_children() %} | ||||||
|                 {% for sub_album in sub_albums|sort(attribute='title') %} |                 {% for sub_album in sub_albums|sort(attribute='title') %} | ||||||
|                 <li><a href="/album/{{sub_album.id}}{{viewparam}}">{{sub_album.display_name}}</a></li> |                 <li><a href="/album/{{sub_album.id}}{{viewparam}}">{{sub_album.display_name}}</a></li> | ||||||
|                 {% endfor %} |                 {% endfor %} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue