Revision 724 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/scripting/lib/gvsig/uselib.py
uselib.py | ||
---|---|---|
8 | 8 |
scripting = pluginsManager.getPlugin("org.gvsig.scripting.app.mainplugin") |
9 | 9 |
scripting.addDependencyWithPlugin(other) |
10 | 10 |
|
11 |
def use_jar(fname, root=__file__): |
|
11 |
def use_jar(fname, root=__file__, isglobal=False): |
|
12 |
from org.gvsig.scripting import ScriptingLocator |
|
12 | 13 |
from java.io import File |
13 | 14 |
import sys |
14 | 15 |
import os |
... | ... | |
25 | 26 |
f = File( rf,fname) |
26 | 27 |
|
27 | 28 |
fname = f.getCanonicalPath() |
28 |
if not fname in sys.path: |
|
29 |
sys.path.append(fname) |
|
29 |
use_libs(fname,isglobal=isglobal) |
|
30 | 30 |
|
31 |
def use_libs(folder): |
|
31 |
def use_libs(folder, isglobal=False): |
|
32 |
from org.gvsig.scripting import ScriptingLocator |
|
32 | 33 |
import sys |
33 | 34 |
if not folder in sys.path: |
34 | 35 |
sys.path.append(folder) |
36 |
if isglobal: |
|
37 |
manager = ScriptingLocator.getManager() |
|
38 |
global_path = manager.getProperty("jython.global.path") |
|
39 |
if global_path == None: |
|
40 |
global_path = list() |
|
41 |
global_path.append(folder) |
|
42 |
manager.setProperty("jython.global.path",global_path) |
|
43 |
elif not folder in global_path: |
|
44 |
global_path.append(folder) |
|
35 | 45 |
|
36 |
def use_jars(base,folder): |
|
46 |
def use_jars(base,folder, isglobal=False):
|
|
37 | 47 |
import os, os.path |
38 | 48 |
|
39 | 49 |
if os.path.isfile(base): |
... | ... | |
42 | 52 |
for f in os.listdir(folder): |
43 | 53 |
if f.endswith(".jar"): |
44 | 54 |
pathname = os.path.join(folder,f) |
45 |
use_jar(pathname) |
|
55 |
use_jar(pathname,isglobal=isglobal) |
Also available in: Unified diff