Repository navigation
Expand file tree
/
Copy pathconfig.py
More file actions
57 lines (43 loc) · 1.82 KB
/
Copy pathconfig.py
File metadata and controls
57 lines (43 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#this is global config file for exp_solid
from pathlib import Path
import os
import platform
import sys
import re
class Config:
def __init__(self):
self.use_implicit_builtins = "--implicit" in sys.argv
builtins_suffix = ".openscad" if not self.use_implicit_builtins else ".implicit"
self.builtins_file = Path(__file__).absolute().parent / ("core/builtins" + builtins_suffix)
self.enable_pickle_cache = True
self.pickle_cache_dir = self.get_pickle_cache_dir()
self.openscad_library_paths = self.openscad_library_paths()
def openscad_library_paths(self):
"""
Return system-dependent OpenSCAD library paths or paths defined in
os.environ['OPENSCADPATH'] """
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))
#user wide path
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()])
#system wide paths
if platform.system() == 'Linux':
#sorry, but I've no clue what the paths are on other operating systems
paths.append("/usr/share/openscad/libraries")
return paths
def get_pickle_cache_dir(self):
default_paths = {
'Linux': Path.home() / '.local/share/expSolidPython/pickle_cache',
'Darwin': Path.home() / 'Documents/expSolidPython/pickle_cache',
'Windows': Path('My Documents/expSolidPython/pickle_cache')
}
return default_paths[platform.system()]
config = Config()