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

Method __init__

Lib/importlib/metadata/__init__.py:881–908  ·  view source on GitHub ↗

Calculate all of the children representing metadata. From the children in the path, calculate early all of the children that appear to represent metadata (infos) or legacy metadata (eggs).

(self, path: FastPath)

Source from the content-addressed store, hash-verified

879 """
880
881 def __init__(self, path: FastPath):
882 """
883 Calculate all of the children representing metadata.
884
885 From the children in the path, calculate early all of the
886 children that appear to represent metadata (infos) or legacy
887 metadata (eggs).
888 """
889
890 base = os.path.basename(path.root).lower()
891 base_is_egg = base.endswith(".egg")
892 self.infos = FreezableDefaultDict(list)
893 self.eggs = FreezableDefaultDict(list)
894
895 for child in path.children():
896 low = child.lower()
897 if low.endswith((".dist-info", ".egg-info")):
898 # rpartition is faster than splitext and suitable for this purpose.
899 name = low.rpartition(".")[0].partition("-")[0]
900 normalized = Prepared.normalize(name)
901 self.infos[normalized].append(path.joinpath(child))
902 elif base_is_egg and low == "egg-info":
903 name = base.rpartition(".")[0].partition("-")[0]
904 legacy_normalized = Prepared.legacy_normalize(name)
905 self.eggs[legacy_normalized].append(path.joinpath(child))
906
907 self.infos.freeze()
908 self.eggs.freeze()
909
910 def search(self, prepared: Prepared):
911 """

Callers

nothing calls this directly

Calls 12

legacy_normalizeMethod · 0.80
freezeMethod · 0.80
lowerMethod · 0.45
basenameMethod · 0.45
endswithMethod · 0.45
childrenMethod · 0.45
partitionMethod · 0.45
rpartitionMethod · 0.45
normalizeMethod · 0.45
appendMethod · 0.45
joinpathMethod · 0.45

Tested by

no test coverage detected