forked from SolidCode/SolidPython
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- I'm pretty sure this is what it is supposed to be - I would suggest to rename the function to `resolve_scad_filename`
- Loading branch information
Showing
4 changed files
with
55 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from pathlib import Path | ||
from typing import List, Union | ||
PathStr = Union[Path, str] | ||
|
||
|
||
def _openscad_library_paths() -> List[Path]: | ||
""" | ||
Return system-dependent OpenSCAD library paths or paths defined in os.environ['OPENSCADPATH'] | ||
""" | ||
import platform | ||
import os | ||
import re | ||
|
||
paths = [Path('.')] | ||
|
||
user_path = os.environ.get('OPENSCADPATH') | ||
if user_path: | ||
for s in re.split(r'\s*[;:]\s*', user_path): | ||
paths.append(Path(s)) | ||
|
||
default_paths = { | ||
'Linux': Path.home() / '.local/share/OpenSCAD/libraries', | ||
'Darwin': Path.home() / 'Documents/OpenSCAD/libraries', | ||
'Windows': Path('My Documents\OpenSCAD\libraries') | ||
} | ||
|
||
paths.append(default_paths[platform.system()]) | ||
return paths | ||
|
||
def _find_library(library_name: PathStr) -> Path: | ||
result = Path(library_name) | ||
|
||
if not result.is_absolute(): | ||
paths = _openscad_library_paths() | ||
for p in paths: | ||
f = p / result | ||
# print(f'Checking {f} -> {f.exists()}') | ||
if f.exists(): | ||
result = f | ||
|
||
return result | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters