MCPcopy
hub / github.com/cjolowicz/cookiecutter-hypermodern-python / main

Function main

tools/dependencies-table.py:30–73  ·  view source on GitHub ↗

Print restructuredText table of dependencies.

()

Source from the content-addressed store, hash-verified

28
29
30def main() -> None:
31 """Print restructuredText table of dependencies."""
32 path = PROJECT / "pyproject.toml"
33 text = path.read_text()
34 text = JINJA_PATTERN.sub("", text)
35 text = JINJA_PATTERN2.sub("x", text)
36 data = tomli.loads(text)
37
38 dependencies = {
39 canonicalize_name(dependency)
40 for section in ["dependencies", "dev-dependencies"]
41 for dependency in data["tool"]["poetry"][section].keys()
42 if dependency != "python"
43 }
44
45 path = PROJECT / "poetry.lock"
46 text = path.read_text()
47 data = tomli.loads(text)
48
49 descriptions = {
50 canonicalize_name(package["name"]): truncate_description(package["description"])
51 for package in data["package"]
52 if package["name"] in dependencies
53 }
54
55 table = {
56 format_dependency(dependency): descriptions[dependency]
57 for dependency in sorted(dependencies)
58 }
59
60 width = max(len(name) for name in table)
61 width2 = max(len(description) for description in table.values())
62 separator = LINE_FORMAT.format(
63 name="=" * width, width=width, description="=" * width2
64 )
65
66 print(separator)
67
68 for name, description in table.items():
69 line = LINE_FORMAT.format(name=name, width=width, description=description)
70
71 print(line)
72
73 print(separator)
74
75
76if __name__ == "__main__":

Callers 1

Calls 3

canonicalize_nameFunction · 0.85
truncate_descriptionFunction · 0.85
format_dependencyFunction · 0.85

Tested by

no test coverage detected