Skip to content

Commit

Permalink
fix: bug in unfold when no crumbs left
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsavio committed Feb 17, 2016
1 parent 61ebf66 commit 81a2c36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion hansel/crumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,15 @@ def has_files(self):

def unfold(self):
""" Return a list of all the existing paths until the last crumb argument.
If there are no remaining open arguments,
Returns
-------
paths: list of pathlib.Path
"""
return self.ls(self._last_open_arg()[0], fullpath=True, make_crumbs=True, check_exists=True)
if list(self.open_args()):
return self.ls(self._last_open_arg()[0], fullpath=True, make_crumbs=True, check_exists=True)
else:
return [self]

def __getitem__(self, arg_name):
""" Return the existing values of the crumb argument `arg_name`
Expand Down
4 changes: 3 additions & 1 deletion hansel/tests/test_crumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ def test_ls_with_check(tmp_crumb):

assert 'subj_000' not in img_crumb['subject_id']

assert list(tmp_crumb.unfold()[0].open_args()) == []
unfolded_crumbs = tmp_crumb.unfold()
assert list(unfolded_crumbs[0].open_args()) == []
assert unfolded_crumbs[0].unfold() == [unfolded_crumbs[0]]


def test_regex(tmp_crumb):
Expand Down

0 comments on commit 81a2c36

Please sign in to comment.