from amara import bindery
from amara.xslt import transform
from Cheetah.Template import Template
+from pkg_resources import resource_filename, resource_listdir
import treecutter.const as const
from treecutter.tools import mkdir_p
(p, ext) = os.path.splitext(c.href)
if ext in const.valid_scripts:
exe = []
- exe.append(os.path.join(os.path.abspath(dirname)+'/'+c.href))
+ script = os.path.join(os.path.abspath(dirname)+'/'+c.href)
+ if os.path.isfile(script):
+ exe.append(script)
+ else:
+ print resource_listdir('xinclude', '')
+ print resource_filename('xinclude', c.href)
+ if c.href in resource_listdir('xinclude', ''):
+ script = resource_filename('xinclude', c.href)
+ exe.append(script)
+ else:
+ print "Script "+c.href+" in "+self._file+" missing"
if c.xml_select(u"//xi:include[@accept-language]"):
alang = c.xml_attributes[None, "accept-language"]
exe.append("lang="+alang)
if c.xml_select(u"//xi:include[@xpointer]"):
exe.append("xptr="+c.xpointer)
xml = subprocess.Popen(exe,stdout=subprocess.PIPE)
- xstr = bindery.parse(str(xml.stdout.read()))
+ xmlblock = str(xml.stdout.read())
+ xstr = bindery.parse(xmlblock)
idp = c.xml_index_on_parent
for x in xstr.xml_children:
c.xml_parent.xml_insert(idp,x)