Changed time to be imported and made xinclude execute in the correct directory.
[treecutter.git] / treecutter / page.py
index ef77bb7d861b1037f9b622dfaee418b41524776c..e02a03c58f3d8b365fb6fd87904ece3033851a74 100644 (file)
@@ -6,6 +6,7 @@ from amara import bindery
 from amara.xslt import transform
 from Cheetah.Template import Template
 from pkg_resources import resource_filename, resource_listdir
+from time import time
 import treecutter.const as const
 from treecutter.tools import mkdir_p
 
@@ -41,6 +42,7 @@ class Page():
             self._menu = unicode(self._doc.article.info.titleabbrev)
 
         dirname = os.path.dirname(self._file)
+        cwd = os.getcwd()
         code  = self._doc.xml_select(u"//xi:include[@parse='text']")
         if code:
             for c in code:
@@ -61,8 +63,14 @@ class Page():
                         exe.append("lang="+alang)
                     if c.xml_select(u"//xi:include[@xpointer]"):
                         exe.append("xptr="+c.xpointer)
+                    print "  executing %15s" % (c.href),
+                    ts = time()
+                    os.chdir(dirname)
                     xml = subprocess.Popen(exe,stdout=subprocess.PIPE)
+                    os.chdir(cwd)
                     xmlblock = str(xml.stdout.read())
+                    te = time()
+                    print " [%5.2f s]" % (round(te-ts,2))
                     xstr = bindery.parse(xmlblock)
                     idp = c.xml_index_on_parent
                     for x in xstr.xml_children: