MCPcopy Index your code
hub / github.com/RustPython/RustPython / escape

Function escape

Lib/glob.py:255–265  ·  view source on GitHub ↗

Escape all special characters.

(pathname)

Source from the content-addressed store, hash-verified

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

Callers 1

markupMethod · 0.70

Calls 2

isinstanceFunction · 0.85
subMethod · 0.45

Tested by

no test coverage detected