Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions grabbit/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ def as_named_tuple(self):
"representing a File as a namedtuple. Replacing "
"entities %s with safe versions %s." % (keys, safe))
entities = dict(zip(keys, self.entities.values()))
_File = namedtuple('File', 'filename ' + ' '.join(entities.keys()))
return _File(filename=self.path, **entities)
_FileTuple = namedtuple('FileTuple', 'path filename dirname ' + ' '.join(entities.keys()))
return _FileTuple(path=self.path,
filename=self.filename, dirname=self.dirname,
**entities)

def copy(self, path_patterns, symbolic_link=False, root=None,
conflicts='fail'):
Expand Down
7 changes: 4 additions & 3 deletions grabbit/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_named_tuple(self, file):
file = copy(file)
file.tags = {'attrA': Tag(None, 'apple'), 'attrB': Tag(None, 'banana')}
tup = file.as_named_tuple()
assert(tup.filename == file.path)
assert(tup.path == file.path)
assert isinstance(tup, tuple)
assert not hasattr(tup, 'task')
assert tup.attrA == 'apple'
Expand Down Expand Up @@ -203,12 +203,13 @@ def test_absolute_paths(self, bids_layout):
layout = Layout([(root, config)], absolute_paths=True)
result = layout.get(subject=1, run=1, session=1)
assert result
assert all([os.path.isabs(f.filename) for f in result])
assert all([os.path.isabs(f.path) for f in result])
assert not any([os.path.isabs(f.filename) for f in result])

layout = Layout([(root, config)], absolute_paths=False)
result = layout.get(subject=1, run=1, session=1)
assert result
assert not any([os.path.isabs(f.filename) for f in result])
assert not any([os.path.isabs(f.path) for f in result])

# Should always be absolute paths on HDFS
else:
Expand Down