Skip to content

Commit

Permalink
Merge pull request #122 from mshriver/fix-table-StopIteration
Browse files Browse the repository at this point in the history
Update Table.__getitem__, wrap StopIteration
  • Loading branch information
izapolsk committed Oct 22, 2018
2 parents b2bc6fd + ad96229 commit bf5e5b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/widgetastic/widget/table.py
Expand Up @@ -456,7 +456,10 @@ def __getitem__(self, item):
if self.table_tree:
nodes = self.resolver.glob(self.table_tree, '/table/tbody/tr*')
at_index = at_index + 1 if self._is_header_in_body else at_index or 1
return next(n.obj for n in nodes if n.position == at_index)
try:
return six.next(n.obj for n in nodes if n.position == at_index)
except StopIteration:
raise RowNotFound('Row not found by index {} via {}'.format(at_index, item))
else:
return self.Row(self, at_index, logger=create_item_logger(self.logger, item))

Expand Down

0 comments on commit bf5e5b2

Please sign in to comment.