MCPcopy Index your code
hub / github.com/ipython/ipython / expand_path

Function expand_path

IPython/utils/path.py:237–257  ·  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: str)

Source from the content-addressed store, hash-verified

235
236
237def expand_path(s: str) -> str:
238 """Expand $VARS and ~names in a string, like a shell
239
240 :Examples:
241
242 In [2]: os.environ['FOO']='test'
243
244 In [3]: expand_path('variable FOO is $FOO')
245 Out[3]: 'variable FOO is test'
246 """
247 # This is a pretty subtle hack. When expand user is given a UNC path
248 # on Windows (\\server\share$\%username%), os.path.expandvars, removes
249 # the $ to get (\\server\share\%username%). I think it considered $
250 # alone an empty var. But, we need the $ to remains there (it indicates
251 # a hidden share).
252 if os.name=='nt':
253 s = s.replace('$\\', 'IPYTHON_TEMP')
254 s = os.path.expandvars(os.path.expanduser(s))
255 if os.name=='nt':
256 s = s.replace('IPYTHON_TEMP', '$\\')
257 return s
258
259
260def unescape_glob(string):

Callers 2

filefindFunction · 0.85
find_profile_dirMethod · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…