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

Add support for comparing Gnumeric spreadsheets. (Closes: #893311)

parent 66bce92a
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ Build-Depends:
ghc <!nocheck>,
ghostscript <!nocheck>,
giflib-tools <!nocheck>,
gnumeric <!nocheck>,
help2man,
imagemagick <!nocheck>,
jsbeautifier <!nocheck>,
......
......@@ -58,6 +58,7 @@ class ComparatorManager(object):
('gettext.MoFile',),
('ipk.IpkFile',),
('rust.RustObjectFile',),
('gnumeric.GnumericFile',),
('gzip.GzipFile',),
('haskell.HiFile',),
('icc.IccFile',),
......
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2018 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import subprocess
from diffoscope.tools import tool_required
from diffoscope.tempfiles import get_named_temporary_file
from diffoscope.difference import Difference
from .utils.file import File
from .missing_file import MissingFile
class GnumericFile(File):
FILE_EXTENSION_SUFFIX = '.gnumeric'
@tool_required('ssconvert')
def compare_details(self, other, source=None):
if isinstance(other, MissingFile):
return [Difference(
None,
self.name,
other.name,
comment="Trying to compare two non-existing files."
)]
return [Difference.from_text(
self.dump(self),
self.dump(other),
self.name,
other.name,
source='ssconvert'
)]
def dump(self, file):
t = get_named_temporary_file()
subprocess.check_call((
'ssconvert',
'--export-type=Gnumeric_stf:stf_assistant',
file.path,
t.name,
))
with open(t.name) as f:
return f.read()
......@@ -220,6 +220,9 @@ EXTERNAL_TOOLS = {
'sng': {
'debian': 'sng',
},
'ssconvert': {
'debian': 'gnumeric',
},
'ssh-keygen': {
'debian': 'openssh-client',
'arch': 'openssh',
......
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2018 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import pytest
from diffoscope.comparators.gnumeric import GnumericFile
from ..utils.data import load_fixture, get_data
from ..utils.tools import skip_unless_tools_exist
from ..utils.nonexisting import assert_non_existing
gnumeric1 = load_fixture('test1.gnumeric')
gnumeric2 = load_fixture('test2.gnumeric')
def test_identification(gnumeric1):
assert isinstance(gnumeric1, GnumericFile)
def test_no_differences(gnumeric1):
difference = gnumeric1.compare(gnumeric1)
assert difference is None
@pytest.fixture
def differences(gnumeric1, gnumeric2):
return gnumeric1.compare(gnumeric2).details
@skip_unless_tools_exist('ssconvert')
def test_diff(differences):
expected_diff = get_data('gnumeric_expected_diff')
assert differences[0].unified_diff == expected_diff
@skip_unless_tools_exist('ssconvert')
def test_compare_non_existing(monkeypatch, gnumeric1):
assert_non_existing(monkeypatch, gnumeric1, has_null_source=False)
@@ -1 +1 @@
-foo
+bar
File added
File added
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