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

Function normcase

Lib/ntpath.py:50–67  ·  view source on GitHub ↗

Normalize case of pathname. Makes all characters lowercase and all slashes into backslashes.

(s, /)

Source from the content-addressed store, hash-verified

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('/', '\\'))
68except ImportError:
69 def normcase(s, /):
70 """Normalize case of pathname.

Callers 11

test_inspect.pyFile · 0.90
reviseFunction · 0.90
test_getsourcefileMethod · 0.90
_readlink_deepFunction · 0.70
realpathFunction · 0.70
relpathFunction · 0.70
_assert_cwdMethod · 0.50
test_normcaseMethod · 0.50
test_normcaseMethod · 0.50
assertEqualNormCaseMethod · 0.50

Calls 4

replaceMethod · 0.45
decodeMethod · 0.45
encodeMethod · 0.45
lowerMethod · 0.45

Tested by 7

reviseFunction · 0.72
test_getsourcefileMethod · 0.72
_assert_cwdMethod · 0.40
test_normcaseMethod · 0.40
test_normcaseMethod · 0.40
assertEqualNormCaseMethod · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…