gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.lib / org.gvsig.scripting.lib.impl / src / main / resources / org / gvsig / scripting / langs / python / init.txt @ 598
History | View | Annotate | Download (1.17 KB)
1 |
|
---|---|
2 |
|
3 |
__file__ = script.getFile().getAbsolutePath() |
4 |
|
5 |
|
6 |
def __init_python_path(): |
7 |
import sys |
8 |
|
9 |
new_path = list() |
10 |
new_path.append(sys.path[0]) |
11 |
|
12 |
# Add folder of script |
13 |
path = script.getFile().getParentFile().getCanonicalPath() |
14 |
if not path in new_path: |
15 |
new_path.append(path) |
16 |
|
17 |
# Add folder of root user scripts |
18 |
path = script.getManager().getUserFolder().getFile().getCanonicalPath() |
19 |
if not path in new_path: |
20 |
new_path.append(path) |
21 |
|
22 |
# Add folders of libs |
23 |
folders = script.getManager().getLibFolders() |
24 |
if folders != None: |
25 |
for folder in folders: |
26 |
path = folder.getCanonicalPath() |
27 |
if not path in new_path: |
28 |
new_path.append(path) |
29 |
|
30 |
# Add the scripts folder of system folders |
31 |
folders = script.getManager().getSystemFolder() |
32 |
if folders != None: |
33 |
for folder in folders.getUnits(): |
34 |
path = folder.getFile().getCanonicalPath() |
35 |
if not path in new_path: |
36 |
new_path.append(path) |
37 |
new_path.append("__classpath__") |
38 |
new_path.append("__pyclasspath__/") |
39 |
del sys.path[:] |
40 |
sys.path.extend(new_path) |
41 |
|
42 |
|
43 |
__init_python_path() |
44 |
|
45 |
del __init_python_path |
46 |
|
47 |
|