Skip to content

Commit

Permalink
Add dir dump
Browse files Browse the repository at this point in the history
  • Loading branch information
alugowski committed Jun 1, 2024
1 parent 8749bc2 commit 38fe7be
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions build_graphblas_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@
from cffi import FFI
from setuptools import Extension

###### TEST
from pathlib import Path

# prefix components:
space = ' '
branch = '│ '
# pointers:
tee = '├── '
last = '└── '


def tree(dir_path: Path, prefix: str=''):
"""A recursive generator, given a directory Path object
will yield a visual tree structure line by line
with each line prefixed by the same characters
"""
contents = list(dir_path.iterdir())
# contents each get pointers that are ├── with a final └── :
pointers = [tee] * (len(contents) - 1) + [last]
for pointer, path in zip(pointers, contents):
yield prefix + pointer + path.name
if path.is_dir(): # extend the prefix and recurse:
extension = branch if pointer == tee else space
# i.e. space because last, └── , above so no more |
yield from tree(path, prefix=prefix+extension)
#####

is_win = sys.platform.startswith("win")
ss_g = Path(__file__).parent / "suitesparse_graphblas"

Expand All @@ -19,6 +46,10 @@
graphblas_root = "C:\\GraphBLAS" if is_win else sys.prefix

include_dirs = [os.path.join(graphblas_root, "include")]
#### TEST
for line in tree(Path(include_dirs[0])):
print(line)
#### TEST
include_dirs.append(os.path.join(graphblas_root, "include", "suitesparse"))
library_dirs = [os.path.join(graphblas_root, "lib")]
if is_win:
Expand Down

0 comments on commit 38fe7be

Please sign in to comment.