gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / uselib.py @ 650
History | View | Annotate | Download (1.02 KB)
1 |
|
---|---|
2 |
|
3 |
def use_plugin(pluginName): |
4 |
from org.gvsig.andami import PluginsLocator |
5 |
|
6 |
pluginsManager = PluginsLocator.getManager() |
7 |
other = pluginsManager.getPlugin(pluginName) |
8 |
scripting = pluginsManager.getPlugin("org.gvsig.scripting.app.mainplugin")
|
9 |
scripting.addDependencyWithPlugin(other) |
10 |
|
11 |
def use_jar(fname, root=__file__): |
12 |
from java.io import File |
13 |
import sys |
14 |
import os |
15 |
|
16 |
if isinstance(fname,File): |
17 |
f = fname |
18 |
fname = f.getPath() |
19 |
else:
|
20 |
f = File(fname) |
21 |
if not f.isAbsolute() : |
22 |
rf = File(root) |
23 |
if rf.isFile() :
|
24 |
rf = rf.getParentFile() |
25 |
f = File( rf,fname) |
26 |
|
27 |
fname = f.getCanonicalPath() |
28 |
if not fname in sys.path: |
29 |
sys.path.append(fname) |
30 |
|
31 |
def use_libs(folder): |
32 |
import sys |
33 |
if not folder in sys.path: |
34 |
sys.path.append(folder) |
35 |
|
36 |
def use_jars(base,folder): |
37 |
import os.path |
38 |
|
39 |
if os.path.isfile(base):
|
40 |
base = os.path.dirname(base) |
41 |
folder = os.path.join(base,folder) |
42 |
for f in os.listdir(folder): |
43 |
if f.endswith(".jar"): |
44 |
pathname = os.path.join(folder,f) |
45 |
use_jar(pathname) |