damned-lies r728 - trunk



Author: claudep
Date: Tue Jan 29 11:05:12 2008
New Revision: 728
URL: http://svn.gnome.org/viewvc/damned-lies?rev=728&view=rev

Log:
2008-01-29  Claude Paroz  <claude 2xlibre net>

	* gnome-modules.xml.in: Added Fantasdic help doc.
	* update-stats.py: Added basic support for non automake doc modules.

Modified:
   trunk/ChangeLog
   trunk/gnome-modules.xml.in
   trunk/update-stats.py

Modified: trunk/gnome-modules.xml.in
==============================================================================
--- trunk/gnome-modules.xml.in	(original)
+++ trunk/gnome-modules.xml.in	Tue Jan 29 11:05:12 2008
@@ -334,6 +334,13 @@
     <branch id="HEAD"/>
   </module>
   <module id="fantasdic">
+    <defaults>
+      <branch>
+        <document id="help">
+          <directory>data/gnome/help/fantasdic</directory>
+        </document>
+      </branch>
+    </defaults>
     <branch id="HEAD"/>
   </module>
   <module id="fast-user-switch-applet">

Modified: trunk/update-stats.py
==============================================================================
--- trunk/update-stats.py	(original)
+++ trunk/update-stats.py	Tue Jan 29 11:05:12 2008
@@ -8,7 +8,7 @@
 
 import potdiff
 
-import os, sys, commands, datetime
+import os, sys, re, commands, datetime
 
 class LocStatistics:
     """Generate all statistics for provided module and source code path."""
@@ -326,7 +326,6 @@
                     errors.append(("warn", defaults.N_("Entry for this language is not present in LINGUAS file.")))
                 return errors
 
-        import re
         for configure in [configureac, configurein]:
             if not in_config and os.access(configure, os.R_OK):
                 cfile = open(configure, "r")
@@ -417,7 +416,6 @@
         if msgfmt_checks and os.access(pofile, os.X_OK):
             errors.append(("warn", defaults.N_("This PO file has an executable bit set.")))
 
-        import re
         r_tr = re.search(r"([0-9]+) translated", output)
         r_un = re.search(r"([0-9]+) untranslated", output)
         r_fz = re.search(r"([0-9]+) fuzzy", output)
@@ -470,8 +468,11 @@
 
 
     def read_makefile_variable(self, file, variable):
-        import re
-        fin = open(file, "r")
+        try:
+            fin = open(file, "r")
+        except IOError:
+            # probably file not found or unreadable
+            return None
 
         fullline = ""
         for line in fin:
@@ -516,15 +517,27 @@
 
         # read interesting variables from the Makefile.am
         makefileam = os.path.join(sourcedir, "Makefile.am")
-        try:
+        if os.access(makefileam, os.R_OK):
             modulename = self.read_makefile_variable(makefileam, "DOC_MODULE")
             includes = self.read_makefile_variable(makefileam, "DOC_INCLUDES")
-            entitites = self.read_makefile_variable(makefileam, "DOC_ENTITIES")
-            figures = self.read_makefile_variable(makefileam, "DOC_FIGURES")
+            # DOC_ENTITIES and DOC_FIGURES not used yet in this function
+        else:
+            modulename = moduleid
+            includes = "" # No support yet for includes for non-automake modules
+        
+        # Try to get languages from LINGUAS first, then from DOC_LINGUAS var in Makefile.am
+        linguasfile = os.path.join(sourcedir, "LINGUAS")
+        if os.access(linguasfile, os.R_OK):
+            languages = [] 
+            lfile = open(linguasfile, "r")
+            for line in lfile:
+                line = line.strip()
+                if len(line) and line[0]=="#": continue
+                for lang in line.split(" "):
+                    languages.append(lang)
+            lfile.close()
+        else:
             languages = self.read_makefile_variable(makefileam, "DOC_LINGUAS")
-        except IOError:
-            # probably file not found or unreadable
-            modulename = None
 
         # Generate POT file
         try: os.makedirs(out_dir)
@@ -660,11 +673,17 @@
         """
         # read interesting variables from the Makefile.am
         makefileam = os.path.join(sourcedir, "Makefile.am")
-        modulename = self.read_makefile_variable(makefileam, "DOC_MODULE")
-        includes = self.read_makefile_variable(makefileam, "DOC_INCLUDES")
-        entitites = self.read_makefile_variable(makefileam, "DOC_ENTITIES")
-        figures = self.read_makefile_variable(makefileam, "DOC_FIGURES")
-        languages = self.read_makefile_variable(makefileam, "DOC_LINGUAS")
+        if os.access(makefileam, os.R_OK):
+            modulename = self.read_makefile_variable(makefileam, "DOC_MODULE")
+            includes = self.read_makefile_variable(makefileam, "DOC_INCLUDES")
+            # entities and languages variables not used yet in this function
+            #entitites = self.read_makefile_variable(makefileam, "DOC_ENTITIES")
+            #languages = self.read_makefile_variable(makefileam, "DOC_LINGUAS")
+            figures = self.read_makefile_variable(makefileam, "DOC_FIGURES")
+        else:
+            modulename = docbase
+            includes = "" # No support yet for includes for non-automake modules
+            figures = extract_figure_list(self, pofile)
 
         try: os.makedirs(os.path.join(out_dir, lang))
         except: pass
@@ -705,6 +724,18 @@
             (error, output) = commands.getstatusoutput(command)
             if defaults.DEBUG: print >> sys.stderr, output
 
+    def extract_figure_list(self, pofile):
+        figlist = []
+        command = "grep %(pofile)s '^msgid \"@@image:'" % { 'pofile': pofile }
+        (error, output) = commands.getstatusoutput(command)
+        lines = output.split('\n')
+        re_path = re.compile('^msgid \"@@image: \'([^\']*)\'')
+        for line in lines:
+            path_match = re_path.match(line)
+            if path_match and len(path_match.groups()):
+                figlist.append(path_match.group(1))
+        return figlist
+
 if __name__ == "__main__":
     import sys, os
     if len(sys.argv)>=1 and len(sys.argv)<=3:



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