@@ -180,53 +180,41 @@ def from_config(cls, config: Config) -> ScriptDirectory:
180
180
version_locations_str = config .get_main_option ("version_locations" )
181
181
version_locations : Optional [List [str ]]
182
182
if version_locations_str :
183
- version_path_separator = config .get_main_option (
183
+ split_char = config .get_separator_char (
184
184
"version_path_separator"
185
185
)
186
186
187
- split_on_path = {
188
- None : None ,
189
- "space" : " " ,
190
- "newline" : "\n " ,
191
- "os" : os .pathsep ,
192
- ":" : ":" ,
193
- ";" : ";" ,
194
- }
195
-
196
- try :
197
- split_char : Optional [str ] = split_on_path [
198
- version_path_separator
199
- ]
200
- except KeyError as ke :
201
- raise ValueError (
202
- "'%s' is not a valid value for "
203
- "version_path_separator; "
204
- "expected 'space', 'newline', 'os', ':', ';'"
205
- % version_path_separator
206
- ) from ke
187
+ if split_char is None :
188
+ # legacy behaviour for backwards compatibility
189
+ version_locations = _split_on_space_comma .split (
190
+ version_locations_str
191
+ )
207
192
else :
208
- if split_char is None :
209
- # legacy behaviour for backwards compatibility
210
- version_locations = _split_on_space_comma .split (
211
- version_locations_str
212
- )
213
- else :
214
- version_locations = [
215
- x .strip ()
216
- for x in version_locations_str .split (split_char )
217
- if x
218
- ]
193
+ version_locations = [
194
+ x .strip ()
195
+ for x in version_locations_str .split (split_char )
196
+ if x
197
+ ]
219
198
else :
220
199
version_locations = None
221
200
222
201
prepend_sys_path = config .get_main_option ("prepend_sys_path" )
223
202
if prepend_sys_path :
224
- if os .name == 'nt' :
225
- prepend_paths = _split_on_space_comma .split (prepend_sys_path )
203
+ split_char = config .get_separator_char (
204
+ "prepend_sys_path_separator"
205
+ )
206
+
207
+ if split_char is None :
208
+ # legacy behaviour for backwards compatibility
209
+ sys .path [:0 ] = list (
210
+ _split_on_space_comma_colon .split (prepend_sys_path )
211
+ )
226
212
else :
227
- prepend_paths = _split_on_space_comma_colon .split (prepend_sys_path )
228
-
229
- sys .path [:0 ] = (os .path .normpath (path .strip ()) for path in prepend_paths )
213
+ sys .path [:0 ] = (
214
+ path .strip ()
215
+ for path in prepend_sys_path .split (split_char )
216
+ if path
217
+ )
230
218
231
219
rvl = config .get_main_option ("recursive_version_locations" ) == "true"
232
220
return ScriptDirectory (
0 commit comments