[Git][reproducible-builds/diffoscope][master] Add support for Python Sphinx inventory files, usually named objects.inv.

Chris Lamb (@lamby) gitlab at salsa.debian.org
Tue Oct 19 16:17:35 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
880e81ea by Chris Lamb at 2021-10-19T17:17:21+01:00
Add support for Python Sphinx inventory files, usually named objects.inv.

- - - - -


7 changed files:

- diffoscope/comparators/__init__.py
- + diffoscope/comparators/sphinx.py
- + tests/comparators/test_sphinx.py
- + tests/data/inv_expected_diff
- + tests/data/test1.inv
- + tests/data/test2.inv
- tests/test_source.py


Changes:

=====================================
diffoscope/comparators/__init__.py
=====================================
@@ -107,6 +107,7 @@ class ComparatorManager:
         ("pgp.PgpFile",),
         ("pgp.PgpSignature",),
         ("python.PycFile",),
+        ("sphinx.SphinxInventoryFile",),
         ("kbx.KbxFile",),
         ("fit.FlattenedImageTreeFile",),
         ("dtb.DeviceTreeFile",),


=====================================
diffoscope/comparators/sphinx.py
=====================================
@@ -0,0 +1,60 @@
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2021 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
+# 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 zlib
+
+from diffoscope.difference import Difference
+
+from .utils.file import File
+
+MAGIC = b"# Sphinx inventory version"
+
+
+class SphinxInventoryFile(File):
+    DESCRIPTION = "Sphinx inventory files"
+    FILE_EXTENSION_SUFFIX = {".inv"}
+
+    def compare_details(self, other, source=None):
+        return [
+            Difference.from_text(
+                describe_inventory(self.path),
+                describe_inventory(other.path),
+                self.path,
+                other.path,
+                source="Sphinx inventory",
+            )
+        ]
+
+
+def describe_inventory(filename):
+    head = b""
+    tail = b""
+
+    with open(filename, "rb") as f:
+        for line in f:
+            if line.startswith(b"#"):
+                # Save commented lines at top of file
+                head += line
+            else:
+                # ... save the rest for decompression
+                tail += line
+
+    result = head + b"\n" if head else b""
+    result += zlib.decompress(tail)
+
+    return result.decode("utf-8")


=====================================
tests/comparators/test_sphinx.py
=====================================
@@ -0,0 +1,45 @@
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2021 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
+# 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.sphinx import SphinxInventoryFile
+
+from ..utils.data import assert_diff, load_fixture
+
+
+inv1 = load_fixture("test1.inv")
+inv2 = load_fixture("test2.inv")
+
+
+def test_identification(inv1, inv2):
+    assert isinstance(inv1, SphinxInventoryFile)
+    assert isinstance(inv2, SphinxInventoryFile)
+
+
+def test_no_differences(inv1):
+    assert inv1.compare(inv1) is None
+
+
+ at pytest.fixture
+def differences(inv1, inv2):
+    return inv1.compare(inv2).details
+
+
+def test_diff(differences):
+    assert_diff(differences[0], "inv_expected_diff")


=====================================
tests/data/inv_expected_diff
=====================================
@@ -0,0 +1,187 @@
+@@ -1,19 +1,171 @@
+-api std:doc -1 api.html API
+-api std:label -1 api.html#$ API
+-configuration std:doc -1 configuration.html Configuration file
+-configuration std:label -1 configuration.html#$ Configuration file
++# Sphinx inventory version 2
++# Project: pytools
++# Version: 2021.2.8
++# The remainder of this file is compressed using zlib.
++
++pytools py:module 0 reference.html#module-$ -
++pytools.DebugProcessLogger py:class 1 reference.html#$ -
++pytools.F py:class 1 reference.html#$ -
++pytools.ProcessLogger py:class 1 reference.html#$ -
++pytools.ProcessLogger.__enter__ py:method 1 reference.html#$ -
++pytools.ProcessLogger.__exit__ py:method 1 reference.html#$ -
++pytools.ProcessLogger.__init__ py:method 1 reference.html#$ -
++pytools.ProcessLogger.done py:method 1 reference.html#$ -
++pytools.ProcessTimer py:class 1 reference.html#$ -
++pytools.ProcessTimer.__enter__ py:method 1 reference.html#$ -
++pytools.ProcessTimer.__exit__ py:method 1 reference.html#$ -
++pytools.ProcessTimer.done py:method 1 reference.html#$ -
++pytools.ProcessTimer.process_elapsed py:attribute 1 reference.html#$ -
++pytools.ProcessTimer.wall_elapsed py:attribute 1 reference.html#$ -
++pytools.ProgressBar py:class 1 reference.html#$ -
++pytools.ProgressBar.__enter__ py:method 1 reference.html#$ -
++pytools.ProgressBar.__exit__ py:method 1 reference.html#$ -
++pytools.ProgressBar.draw py:method 1 reference.html#$ -
++pytools.ProgressBar.finished py:method 1 reference.html#$ -
++pytools.ProgressBar.progress py:method 1 reference.html#$ -
++pytools.ProgressBar.set_progress py:method 1 reference.html#$ -
++pytools.T py:class 1 reference.html#$ -
++pytools.Table py:class 1 reference.html#$ -
++pytools.Table.__str__ py:method 1 reference.html#$ -
++pytools.Table.add_row py:method 1 reference.html#$ -
++pytools.Table.github_markdown py:method 1 reference.html#$ -
++pytools.Table.latex py:method 1 reference.html#$ -
++pytools.UniqueNameGenerator py:class 1 reference.html#$ -
++pytools.UniqueNameGenerator.__call__ py:method 1 reference.html#$ -
++pytools.UniqueNameGenerator.add_name py:method 1 reference.html#$ -
++pytools.UniqueNameGenerator.add_names py:method 1 reference.html#$ -
++pytools.UniqueNameGenerator.is_name_conflicting py:method 1 reference.html#$ -
++pytools.all_roughly_equal py:function 1 reference.html#$ -
++pytools.argmax py:function 1 reference.html#$ -
++pytools.argmax2 py:function 1 reference.html#$ -
++pytools.argmin py:function 1 reference.html#$ -
++pytools.argmin2 py:function 1 reference.html#$ -
++pytools.cartesian_product py:function 1 reference.html#$ -
++pytools.codegen py:module 0 codegen.html#module-$ -
++pytools.codegen.CodeGenerator py:class 1 codegen.html#$ -
++pytools.codegen.CodeGenerator.__call__ py:method 1 codegen.html#$ -
++pytools.codegen.CodeGenerator.add_to_preamble py:method 1 codegen.html#$ -
++pytools.codegen.CodeGenerator.dedent py:method 1 codegen.html#$ -
++pytools.codegen.CodeGenerator.extend py:method 1 codegen.html#$ -
++pytools.codegen.CodeGenerator.get py:method 1 codegen.html#$ -
++pytools.codegen.CodeGenerator.indent py:method 1 codegen.html#$ -
++pytools.codegen.Indentation py:class 1 codegen.html#$ -
++pytools.codegen.Indentation.__enter__ py:method 1 codegen.html#$ -
++pytools.codegen.Indentation.__exit__ py:method 1 codegen.html#$ -
++pytools.codegen.Indentation.generator py:attribute 1 codegen.html#$ -
++pytools.codegen.remove_common_indentation py:function 1 codegen.html#$ -
++pytools.comb py:function 1 reference.html#$ -
++pytools.datatable py:module 0 reference.html#module-$ -
++pytools.datatable.DataTable py:class 1 reference.html#$ -
++pytools.datatable.DataTable.__init__ py:method 1 reference.html#$ -
++pytools.datatable.DataTable.copy py:method 1 reference.html#$ -
++pytools.datatable.DataTable.deep_copy py:method 1 reference.html#$ -
++pytools.datatable.DataTable.join py:method 1 reference.html#$ -
++pytools.deprecate_keyword py:function 1 reference.html#$ -
++pytools.distinct_pairs py:function 1 reference.html#$ -
++pytools.download_from_web_if_not_present py:function 1 reference.html#$ -
++pytools.generate_all_integer_tuples_below py:function 1 reference.html#$ -
++pytools.generate_nonnegative_integer_tuples_below py:function 1 reference.html#$ -
++pytools.generate_nonnegative_integer_tuples_summing_to_at_most py:function 1 reference.html#$ -
++pytools.generate_numbered_unique_names py:function 1 reference.html#$ -
++pytools.generate_permutations py:function 1 reference.html#$ -
++pytools.generate_unique_names py:function 1 reference.html#$ -
++pytools.generate_unique_permutations py:function 1 reference.html#$ -
++pytools.graph py:module 0 graph.html#module-$ -
++pytools.graph.CycleError py:class 1 graph.html#$ -
++pytools.graph.T py:class 1 graph.html#$ -
++pytools.graph.a_star py:function 1 graph.html#$ -
++pytools.graph.compute_induced_subgraph py:function 1 graph.html#$ -
++pytools.graph.compute_sccs py:function 1 graph.html#$ -
++pytools.graph.compute_topological_order py:function 1 graph.html#$ -
++pytools.graph.compute_transitive_closure py:function 1 graph.html#$ -
++pytools.graph.contains_cycle py:function 1 graph.html#$ -
++pytools.invoke_editor py:function 1 reference.html#$ -
++pytools.is_single_valued py:function 1 reference.html#$ -
++pytools.keyed_memoize_in py:function 1 reference.html#$ -
++pytools.keyed_memoize_method py:function 1 reference.html#$ -
++pytools.keyed_memoize_on_first_arg py:function 1 reference.html#$ -
++pytools.levi_civita py:function 1 reference.html#$ -
++pytools.log_process py:class 1 reference.html#$ -
++pytools.memoize py:function 1 reference.html#$ -
++pytools.memoize_in py:function 1 reference.html#$ -
++pytools.memoize_method py:function 1 reference.html#$ -
++pytools.memoize_on_first_arg py:function 1 reference.html#$ -
++pytools.natorder py:function 1 reference.html#$ -
++pytools.natsorted py:function 1 reference.html#$ -
++pytools.obj_array py:module 0 obj_array.html#module-$ -
++pytools.obj_array.flat_obj_array py:function 1 obj_array.html#$ -
++pytools.obj_array.make_obj_array py:function 1 obj_array.html#$ -
++pytools.obj_array.obj_array_imag py:function 1 obj_array.html#$ -
++pytools.obj_array.obj_array_imag_copy py:function 1 obj_array.html#$ -
++pytools.obj_array.obj_array_real py:function 1 obj_array.html#$ -
++pytools.obj_array.obj_array_real_copy py:function 1 obj_array.html#$ -
++pytools.obj_array.obj_array_vectorize py:function 1 obj_array.html#$ -
++pytools.obj_array.obj_array_vectorize_n_args py:function 1 obj_array.html#$ -
++pytools.one py:function 1 reference.html#$ -
++pytools.perm py:function 1 reference.html#$ -
++pytools.persistent_dict py:module 0 persistent_dict.html#module-$ -
++pytools.persistent_dict.CollisionWarning py:exception 1 persistent_dict.html#$ -
++pytools.persistent_dict.KeyBuilder py:class 1 persistent_dict.html#$ -
++pytools.persistent_dict.KeyBuilder.__call__ py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.KeyBuilder.new_hash py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.KeyBuilder.rec py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.NoSuchEntryError py:exception 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict py:class 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.__delitem__ py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.__getitem__ py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.__init__ py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.__setitem__ py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.clear py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.fetch py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.remove py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.store py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.PersistentDict.store_if_not_present py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.ReadOnlyEntryError py:exception 1 persistent_dict.html#$ -
++pytools.persistent_dict.WriteOncePersistentDict py:class 1 persistent_dict.html#$ -
++pytools.persistent_dict.WriteOncePersistentDict.__getitem__ py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.WriteOncePersistentDict.__init__ py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.WriteOncePersistentDict.__setitem__ py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.WriteOncePersistentDict.clear py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.WriteOncePersistentDict.fetch py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.WriteOncePersistentDict.store py:method 1 persistent_dict.html#$ -
++pytools.persistent_dict.WriteOncePersistentDict.store_if_not_present py:method 1 persistent_dict.html#$ -
++pytools.reshaped_view py:function 1 reference.html#$ -
++pytools.resolve_name py:function 1 reference.html#$ -
++pytools.single_valued py:function 1 reference.html#$ -
++pytools.string_histogram py:function 1 reference.html#$ -
++pytools.tag py:module 0 tag.html#module-$ -
++pytools.tag.DottedName py:class 1 tag.html#$ -
++pytools.tag.DottedName.from_class py:method 1 tag.html#$ -
++pytools.tag.DottedName.name_parts py:attribute 1 tag.html#$ -
++pytools.tag.NonUniqueTagError py:class 1 tag.html#$ -
++pytools.tag.T_co py:class 1 tag.html#$ -
++pytools.tag.Tag py:class 1 tag.html#$ -
++pytools.tag.Tag.__repr__ py:method 1 tag.html#$ -
++pytools.tag.Tag.tag_name py:attribute 1 tag.html#$ -
++pytools.tag.Taggable py:class 1 tag.html#$ -
++pytools.tag.Taggable.__init__ py:method 1 tag.html#$ -
++pytools.tag.Taggable.copy py:method 1 tag.html#$ -
++pytools.tag.Taggable.tagged py:method 1 tag.html#$ -
++pytools.tag.Taggable.tags py:attribute 1 tag.html#$ -
++pytools.tag.Taggable.tags_of_type py:method 1 tag.html#$ -
++pytools.tag.Taggable.without_tags py:method 1 tag.html#$ -
++pytools.tag.UniqueTag py:class 1 tag.html#$ -
++pytools.tag.check_tag_uniqueness py:function 1 tag.html#$ -
++pytools.typedump py:function 1 reference.html#$ -
++pytools.unordered_hash py:function 1 reference.html#$ -
++pytools.wandering_element py:function 1 reference.html#$ -
++pytools.word_wrap py:function 1 reference.html#$ -
++codegen std:doc -1 codegen.html Tools for Source Code Generation
+ genindex std:label -1 genindex.html Index
+-index std:doc -1 index.html Welcome to xPore’s documentation!
+-installation std:doc -1 installation.html Installation
+-installation std:label -1 installation.html#$ Installation
++graph std:doc -1 graph.html Graph Algorithms
++index std:doc -1 index.html Welcome to pytools’s documentation!
++license std:label -1 misc.html#$ License
++misc std:doc -1 misc.html Installation
+ modindex std:label -1 py-modindex.html Module Index
+-outputtable std:doc -1 outputtable.html Output table description
+-outputtable std:label -1 outputtable.html#$ Output table description
+-preparation std:doc -1 preparation.html Data preparation from raw reads
+-preparation std:label -1 preparation.html#$ Data preparation from raw reads
++obj_array std:doc -1 obj_array.html Handling numpy Object Arrays
++persistent_dict std:doc -1 persistent_dict.html Persistent Hashing and Persistent Dictionaries
+ py-modindex std:label -1 py-modindex.html Python Module Index
+-quickstart std:doc -1 quickstart.html Quickstart - Detection of differential RNA modifications
+-quickstart std:label -1 quickstart.html#$ Quickstart - Detection of differential RNA modifications
+-scripts std:doc -1 scripts.html Scripts
+-scripts std:label -1 scripts.html#$ Scripts
++reference std:doc -1 reference.html A Collection of Utilities
+ search std:label -1 search.html Search Page
++tag std:doc -1 tag.html Tag Interface


=====================================
tests/data/test1.inv
=====================================
@@ -0,0 +1,3 @@
+xڝRN0`-+[E@jS
'6#ڍx\;MRl<ۭ,uLT>s!֢]F0
+脼5hJ^>u落	]-~8Ǵw
Ǽ3ap$5?/yR޴& Y
N@"rrJC}"X28Zc_`	
0q
+ez
v@˽\?[>X/4I2"O,6lxM>-)$UԾ6	k^
n;(uK?#^#g=в3KUƘ


=====================================
tests/data/test2.inv
=====================================
Binary files /dev/null and b/tests/data/test2.inv differ


=====================================
tests/test_source.py
=====================================
@@ -109,6 +109,7 @@ ALLOWED_TEST_FILES = {
     "test1.hi",
     "test1.icc",
     "test1.ico",
+    "test1.inv",
     "test1.iso",
     "test1.jmod",
     "test1.jpg",
@@ -172,6 +173,7 @@ ALLOWED_TEST_FILES = {
     "test2.hi",
     "test2.icc",
     "test2.ico",
+    "test2.inv",
     "test2.iso",
     "test2.jmod",
     "test2.jpg",



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

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/880e81ea1d40c917f879106bc9f61ccc40f9a7c4
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/20211019/0e63f2dd/attachment.htm>


More information about the rb-commits mailing list