return itertools.chain(infos, eggs)
-# Translation table for Prepared.normalize: lowercase and
-# replace "-" (hyphen) and "." (dot) with "_" (underscore).
-_normalize_table = str.maketrans(
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ-.",
- "abcdefghijklmnopqrstuvwxyz__",
-)
-
-
class Prepared:
"""
A prepared search query for metadata on a possibly-named package.
"""
PEP 503 normalization plus dashes as underscores.
"""
- # Emulates ``re.sub(r"[-_.]+", "-", name).lower()`` from PEP 503
- # About 3x faster, safe since packages only support alphanumeric characters
- value = name.translate(_normalize_table)
+ # Much faster than re.sub, and even faster than str.translate
+ value = name.lower().replace("-", "_").replace(".", "_")
# Condense repeats (faster than regex)
while "__" in value:
value = value.replace("__", "_")