Skip to content

Commit 30b87cf

Browse files
committed
ENH: Modify Directory and File traits to get along with pathlib
Closes #2959
1 parent 6f2f94f commit 30b87cf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

nipype/interfaces/base/traits_extension.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
if USING_PATHLIB2:
3939
from future.types.newstr import newstr
4040

41+
try:
42+
from pathlib import Path
43+
except ImportError:
44+
from pathlib2 import Path
45+
46+
4147
if traits_version < '3.7.0':
4248
raise ImportError('Traits version 3.7.0 or higher must be installed')
4349

@@ -153,7 +159,6 @@ def validate(self, objekt, name, value, return_pathlike=False):
153159

154160
return value
155161

156-
157162
class Directory(BasePath):
158163
"""
159164
Defines a trait whose value must be a directory path.
@@ -194,14 +199,12 @@ class Directory(BasePath):
194199
>>> a.foo
195200
'relative_dir'
196201
197-
198202
>>> class A(TraitedSpec):
199203
... foo = Directory('tmpdir')
200204
>>> a = A()
201205
>>> a.foo # doctest: +ELLIPSIS
202206
<undefined>
203207
204-
205208
>>> class A(TraitedSpec):
206209
... foo = Directory('tmpdir', usedefault=True)
207210
>>> a = A()

nipype/interfaces/spm/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,3 +605,4 @@ def __init__(self, value=NoDefaultSpecified, exists=False, resolve=False, **meta
605605
super(ImageFileSPM, self).__init__(
606606
value=value, exists=exists, types=['nifti1', 'nifti2'],
607607
allow_compressed=False, resolve=resolve, **metadata)
608+

0 commit comments

Comments
 (0)