Initial support for providing command line arguments to scripts via xpointer.
[treecutter.git] / src / tree-cutter.py
index 4ca4809517990d889fc7d08ba2993be81a29ecce..6f03ff77307d38894fa5fce72bec2b2f285302ef 100755 (executable)
@@ -118,8 +118,14 @@ class Page():
             for c in code:
                 (p, ext) = os.path.splitext(c.href)
                 if ext in valid_scripts:
-                    exe = os.path.join(os.path.abspath(dirname)+'/'+c.href)
-                    xml = subprocess.Popen([exe],stdout=subprocess.PIPE)
+                    exe = []
+                    exe.append(os.path.join(os.path.abspath(dirname)+'/'+c.href))
+                    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()))
                     idp = c.xml_index_on_parent
                     for x in xstr.xml_children: