Escape all special characters.
(pathname)
| 253 | return pattern == '**' |
| 254 | |
| 255 | def 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 = ('', '.', '..') |
no test coverage detected