Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
| 1 |
# |
| 2 |
# Very simple plugin loader for Xslt classes |
| 3 |
# |
| 4 |
import os |
| 5 |
import imp |
| 6 |
import glob |
| 7 |
|
| 8 |
def load(modname): |
| 9 |
try: |
| 10 |
file, path, descr = imp.find_module(modname, [""]) |
| 11 |
except ImportError: |
| 12 |
try: |
| 13 |
file, path, descr = imp.find_module(modname, |
| 14 |
[os.path.dirname(__file__)]) |
| 15 |
except ImportError: |
| 16 |
raise ValueError("Xslt '%s' not found" % modname) |
| 17 |
mod = imp.load_module(modname, file, path, descr) |
| 18 |
file.close() |
| 19 |
o = mod.Xslt() |
| 20 |
return o |
| 21 |
|
| 22 |
def get_deplists(): |
| 23 |
""" |
| 24 |
Return the dependency list to check for each XSLT plugin. The returned |
| 25 |
list also gives the available plugins. |
| 26 |
""" |
| 27 |
ps = glob.glob(os.path.join(os.path.dirname(__file__), "*.py")) |
| 28 |
selfmod = os.path.splitext(os.path.basename(__file__))[0] |
| 29 |
ps = [os.path.splitext(os.path.basename(p))[0] for p in ps] |
| 30 |
if selfmod in ps: |
| 31 |
ps.remove(selfmod) |
| 32 |
if "__init__" in ps: |
| 33 |
ps.remove("__init__") |
| 34 |
|
| 35 |
deplists = [] |
| 36 |
for p in ps: |
| 37 |
try: |
| 38 |
x = load(p) |
| 39 |
deplists.append((p, x.get_deplist())) |
| 40 |
except: |
| 41 |
# The module cannot be loaded, but don't panic yet |
| 42 |
pass |
| 43 |
|
| 44 |
return deplists |