MCPcopy Index your code
hub / github.com/python/cpython / escape

Function escape

Lib/glob.py:261–271  ·  view source on GitHub ↗

Escape all special characters.

(pathname)

Source from the content-addressed store, hash-verified

259 return pattern == '**'
260
261def escape(pathname):
262 """Escape all special characters.
263 """
264 # Escaping is done by wrapping any of "*?[" between square brackets.
265 # Metacharacters do not work in the drive part and shouldn't be escaped.
266 drive, pathname = os.path.splitdrive(pathname)
267 if isinstance(pathname, bytes):
268 pathname = magic_check_bytes.sub(br'[\1]', pathname)
269 else:
270 pathname = magic_check.sub(r'[\1]', pathname)
271 return drive + pathname
272
273
274_special_parts = ('', '.', '..')

Callers 2

markupMethod · 0.70
normalizeFunction · 0.50

Calls 1

subMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…