Skip to content
Snippets Groups Projects
Commit 0f45b185 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Support both variants of "odt2txt", including the one provided by unoconv....

Support both variants of "odt2txt", including the one provided by unoconv. (Closes: #298)
parent dd358a4b
No related branches found
No related tags found
No related merge requests found
Pipeline #334340 passed
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2017-2021 Chris Lamb <lamby@debian.org>
# Copyright © 2017-2022 Chris Lamb <lamby@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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment