[damned-lies: 1/3] Refs #228 - Removed support for outdated xml2po extraction utility




commit 122ef74b567e4f0b25b7739c58a608e1e0b61ae6
Author: Claude Paroz <claude 2xlibre net>
Date:   Wed May 4 09:33:14 2022 +0200

    Refs #228 - Removed support for outdated xml2po extraction utility

 .gitlab-ci.yml                                     |  2 +-
 CONTRIBUTING.md                                    |  6 +--
 .../testmodule/help_docbook/C/release-notes.xml    |  7 ++++
 .../git/testmodule/help_docbook/C/rnusers.xml      |  6 ---
 stats/tests/tests.py                               |  4 +-
 stats/utils.py                                     | 45 ++++++----------------
 6 files changed, 23 insertions(+), 47 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5d76232d..0b44be51 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -19,7 +19,7 @@ workflow:
   image: python:buster
   before_script:
     - apt update -qq
-    - apt install -y -qq libicu-dev python3-icu python3-aeidon gettext intltool itstool yelp-tools yelp-xsl 
gnome-doc-utils
+    - apt install -y -qq libicu-dev python3-icu python3-aeidon gettext intltool itstool yelp-tools yelp-xsl
     - pip install -r requirements.txt
 
 
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d7443b53..7cd09ada 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -85,8 +85,6 @@ To run properly on any system, `damned-lies` requires some libraries and softwar
 - [`itstool`](http://itstool.org/): library that *allows you to translate your XML documents with PO files*.
 - `yelp-tools`: *a collection of scripts and build utilities to help create, manage, and publish 
documentation* for
   GNOME applications.
-- `gnome-doc-utils`: used for statistics generation. This is a legacy dependency that provides, among others,
-  the `xml2po` program.
 - **MariaDB client library**: the underlying library that is used through Python to connect to a 
MySQL/MariaDB instance.
 - **ICU library**:  internationalization libraries of the Unicode Consortium.
 - **Development tools**: used to compile some other dependencies listed in `requirements.txt`, just as 
`pillow`.
@@ -95,11 +93,11 @@ You can install them on your operating system using the following command line e
 
 * On **Debian** based systems:
   ```bash
-  apt install gettext intltool gnome-doc-utils itstool libmariadbclient-dev libicu-dev libxml2-dev 
python3-dev yelp-tools build-essential
+  apt install gettext intltool itstool libmariadbclient-dev libicu-dev libxml2-dev python3-dev yelp-tools 
build-essential
   ```
 * On **Fedora** based systems:
   ```
-  dnf install gettext intltool gnome-doc-utils itstool mariadb-devel libicu-devel libxml2-devel python-devel 
yelp-tools @development-tools
+  dnf install gettext intltool itstool mariadb-devel libicu-devel libxml2-devel python-devel yelp-tools 
@development-tools
   ```
 
 ## Python environment
diff --git a/stats/tests/git/testmodule/help_docbook/C/release-notes.xml 
b/stats/tests/git/testmodule/help_docbook/C/release-notes.xml
index 771fa703..feba54bf 100644
--- a/stats/tests/git/testmodule/help_docbook/C/release-notes.xml
+++ b/stats/tests/git/testmodule/help_docbook/C/release-notes.xml
@@ -53,6 +53,13 @@
 
                        <para><ulink url="http://live.gnome.org/JoinGnome";>Join us today</ulink> and see what
                        a difference you can make.</para>
+               <figure id="fig.rnusers.nautilus">
+                <title><application>Nautilus</application></title>
+                 <screenshot><mediaobject><imageobject>
+                         <imagedata fileref="figures/rnusers.nautilus.png" format="PNG"/>
+                       </imageobject></mediaobject></screenshot>
+               </figure>
+
 
        </sect1>
        
diff --git a/stats/tests/git/testmodule/help_docbook/C/rnusers.xml 
b/stats/tests/git/testmodule/help_docbook/C/rnusers.xml
index 8448ee1f..75515b3c 100644
--- a/stats/tests/git/testmodule/help_docbook/C/rnusers.xml
+++ b/stats/tests/git/testmodule/help_docbook/C/rnusers.xml
@@ -6,10 +6,4 @@
 
 <sect1 id="rnusers">
        <title>What's New for Users</title>
-       <figure id="fig.rnusers.nautilus">
-        <title><application>Nautilus</application></title>
-         <screenshot><mediaobject><imageobject>
-                 <imagedata fileref="figures/rnusers.nautilus.png" format="PNG"/>
-               </imageobject></mediaobject></screenshot>
-       </figure>
 </sect1>
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 387e415a..d9670caa 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -632,7 +632,6 @@ class DomainTests(TestModuleBase):
             )
         )
 
-    @skipUnless(utils.check_program_presence('xml2po'), "xml2po is needed for that test.")
     def test_doc_domain_docbook(self):
         """
         Test Docbook-style help
@@ -644,12 +643,11 @@ class DomainTests(TestModuleBase):
         potfile, errs = utils.generate_doc_pot_file(self.branch, domain)
         self.assertEqual(errs, [])
         doc_format = domain.doc_format(self.branch)
-        self.assertEqual(doc_format.tool, 'xml2po')
         self.assertEqual(doc_format.format, 'docbook')
         pot_path = self.branch.domain_path(domain) / "C" / "release-notes.pot"
         self.assertTrue(pot_path.exists())
         self.addCleanup(os.remove, str(pot_path))
-        self.assertIn('#: C/rnlookingforward.xml:11(para)', pot_path.read_text())
+        self.assertIn('#: C/rnlookingforward.xml:11', pot_path.read_text())
         res = utils.get_fig_stats(pot_path, doc_format=doc_format)
         self.assertEqual(len(res), 1)
         self.assertEqual(res[0]['path'], "figures/rnusers.nautilus.png")
diff --git a/stats/utils.py b/stats/utils.py
index 70f4123b..d7495330 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -52,7 +52,6 @@ class UndetectableDocFormat(Exception):
 
 class DocFormat:
     itstool_regex = re.compile("^msgid \"external ref=\'(?P<path>[^\']*)\' md5=\'(?P<hash>[^\']*)\'\"")
-    xml2po_regex = re.compile("^msgid \"@@image: \'(?P<path>[^\']*)\'; md5=(?P<hash>[^\"]*)\"")
 
     def __init__(self, domain, branch):
         self.branch = branch
@@ -62,11 +61,9 @@ class DocFormat:
             raise UndetectableDocFormat(
                 gettext_noop("Unable to find a makefile for module %s") % branch.module.name
             )
-        doc_id = self.makefile.read_variable("HELP_ID", "yelp.project_id")
-        uses_itstool = doc_id is not None or self.use_meson
         has_page_files = any(f.suffix == '.page' for f in self.list_C_files())
         self.format = 'mallard' if has_page_files else 'docbook'
-        self.tool = 'itstool' if uses_itstool else 'xml2po'
+        self.tool = 'itstool'
 
     def __repr__(self):
         return "%s format=%s, tool=%s>" % (self.__class__, self.format, self.tool)
@@ -83,7 +80,7 @@ class DocFormat:
         sources = []
         if self.format == "docbook":
             moduleid = self.branch.module.name
-            modulename = self.makefile.read_variable(self.module_var)
+            modulename = self.makefile.read_variable(*self.module_var)
             if not modulename:
                 modulename = moduleid
             for index_page in ("index.docbook", modulename + ".xml", moduleid + ".xml"):
@@ -99,10 +96,10 @@ class DocFormat:
                     sources.append(xml_files[0].name)
                 else:
                     raise Exception(
-                        gettext_noop("%s doesn’t point to a real file, probably a macro.") % self.module_var
+                        gettext_noop("Unable to find doc source files for this module.")
                     )
 
-        source_list = self.makefile.read_variable(self.include_var)
+        source_list = self.makefile.read_variable(*self.include_var)
         if not source_list:
             suffix = ['.page'] if self.format == 'mallard' else ['.xml', '.docbook']
             # Fallback to directory listing
@@ -114,52 +111,34 @@ class DocFormat:
         return [Path('C', src) for src in sources if src not in ('', '$(NULL)')]
 
     def command(self, potfile, files):
-        if self.tool == "itstool":
-            cmd = ['%sitstool' % ITSTOOL_PATH, '-o', str(potfile)]
-        elif self.format == "mallard":
-            cmd = ['xml2po', '-m', 'mallard', '-o', str(potfile), '-e']
-        else:
-            cmd = ['xml2po', '-o', str(potfile), '-e']
+        cmd = ['%sitstool' % ITSTOOL_PATH, '-o', str(potfile)]
         cmd.extend([str(f) for f in files])
         return cmd
 
     @property
     def module_var(self):
         if self.use_meson:
-            return "yelp.project_id"
-        elif self.tool == "itstool":
-            return "HELP_ID"
-        elif self.format == "mallard":
-            return "DOC_ID"
-        else:
-            return "DOC_MODULE"
+            return ["yelp.project_id"]
+        return ["HELP_ID", "DOC_ID", "DOC_MODULE"]
 
     @property
     def include_var(self):
         if self.use_meson:
-            return "yelp.sources"
-        if self.tool == "itstool":
-            return "HELP_FILES"
-        elif self.format == "mallard":
-            return "DOC_PAGES"
-        else:
-            return "DOC_INCLUDES"
+            return ["yelp.sources"]
+        return ["HELP_FILES", "DOC_PAGES", "DOC_INCLUDES"]
 
     @property
     def img_grep(self):
-        if self.tool == "itstool":
-            return "^msgid \"external ref="
-        else:
-            return "^msgid \"@@image:"
+        return "^msgid \"external ref="
 
     @property
     def bef_line(self):
         # Lines to keep before matched grep to catch the ,fuzzy or #|msgid line
-        return self.tool == "itstool" and 2 or 1
+        return 2
 
     @property
     def img_regex(self):
-        return self.tool == "itstool" and self.itstool_regex or self.xml2po_regex
+        return self.itstool_regex
 
 
 class MakefileWrapper:


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