@@ -99,30 +99,34 @@ class BasePath(TraitType):
99
99
"""Defines a trait whose value must be a valid filesystem path."""
100
100
101
101
# A description of the type of value this trait accepts:
102
- info_text = 'a pathlike object or string'
103
102
exists = False
104
103
pathlike = False
105
104
resolve = False
106
105
_is_file = False
107
106
_is_dir = False
108
107
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
+
109
124
def __init__ (self , value = Undefined ,
110
125
exists = False , pathlike = False , resolve = False , ** metadata ):
111
126
"""Create a BasePath trait."""
112
127
self .exists = exists
113
128
self .resolve = resolve
114
129
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
-
126
130
super (BasePath , self ).__init__ (value , ** metadata )
127
131
128
132
def validate (self , objekt , name , value , return_pathlike = False ):
0 commit comments