MCPcopy Create free account
hub / github.com/ipython/ipython / expand_path

Function expand_path

IPython/utils/path.py:282–302  ·  view source on GitHub ↗

Expand $VARS and ~names in a string, like a shell :Examples: In [2]: os.environ['FOO']='test' In [3]: expand_path('variable FOO is $FOO') Out[3]: 'variable FOO is test'

(s)

Source from the content-addressed store, hash-verified

280 return locate_profile(profile=profile)
281
282def expand_path(s):
283 """Expand $VARS and ~names in a string, like a shell
284
285 :Examples:
286
287 In [2]: os.environ['FOO']='test'
288
289 In [3]: expand_path('variable FOO is $FOO')
290 Out[3]: 'variable FOO is test'
291 """
292 # This is a pretty subtle hack. When expand user is given a UNC path
293 # on Windows (\\server\share$\%username%), os.path.expandvars, removes
294 # the $ to get (\\server\share\%username%). I think it considered $
295 # alone an empty var. But, we need the $ to remains there (it indicates
296 # a hidden share).
297 if os.name=='nt':
298 s = s.replace('$\\', 'IPYTHON_TEMP')
299 s = os.path.expandvars(os.path.expanduser(s))
300 if os.name=='nt':
301 s = s.replace('IPYTHON_TEMP', '$\\')
302 return s
303
304
305def unescape_glob(string):

Callers 2

filefindFunction · 0.85
find_profile_dirMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected