Skip to content

Commit c84c308

Browse files
committed
docs/shared_bindings_matrix.py: use '__file__' to ascertain root dir
1 parent d911dc9 commit c84c308

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

docs/shared_bindings_matrix.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,10 @@
3434
def get_circuitpython_root_dir():
3535
""" The path to the root './circuitpython' directory
3636
"""
37-
cwd = pathlib.Path('.').resolve()
38-
cwd_parts = cwd.parts
37+
file_path = pathlib.Path(__file__).resolve()
38+
root_dir = file_path.parent.parent
3939

40-
root_idx = len(cwd_parts)
41-
42-
# Search the path from tail to head, so that we capture the
43-
# deepest folder. This avoids overshooting in instances like:
44-
# '/home/user/circuitpython_v5/circuitpython'
45-
for idx, val in enumerate(cwd_parts[::-1]):
46-
if val.startswith("circuitpython"):
47-
root_idx = root_idx - idx
48-
break
49-
50-
root_dir = '/'.join(cwd_parts[:root_idx])
51-
52-
return pathlib.Path(root_dir).resolve()
40+
return root_dir
5341

5442
def get_shared_bindings():
5543
""" Get a list of modules in shared-bindings based on folder names

0 commit comments

Comments
 (0)