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

Method normalize

Lib/importlib/metadata/__init__.py:958–969  ·  view source on GitHub ↗

PEP 503 normalization plus dashes as underscores. Specifically avoids ``re.sub`` as prescribed for performance benefits (see python/cpython#143658).

(name)

Source from the content-addressed store, hash-verified

956
957 @staticmethod
958 def normalize(name):
959 """
960 PEP 503 normalization plus dashes as underscores.
961
962 Specifically avoids ``re.sub`` as prescribed for performance
963 benefits (see python/cpython#143658).
964 """
965 value = name.lower().replace("-", "_").replace(".", "_")
966 # Condense repeats
967 while "__" in value:
968 value = value.replace("__", "_")
969 return value
970
971 @staticmethod
972 def legacy_normalize(name):

Callers 3

__init__Method · 0.95
_normalized_nameMethod · 0.45
__init__Method · 0.45

Calls 2

replaceMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected