@@ -307,44 +307,41 @@ def update_paths(self, key, paths, prepend=True, allow_abs=False, expand_relpath
307307 """
308308 raise NotImplementedError
309309
310+ def _det_user_modpath_common (self , user_modpath ):
311+ """
312+ Helper function for det_user_modpath.
313+ """
314+ # Check for occurences of {RUNTIME_ENV::SOME_ENV_VAR}
315+ # SOME_ENV_VAR will be expanded at module load time.
316+ runtime_env_re = re .compile (r'{RUNTIME_ENV::(\w+)}' )
317+ sub_paths = []
318+ expanded_user_modpath = []
319+ for sub_path in re .split (os .path .sep , user_modpath ):
320+ matched_re = runtime_env_re .match (sub_path )
321+ if matched_re :
322+ if sub_paths :
323+ path = quote_str (os .path .join (* sub_paths ))
324+ expanded_user_modpath .extend ([path ])
325+ sub_paths = []
326+ expanded_user_modpath .extend ([self .getenv_cmd (matched_re .group (1 ))])
327+ else :
328+ sub_paths .append (sub_path )
329+ if sub_paths :
330+ expanded_user_modpath .extend ([quote_str (os .path .join (* sub_paths ))])
331+
332+ # if a mod_path_suffix is being used, we should respect it
333+ mod_path_suffix = build_option ('suffix_modules_path' )
334+ if mod_path_suffix :
335+ expanded_user_modpath .extend ([quote_str (mod_path_suffix )])
336+
337+ return expanded_user_modpath
338+
310339 def det_user_modpath (self , user_modpath ):
311340 """
312341 Determine user-specific modules subdirectory, to be used in 'use' statements
313- (cfr. implementations of use() method).
342+ (cfr. implementation of use() method).
314343 """
315-
316- if self .SYNTAX == 'Tcl' :
317- join_str = ' '
318- else :
319- join_str = ', '
320-
321- if user_modpath :
322- # Check for occurences of {RUNTIME_ENV::SOME_ENV_VAR}
323- # SOME_ENV_VAR will be expanded at module load time.
324- runtime_env_re = re .compile (r'{RUNTIME_ENV::(\w+)}' )
325- sub_paths = []
326- expanded_user_modpath = []
327- for sub_path in re .split (os .path .sep , user_modpath ):
328- matched_re = runtime_env_re .match (sub_path )
329- if matched_re :
330- if sub_paths :
331- path = quote_str (os .path .join (* sub_paths ))
332- expanded_user_modpath .extend ([path ])
333- sub_paths = []
334- expanded_user_modpath .extend ([self .getenv_cmd (matched_re .group (1 ))])
335- else :
336- sub_paths .append (sub_path )
337- if sub_paths :
338- expanded_user_modpath .extend ([quote_str (os .path .join (* sub_paths ))])
339-
340- # if a mod_path_suffix is being used, we should respect it
341- mod_path_suffix = build_option ('suffix_modules_path' )
342- if mod_path_suffix :
343- expanded_user_modpath .extend ([quote_str (mod_path_suffix )])
344-
345- user_modpath = join_str .join (expanded_user_modpath )
346-
347- return user_modpath
344+ raise NotImplementedError
348345
349346 def use (self , paths , prefix = None , guarded = False , user_modpath = None ):
350347 """
@@ -683,6 +680,16 @@ def unload_module(self, mod_name):
683680 """
684681 return '\n ' .join (['' , "module unload %s" % mod_name ])
685682
683+ def det_user_modpath (self , user_modpath ):
684+ """
685+ Determine user-specific modules subdirectory, to be used in 'use' statements
686+ (cfr. implementation of use() method).
687+ """
688+ if user_modpath :
689+ user_modpath = ' ' .join (self ._det_user_modpath_common (user_modpath ))
690+
691+ return user_modpath
692+
686693 def use (self , paths , prefix = None , guarded = False , user_modpath = None ):
687694 """
688695 Generate module use statements for given list of module paths.
@@ -998,6 +1005,16 @@ def unload_module(self, mod_name):
9981005 """
9991006 return '\n ' .join (['' , 'unload("%s")' % mod_name ])
10001007
1008+ def det_user_modpath (self , user_modpath ):
1009+ """
1010+ Determine user-specific modules subdirectory, to be used in 'use' statements
1011+ (cfr. implementations of use() method).
1012+ """
1013+ if user_modpath :
1014+ user_modpath = ', ' .join (self ._det_user_modpath_common (user_modpath ))
1015+
1016+ return user_modpath
1017+
10011018 def use (self , paths , prefix = None , guarded = False , user_modpath = None ):
10021019 """
10031020 Generate module use statements for given list of module paths.
0 commit comments