Skip to content

Commit

Permalink
Merge pull request #836 from ZeitOnline/maint/broken_gallery_length
Browse files Browse the repository at this point in the history
MAINT: Set length of broken galleries to 0
  • Loading branch information
stollero committed Sep 13, 2024
2 parents a828219 + 4762dab commit 6370e80
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/zeit/content/gallery/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def items(self):
return list(zip(list(self.keys()), list(self.values())))

def __len__(self):
if self._image_folder is None:
return 0
return int(self._entries_container.xpath('count(block)'))

def __setitem__(self, key, value):
Expand All @@ -185,8 +187,8 @@ def __setitem__(self, key, value):
self._p_changed = True

def updateOrder(self, order):
if set(self.keys()) != set(order):
raise ValueError('The order argument must contain the same ' 'keys as the container.')
if order is None or set(self.keys()) != set(order):
raise ValueError('The order argument must contain the same keys as the container.')
order = [self._get_block_for_key(x) for x in order]
for node in self._entries_container.iterchildren():
self._entries_container.remove(node)
Expand Down

0 comments on commit 6370e80

Please sign in to comment.