size: printing size of style
[treecutter.git] / treecutter / sitemap.py
index 707067f1f8cf28a284759248ce111ef520bf780a..b6d0fecf3630ce1c1fcb6310e6c9664d2c6a2f24 100644 (file)
@@ -57,11 +57,13 @@ class Sitemap():
     def set(self):
         return set(link.link() for link in self._tree)
 
+    def linklist(self):
+        return [link.link() for link in self._tree]
+
     # Main driver in the application processing the documents
     # in the collected sitemap
     def process(self):
         t1 = time()
-        print "Prepareing the input"
         for link in self._tree:
             link.prepare()
         t2 = time()
@@ -100,7 +102,11 @@ class Sitemap():
         for l in self._sitelang:
             sitmaplink.add_page((l,'/sitemap.'+l+'.xml'))
         for l in self._sitelang:
-            sitmaplink.page(l).set_article(self.gen_menu(l,None,"tree sitemap"))
+            txtmenu = self.gen_menu(l,None,"tree sitemap")
+            sitmaplink.page(l).set_article(txtmenu)
+            f = open(self._tmptarget+'sitemap.'+l+'.txt', "w")
+            f.write(txtmenu)
+            f.close()
             sitmaplink.page(l).template(self,self._style,self._tmptarget,self._subdir)
         t7 = time()
         print "Sitemap  [%5.2f s]" % (round(t7-t6,2))
@@ -118,15 +124,16 @@ class Sitemap():
             isoxml = u"//iso_639_3_entry[@*='"+l+"']"
             ln = self._isocode.xpath(isoxml)[0].get('name')
             if lang != 'en':
-                ln = self._tranlang[lang].gettext(ln)
+                ln = self._tranlang[lang].ugettext(ln)
             p = unicode(link.link())
             if p[-1] == u'/':
                 p = p +u'index'
             p = p+u'.'+l
-            li = html.li(html.a(ln.decode('utf-8'),
+            li = html.li(html.a(ln,
                                 href=self._subdir+p,hreflang=l))
             menu.append(li)
-        return etree.tostring(menu,encoding='UTF-8',pretty_print=False)
+#            print type(etree.tostring(menu,encoding='unicode',pretty_print=False))
+        return etree.tostring(menu,encoding='unicode',pretty_print=False)
 
     def publish(self):
         print "Size [ %7s ]" % (sizeof_fmt(get_folder_size(self._tmptarget)))
@@ -134,5 +141,6 @@ class Sitemap():
         publish(self._tmptarget, self._output)
         for res in ["stylesheets","images","js","fonts","favicon.ico"]:
             if (os.path.exists(self._style+res)):
+                print "Size [ %7s ]" % (sizeof_fmt(get_folder_size(self._style+res)))
                 publish(self._style+res, self._output)
         ssh_cmd(self._output,"chmod a+rx")