@@ -54,7 +54,7 @@ class Str(Unicode):
54
54
traits .DictStrStr = DictStrStr
55
55
56
56
57
- class BaseFile (BaseUnicode ):
57
+ class File (BaseUnicode ):
58
58
""" Defines a trait whose value must be the name of a file.
59
59
"""
60
60
@@ -96,14 +96,11 @@ def __init__(self,
96
96
if exists :
97
97
self .info_text = 'an existing file name'
98
98
99
- super (BaseFile , self ).__init__ (value , ** metadata )
99
+ super (File , self ).__init__ (value , ** metadata )
100
100
101
101
def validate (self , object , name , value ):
102
- """ Validates that a specified value is valid for this trait.
103
-
104
- Note: The 'fast validator' version performs this check in C.
105
- """
106
- validated_value = super (BaseFile , self ).validate (object , name , value )
102
+ """ Validates that a specified value is valid for this trait."""
103
+ validated_value = super (File , self ).validate (object , name , value )
107
104
if not self .exists :
108
105
return validated_value
109
106
elif os .path .isfile (value ):
@@ -117,53 +114,12 @@ def validate(self, object, name, value):
117
114
self .error (object , name , value )
118
115
119
116
120
- class File (BaseFile ):
121
- """
122
- Defines a trait whose value must be the name of a file.
123
- Disables the default C-level fast validator.
124
- """
125
-
126
- def __init__ (self ,
127
- value = '' ,
128
- filter = None ,
129
- auto_set = False ,
130
- entries = 0 ,
131
- exists = False ,
132
- ** metadata ):
133
- """ Creates a File trait.
134
-
135
- Parameters
136
- ----------
137
- value : string
138
- The default value for the trait
139
- filter : string
140
- A wildcard string to filter filenames in the file dialog box used by
141
- the attribute trait editor.
142
- auto_set : boolean
143
- Indicates whether the file editor updates the trait value after
144
- every key stroke.
145
- exists : boolean
146
- Indicates whether the trait value must be an existing file or
147
- not.
148
-
149
- Default Value
150
- -------------
151
- *value* or ''
152
- """
153
- # if not exists:
154
- # # Define the C-level fast validator to use:
155
- # fast_validate = (11, str)
156
-
157
- super (File , self ).__init__ (value , filter , auto_set , entries , exists ,
158
- ** metadata )
159
-
160
-
161
117
# -------------------------------------------------------------------------------
162
- # 'BaseDirectory' and ' Directory' traits:
118
+ # 'Directory' trait
163
119
# -------------------------------------------------------------------------------
164
120
165
121
166
- class BaseDirectory (BaseUnicode ):
122
+ class Directory (BaseUnicode ):
167
123
"""
168
124
Defines a trait whose value must be the name of a directory.
169
125
"""
@@ -177,7 +133,7 @@ def __init__(self,
177
133
entries = 0 ,
178
134
exists = False ,
179
135
** metadata ):
180
- """ Creates a BaseDirectory trait.
136
+ """ Creates a Directory trait.
181
137
182
138
Parameters
183
139
----------
@@ -201,13 +157,10 @@ def __init__(self,
201
157
if exists :
202
158
self .info_text = 'an existing directory name'
203
159
204
- super (BaseDirectory , self ).__init__ (value , ** metadata )
160
+ super (Directory , self ).__init__ (value , ** metadata )
205
161
206
162
def validate (self , object , name , value ):
207
- """ Validates that a specified value is valid for this trait.
208
-
209
- Note: The 'fast validator' version performs this check in C.
210
- """
163
+ """ Validates that a specified value is valid for this trait."""
211
164
if isinstance (value , (str , bytes )):
212
165
if not self .exists :
213
166
return value
@@ -222,44 +175,6 @@ def validate(self, object, name, value):
222
175
self .error (object , name , value )
223
176
224
177
225
- class Directory (BaseDirectory ):
226
- """
227
- Defines a trait whose value must be the name of a directory.
228
- Disables the default C-level fast validator.
229
- """
230
-
231
- def __init__ (self ,
232
- value = '' ,
233
- auto_set = False ,
234
- entries = 0 ,
235
- exists = False ,
236
- ** metadata ):
237
- """ Creates a Directory trait.
238
-
239
- Parameters
240
- ----------
241
- value : string
242
- The default value for the trait
243
- auto_set : boolean
244
- Indicates whether the directory editor updates the trait value
245
- after every key stroke.
246
- exists : boolean
247
- Indicates whether the trait value must be an existing directory or
248
- not.
249
-
250
- Default Value
251
- -------------
252
- *value* or ''
253
- """
254
- # Define the C-level fast validator to use if the directory existence
255
- # test is not required:
256
- # if not exists:
257
- # self.fast_validate = (11, str)
258
-
259
- super (Directory , self ).__init__ (value , auto_set , entries , exists ,
260
- ** metadata )
261
-
262
-
263
178
# lists of tuples
264
179
# each element consists of :
265
180
# - uncompressed (tuple[0]) extension
0 commit comments