Escape a string to protect certain characters.
(s: str, protectables: str = PROTECTABLES)
| 358 | |
| 359 | |
| 360 | def protect_filename(s: str, protectables: str = PROTECTABLES) -> str: |
| 361 | """Escape a string to protect certain characters.""" |
| 362 | if set(s) & set(protectables): |
| 363 | if sys.platform == "win32": |
| 364 | return '"' + s + '"' |
| 365 | else: |
| 366 | return "".join(("\\" + c if c in protectables else c) for c in s) |
| 367 | else: |
| 368 | return s |
| 369 | |
| 370 | |
| 371 | def expand_user(path: str) -> tuple[str, bool, str]: |
no outgoing calls
no test coverage detected
searching dependent graphs…