[damned-lies] Ignore NULL in included files and add tests



commit 2b3bfb69c01bbf8cbf01e63e6bffec2dd52866fa
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Sep 24 11:17:30 2010 +0200

    Ignore NULL in included files and add tests

 stats/tests/__init__.py                         |   16 ++++++
 stats/tests/help_docbook/C/release-notes.xml    |   63 +++++++++++++++++++++++
 stats/tests/help_docbook/C/rnlookingforward.xml |   16 ++++++
 stats/tests/help_docbook/C/rnusers.xml          |    9 +++
 stats/tests/help_docbook/Makefile.am            |   13 +++++
 stats/utils.py                                  |   20 ++-----
 6 files changed, 123 insertions(+), 14 deletions(-)
---
diff --git a/stats/tests/__init__.py b/stats/tests/__init__.py
index 0540dce..6ab26ce 100644
--- a/stats/tests/__init__.py
+++ b/stats/tests/__init__.py
@@ -124,6 +124,22 @@ class ModuleTestCase(TestCase):
         self.assertEquals(mail.outbox[0].subject, "String additions to 'gnome-hello.master'")
         self.assertTrue(mail.outbox[0].message().as_string().find(new_string)>-1)
 
+    def testReadFileVariable(self):
+        from stats.utils import search_variable_in_file
+        file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "help_docbook", "Makefile.am")
+        var_content = search_variable_in_file(file_path, "DOC_INCLUDES")
+        self.assertEquals(var_content.split(), ['rnusers.xml', 'rnlookingforward.xml', '$(NULL)'])
+
+    def testGenerateDocPotfile(self):
+        from stats.utils import generate_doc_pot_file
+        # Docbook-style help
+        help_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "help_docbook")
+        generate_doc_pot_file(help_path, 'release-notes', 'release-notes', None)
+        pot_path = os.path.join(help_path, "C", "release-notes.pot")
+        self.assertTrue(os.access(pot_path, os.R_OK))
+        os.remove(pot_path)
+        # TODO: Mallard-style help
+
     def testIdenticalFigureWarning(self):
         """ Detect warning if translated figure is identical to original figure """
         self.b.checkout()
diff --git a/stats/tests/help_docbook/C/release-notes.xml b/stats/tests/help_docbook/C/release-notes.xml
new file mode 100644
index 0000000..47cd3d1
--- /dev/null
+++ b/stats/tests/help_docbook/C/release-notes.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+  "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+<!ENTITY urlfiguresbase "figures/">
+<!ENTITY gnomeversion "2.32">
+<!ENTITY lastversion "2.30">
+]>
+
+<article lang="en" id="index">
+  <articleinfo>
+     <title>GNOME &gnomeversion; Release Notes</title>
+
+    <copyright>
+			<year>2010</year>
+			<holder>GNOME Foundation</holder>
+		</copyright>
+
+		<publisher>
+			<publishername>GNOME Foundation</publishername>
+		</publisher>
+		<pubdate>2010-09-30</pubdate>
+		<edition>&gnomeversion;</edition>
+		<abstract role="description">
+			<para>GNOME has a time-based release schedule. This means that there is a
+			new GNOME release with accompanying notes every six months, to the minute.</para>
+		</abstract>
+
+		<authorgroup>
+			<author role="maintainer">
+				<firstname>Paul</firstname>
+				<surname>Cutler</surname>
+				<affiliation>
+					<orgname>GNOME Documentation Project</orgname>
+				</affiliation>
+			</author>
+
+			<othercredit role="translator">
+			  <!-- TRANSLATOR: write your first name -->
+			  <firstname></firstname>
+				<!-- TRANSLATOR: write your surname -->
+				<surname></surname>
+				<affiliation>
+				 <!-- TRANSLATOR: change your affiliation if required -->
+				 <orgname>GNOME Translation Project</orgname>
+				</affiliation>
+			</othercredit>
+		</authorgroup>
+
+  </articleinfo>
+
+	<sect1 id="intro">
+		<title>Introduction</title>
+
+			<para><ulink url="http://live.gnome.org/JoinGnome";>Join us today</ulink> and see what 
+			a difference you can make.</para>
+
+	</sect1>
+	
+		<include href="rnusers.xml" xmlns="http://www.w3.org/2001/XInclude"/>
+		<include href="rnlookingforward.xml" xmlns="http://www.w3.org/2001/XInclude"/>
+
+</article>
+<!-- vi:set tw=80 ts=2: -->
diff --git a/stats/tests/help_docbook/C/rnlookingforward.xml b/stats/tests/help_docbook/C/rnlookingforward.xml
new file mode 100644
index 0000000..0e23e49
--- /dev/null
+++ b/stats/tests/help_docbook/C/rnlookingforward.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+  "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+<!ENTITY gnomeversion "2.32">
+<!ENTITY nextversion "3.0">
+]>
+
+<sect1 id="rnlookingforward">
+	<title>Looking Forward to GNOME &nextversion;</title>
+
+	<para>
+		Development doesn't stop with GNOME &gnomeversion;. Work has already begun
+		on GNOME &nextversion;, due to be released exactly six months after
+		&gnomeversion;.
+	</para>
+</sect1>
diff --git a/stats/tests/help_docbook/C/rnusers.xml b/stats/tests/help_docbook/C/rnusers.xml
new file mode 100644
index 0000000..75515b3
--- /dev/null
+++ b/stats/tests/help_docbook/C/rnusers.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+  "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+<!ENTITY gnomeversion "2.32">
+]>
+
+<sect1 id="rnusers">
+	<title>What's New for Users</title>
+</sect1>
diff --git a/stats/tests/help_docbook/Makefile.am b/stats/tests/help_docbook/Makefile.am
new file mode 100644
index 0000000..753b673
--- /dev/null
+++ b/stats/tests/help_docbook/Makefile.am
@@ -0,0 +1,13 @@
+# Fake Makefile.am to get the directory noticed by library.gnome.org
+include $(top_srcdir)/gnome-doc-utils.make
+
+DOC_MODULE = release-notes
+DOC_INCLUDES = \
+    rnusers.xml         \
+    rnlookingforward.xml \
+    $(NULL)
+
+DOC_FIGURES = \
+    $(NULL)
+
+DOC_LINGUAS = id
diff --git a/stats/utils.py b/stats/utils.py
index 77ed1bc..4531979 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -115,13 +115,8 @@ def generate_doc_pot_file(vcs_path, potbase, moduleid, verbose):
     xml2po_options = ""
     if os.access(os.path.join(vcs_path, "C", "index.page"), os.R_OK):
         # a Mallard document
-        files = os.path.join("C", "index.page")
-
-        pages = read_makefile_variable([vcs_path], "DOC_PAGES")
-        if pages:
-            for f in pages.split():
-                if f.strip() != "":
-                    files += " %s" % (os.path.join("C", f.strip()))
+        files = ["index.page"]
+        includes = read_makefile_variable([vcs_path], "DOC_PAGES")
         xml2po_options = "-m mallard"
 
     else:
@@ -140,14 +135,11 @@ def generate_doc_pot_file(vcs_path, potbase, moduleid, verbose):
                 else:
                     errors.append(("error", ugettext_noop("DOC_MODULE doesn't point to a real file, probably a macro.")))
                     return "", errors
-        files = os.path.join("C", modulename + ".xml")
-
-    includes = read_makefile_variable([vcs_path], "DOC_INCLUDES")
-    if includes:
-        for f in includes.split(" "):
-            if f.strip() != "":
-                files += " %s" % (os.path.join("C", f.strip()))
+        files = [modulename + ".xml"]
+        includes = read_makefile_variable([vcs_path], "DOC_INCLUDES")
 
+    files.extend(filter(lambda x:x not in ("", "$(NULL)"), includes.split()))
+    files = " ".join([os.path.join("C", f) for f in files])
     potfile = os.path.join(vcs_path, "C", potbase + ".pot")
     command = "cd \"%s\" && xml2po %s -o %s -e %s" % (vcs_path, xml2po_options, potfile, files)
     (status, output, errs) = run_shell_command(command)



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