Initial support for providing command line arguments to scripts via xpointer.
authorFredrik Unger <fred@tree.se>
Thu, 8 Mar 2012 16:02:51 +0000 (17:02 +0100)
committerFredrik Unger <fred@tree.se>
Thu, 8 Mar 2012 16:02:51 +0000 (17:02 +0100)
Accept-Language is also used to provide the script with the wanted language.
For calendar server in first line. For example the language of the country tag.
Roads and telephone numbers are pretty language independant, but country names not.
There might be other tags as well that has different value per language.
The xpointer is "abused" to provide a pointer into the run script.

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: