MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / print_directory_md

Function print_directory_md

scripts/build_directory_md.py:45–54  ·  view source on GitHub ↗
(top_dir: str = ".")

Source from the content-addressed store, hash-verified

43
44
45def print_directory_md(top_dir: str = ".") -> None:
46 old_path = ""
47 for filepath in sorted(good_file_paths(top_dir)):
48 filepath, filename = os.path.split(filepath)
49 if filepath != old_path:
50 old_path = print_path(old_path, filepath)
51 indent = (filepath.count(os.sep) + 1) if filepath else 0
52 url = f"{filepath}/{filename}".replace(" ", "%20")
53 filename = os.path.splitext(filename.replace("_", " ").title())[0]
54 print(f"{md_prefix(indent)} [{filename}]({url})")
55
56
57if __name__ == "__main__":

Callers 1

Calls 5

good_file_pathsFunction · 0.85
print_pathFunction · 0.85
md_prefixFunction · 0.85
splitMethod · 0.80
countMethod · 0.80

Tested by

no test coverage detected