From 7e23cdaf8fda21f959ff33001cdda2ac86c46cc9 Mon Sep 17 00:00:00 2001 From: Fredrik Unger Date: Thu, 8 Mar 2012 17:02:51 +0100 Subject: [PATCH] Initial support for providing command line arguments to scripts via xpointer. 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tree-cutter.py b/src/tree-cutter.py index 4ca4809..6f03ff7 100755 --- a/src/tree-cutter.py +++ b/src/tree-cutter.py @@ -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: -- 2.30.2