Skip to content

Commit 47f793e

Browse files
committed
FIX: Do not cache grab_exts
1 parent 3cdb657 commit 47f793e

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

nipype/interfaces/base/traits_extension.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,26 +214,19 @@ def __init__(self,
214214
"""
215215
self.types = types
216216
self.allow_compressed = allow_compressed
217-
self._exts = None
218217
super(ImageFile, self).__init__(value, filter, auto_set, entries,
219218
exists, **metadata)
220219

221220
def info(self):
222-
existing='n existing' if self.exists else ''
221+
existing = 'n existing' if self.exists else ''
223222
comma = ',' if self.exists and not self.allow_compressed else ''
224-
uncompressed=' uncompressed' if not self.allow_compressed else ''
225-
with_ext = ' (valid extensions: [{}])'.format(', '.join(self.exts)) \
226-
if self.types else ''
223+
uncompressed = ' uncompressed' if not self.allow_compressed else ''
224+
with_ext = ' (valid extensions: [{}])'.format(
225+
', '.join(self.grab_exts())) if self.types else ''
227226
return 'a{existing}{comma}{uncompressed} file{with_ext}'.format(
228227
existing=existing, comma=comma, uncompressed=uncompressed,
229228
with_ext=with_ext)
230229

231-
@property
232-
def exts(self):
233-
if self.types and self._exts is None:
234-
self._exts = self.grab_exts()
235-
return self._exts
236-
237230
def grab_exts(self):
238231
# TODO: file type validation
239232
exts = []
@@ -260,10 +253,11 @@ def validate(self, object, name, value):
260253
"""
261254
validated_value = super(ImageFile, self).validate(object, name, value)
262255
if validated_value and self.types:
263-
if not any(validated_value.endswith(x) for x in self.exts):
256+
_exts = self.grab_exts()
257+
if not any(validated_value.endswith(x) for x in _exts):
264258
raise TraitError(
265259
args="{} is not included in allowed types: {}".format(
266-
validated_value, ', '.join(self.exts)))
260+
validated_value, ', '.join(_exts)))
267261
return validated_value
268262

269263

0 commit comments

Comments
 (0)