Skip to content

Commit c1d1151

Browse files
committed
fix: make info_text of BasePaths a property (@effigies' suggestion)
1 parent 523a21e commit c1d1151

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

nipype/interfaces/base/traits_extension.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,34 @@ class BasePath(TraitType):
9999
"""Defines a trait whose value must be a valid filesystem path."""
100100

101101
# A description of the type of value this trait accepts:
102-
info_text = 'a pathlike object or string'
103102
exists = False
104103
pathlike = False
105104
resolve = False
106105
_is_file = False
107106
_is_dir = False
108107

108+
@property
109+
def info_text(self):
110+
"""Create the trait's general description."""
111+
info_text = 'a pathlike object or string'
112+
if any((self.exists, self._is_file, self._is_dir)):
113+
info_text += ' representing a'
114+
if self.exists:
115+
info_text += 'n existing'
116+
if self._is_file:
117+
info_text += ' file'
118+
elif self._is_dir:
119+
info_text += ' directory'
120+
else:
121+
info_text += ' file or directory'
122+
return info_text
123+
109124
def __init__(self, value=Undefined,
110125
exists=False, pathlike=False, resolve=False, **metadata):
111126
"""Create a BasePath trait."""
112127
self.exists = exists
113128
self.resolve = resolve
114129
self.pathlike = pathlike
115-
if any((exists, self._is_file, self._is_dir)):
116-
self.info_text += ' representing a'
117-
if exists:
118-
self.info_text += 'n existing'
119-
if self._is_file:
120-
self.info_text += ' file'
121-
elif self._is_dir:
122-
self.info_text += ' directory'
123-
else:
124-
self.info_text += ' file or directory'
125-
126130
super(BasePath, self).__init__(value, **metadata)
127131

128132
def validate(self, objekt, name, value, return_pathlike=False):

0 commit comments

Comments
 (0)