Normalize case of pathname. Makes all characters lowercase and all slashes into backslashes.
(s, /)
| 48 | LCMAP_LOWERCASE as _LCMAP_LOWERCASE) |
| 49 | |
| 50 | def normcase(s, /): |
| 51 | """Normalize case of pathname. |
| 52 | |
| 53 | Makes all characters lowercase and all slashes into backslashes. |
| 54 | """ |
| 55 | s = os.fspath(s) |
| 56 | if not s: |
| 57 | return s |
| 58 | if isinstance(s, bytes): |
| 59 | encoding = sys.getfilesystemencoding() |
| 60 | s = s.decode(encoding, 'surrogateescape').replace('/', '\\') |
| 61 | s = _LCMapStringEx(_LOCALE_NAME_INVARIANT, |
| 62 | _LCMAP_LOWERCASE, s) |
| 63 | return s.encode(encoding, 'surrogateescape') |
| 64 | else: |
| 65 | return _LCMapStringEx(_LOCALE_NAME_INVARIANT, |
| 66 | _LCMAP_LOWERCASE, |
| 67 | s.replace('/', '\\')) |
| 68 | except ImportError: |
| 69 | def normcase(s, /): |
| 70 | """Normalize case of pathname. |
searching dependent graphs…