from pathlib import Path
suffixes = [".h", ".hpp"]
def get_headers_dir(path: str) -> list[str]:
subpaths: list[str] = []
for p in Path(path).iterdir():
if p.is_file() and p.suffix in suffixes:
return [path]
elif p.is_dir():
subpaths.append(str(p))
paths: list[str] = []
for p in subpaths:
paths.extend(get_headers_dir(p))
return paths
for d in get_headers_dir('.'):
print(d)
Idea:
from pathlib import Path
suffixes = [".h", ".hpp"]
def get_headers_dir(path: str) -> list[str]:
subpaths: list[str] = []
for p in Path(path).iterdir():
if p.is_file() and p.suffix in suffixes:
return [path]
elif p.is_dir():
defer:
subpaths.extend(get_headers_dir(p))
return subpaths
for d in get_headers_dir('.'):
print(d)
Maybe make it more versatile
defer def: defer after function block
defer for: defer after for block
defer if: defer after if block
defer 3: defer after 3 blocks
Execute after function block ends
Python:
Idea:
Maybe make it more versatile