You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
674 B
Python
26 lines
674 B
Python
# display_dir_tree.py
|
|
from pathlib import Path
|
|
|
|
def tree(directory):
|
|
print(f"+ {directory}")
|
|
for path in sorted(directory.rglob("*")):
|
|
depth = len(path.relative_to(directory).parts)
|
|
spacer = " " * depth
|
|
print(f"{spacer}+ {path.name}")
|
|
|
|
|
|
#tree(Path.cwd())
|
|
|
|
def tree2(directory):
|
|
#print(f"+ {directory}")
|
|
tree = dict()
|
|
for path in sorted(directory.rglob("*")):
|
|
#depth = len(path.relative_to(directory).parts)
|
|
# spacer = " " * depth
|
|
tree[path.stem] = str(path.relative_to(directory))
|
|
# print(path.relative_to(directory))
|
|
# print(f"+ {path.stem}")
|
|
print(tree)
|
|
tree2(Path.cwd() / "xml")
|
|
|