@@ -214,26 +214,19 @@ def __init__(self,
214
214
"""
215
215
self .types = types
216
216
self .allow_compressed = allow_compressed
217
- self ._exts = None
218
217
super (ImageFile , self ).__init__ (value , filter , auto_set , entries ,
219
218
exists , ** metadata )
220
219
221
220
def info (self ):
222
- existing = 'n existing' if self .exists else ''
221
+ existing = 'n existing' if self .exists else ''
223
222
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 ''
227
226
return 'a{existing}{comma}{uncompressed} file{with_ext}' .format (
228
227
existing = existing , comma = comma , uncompressed = uncompressed ,
229
228
with_ext = with_ext )
230
229
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
-
237
230
def grab_exts (self ):
238
231
# TODO: file type validation
239
232
exts = []
@@ -260,10 +253,11 @@ def validate(self, object, name, value):
260
253
"""
261
254
validated_value = super (ImageFile , self ).validate (object , name , value )
262
255
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 ):
264
258
raise TraitError (
265
259
args = "{} is not included in allowed types: {}" .format (
266
- validated_value , ', ' .join (self . exts )))
260
+ validated_value , ', ' .join (_exts )))
267
261
return validated_value
268
262
269
263
0 commit comments