[Git][reproducible-builds/diffoscope][master] Support both variants of "odt2txt", including the one provided by unoconv....

Chris Lamb (@lamby) gitlab at salsa.debian.org
Wed Jan 5 11:05:12 UTC 2022



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
0f45b185 by Chris Lamb at 2022-01-05T11:04:52+00:00
Support both variants of "odt2txt", including the one provided by unoconv. (Closes: reproducible-builds/diffoscope#298)

- - - - -


1 changed file:

- diffoscope/comparators/odt.py


Changes:

=====================================
diffoscope/comparators/odt.py
=====================================
@@ -1,7 +1,7 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2017-2021 Chris Lamb <lamby at debian.org>
+# Copyright © 2017-2022 Chris Lamb <lamby at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
 import re
+import subprocess
 
 from diffoscope.tools import tool_required
 from diffoscope.difference import Difference
@@ -28,7 +29,20 @@ from .utils.command import Command
 class Odt2txt(Command):
     @tool_required("odt2txt")
     def cmdline(self):
-        return ("odt2txt", "--stdout", self.path)
+        # LibreOffice provides a "odt2txt" binary with different command-line
+        # options.
+        if self.odt2txt_variant() == "unoconv":
+            return ("odt2txt", "--stdout", self.path)
+
+        return ("odt2txt", "--width=-1", self.path)
+
+    @staticmethod
+    def odt2txt_variant():
+        try:
+            out = subprocess.check_output(["odt2txt", "--version"])
+        except subprocess.CalledProcessError as e:
+            out = e.output
+        return out.decode("UTF-8").splitlines()[0].split()[0].strip()
 
 
 class OdtFile(File):



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/0f45b185a4e281bbd17ab4af1a711aa11abbb03a

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/0f45b185a4e281bbd17ab4af1a711aa11abbb03a
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20220105/0b2dc214/attachment.htm>


More information about the rb-commits mailing list