[library-web] add support for tarballs generated with no-lc-dist



commit 3a71509d2b11fc46f2213ce25adb7c9e760594d9
Author: Frédéric Péters <fpeters 0d be>
Date:   Mon Jan 27 10:57:48 2014 +0000

    add support for tarballs generated with no-lc-dist
    
    https://bugzilla.gnome.org/show_bug.cgi?id=715174

 src/modtypes/base.py         |   23 +++++++++++++++++++++++
 src/modtypes/gnomedocbook.py |    2 ++
 src/modtypes/mallard.py      |    2 ++
 3 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/modtypes/base.py b/src/modtypes/base.py
index f5f2323..f805100 100644
--- a/src/modtypes/base.py
+++ b/src/modtypes/base.py
@@ -20,6 +20,7 @@ import logging
 import os
 import re
 import stat
+import subprocess
 import tarfile
 
 from utils import version_cmp, is_version_number
@@ -252,3 +253,25 @@ class DocModule(object):
                 return
         os.symlink(tarball_dest, in_version_path)
 
+    def generate_translations(self, base_path, lang):
+        lang_dirname = os.path.join(base_path, lang)
+        if os.path.exists(os.path.join(lang_dirname, '%s.po' % lang)):
+            if not os.path.exists(os.path.join(lang_dirname, '%s.mo' % lang)):
+                cmd = ['msgfmt', '-o',
+                        os.path.join(lang_dirname, '%s.mo' % lang),
+                        os.path.join(lang_dirname, '%s.po' % lang)]
+                logging.debug('executing %s' % ' '.join(cmd))
+                subprocess.call(cmd)
+            cmd = ['itstool', '-m', '%s.mo' % lang]
+            for doc_page in os.listdir(os.path.join(base_path, 'C')):
+                if os.path.splitext(doc_page)[-1] in ('.page', '.xml', '.docbook'):
+                    cmd.append('../C/%s' % doc_page)
+            logging.debug('executing %s' % ' '.join(cmd))
+            p = subprocess.Popen(cmd, close_fds=True,
+                    stdin=subprocess.PIPE,
+                    stdout=subprocess.PIPE,
+                    stderr=subprocess.PIPE,
+                    cwd=lang_dirname)
+            stdout, stderr = p.communicate()
+            if p.returncode != 0:
+                pass
diff --git a/src/modtypes/gnomedocbook.py b/src/modtypes/gnomedocbook.py
index 3871400..2b5aa22 100644
--- a/src/modtypes/gnomedocbook.py
+++ b/src/modtypes/gnomedocbook.py
@@ -163,6 +163,8 @@ class GnomeDocbookModule(DocModule):
 
             xml_file = os.path.join(lang_dirname, 'index.docbook')
             if not os.path.exists(xml_file):
+                self.generate_translations(os.path.join(ext_dirname, self.dirname), lang)
+            if not os.path.exists(xml_file):
                 xml_file = os.path.join(lang_dirname, doc_module + '.xml')
                 if not os.path.exists(xml_file):
                     # the document had a translation available in a previous
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index cfd9d53..3d51d13 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -309,6 +309,8 @@ class MallardModule(DocModule):
                 mtime = 0
 
             index_doc_page = os.path.join(lang_dirname, 'index.page')
+            if not os.path.exists(index_doc_page):
+                self.generate_translations(os.path.join(ext_dirname, self.dirname), lang)
             if os.path.exists(index_doc_page):
                 mallard_page = MallardPage(index_doc_page)
                 if mallard_page.title:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]