xmldiff


Namexmldiff JSON
Version 2.6.3 PyPI version JSON
download
home_pagehttps://github.com/Shoobx/xmldiff
SummaryCreates diffs of XML files
upload_time2023-05-21 16:15:17
maintainer
docs_urlNone
authorLennart Regebro
requires_python>=3.7
licenseMIT
keywords xml html diff
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            xmldiff
========

.. image:: https://travis-ci.org/Shoobx/xmldiff.svg?branch=master
  :target: https://travis-ci.org/Shoobx/xmldiff

.. image:: https://coveralls.io/repos/github/Shoobx/xmldiff/badge.svg
  :target: https://coveralls.io/github/Shoobx/xmldiff

``xmldiff`` is a library and a command-line utility for making diffs out of XML.
This may seem like something that doesn't need a dedicated utility,
but change detection in hierarchical data is very different from change detection in flat data.
XML type formats are also not only used for computer readable data,
it is also often used as a format for hierarchical data that can be rendered into human readable formats.
A traditional diff on such a format would tell you line by line the differences,
but this would not be be readable by a human.
``xmldiff`` provides tools to make human readable diffs in those situations.

Full documentation is on `xmldiff.readthedocs.io <https://xmldiff.readthedocs.io>`_

``xmldiff`` is still under rapid development,
and no guarantees are done that the output of one version will be the same as the output of any previous version.


Quick usage
-----------

``xmldiff`` is both a command-line tool and a Python library.
To use it from the command-line, just run ``xmldiff`` with two input files::

  $ xmldiff file1.xml file2.xml

There is also a command to patch a file with the output from the ``xmldiff`` command::

  $ xmlpatch file.diff file1.xml

There is a simple API for using ``xmldiff`` as a library::

  from lxml import etree
  from xmldiff import main, formatting

  diff = main.diff_files('file1.xml', 'file2.xml',
                         formatter=formatting.XMLFormatter())

There is also a method ``diff_trees()`` that take two lxml trees,
and a method ``diff_texts()`` that will take strings containing XML.
Similarly, there is ``patch_file()`` ``patch_text()`` and ``patch_tree()``::

  result = main.patch_file('file.diff', 'file1.xml')


Changes from ``xmldiff`` 0.6/1.x
--------------------------------

  * A complete, ground up, pure-Python rewrite

  * Easier to maintain, the code is less complex and more Pythonic,
    and uses more custom classes instead of just nesting lists and dicts.

  * Fixes the problems with certain large files and solves the memory leaks.

  * A nice, easy to use Python API for using it as a library.

  * Adds support for showing the diffs in different formats,
    mainly one where differences are marked up in the XML,
    useful for making human readable diffs.

    These formats can show text differences in a semantically meaningful way.

  * An output format compatible with 0.6/1.x is also available.

  * 2.0 is currently significantly slower than ``xmldiff`` 0.6/1.x,
    but this will change in the future.
    Currently we make no effort to make ``xmldiff`` 2.0 fast,
    we concentrate on making it correct and usable.


Contributors
------------

 * Lennart Regebro, regebro@gmail.com (main author)

 * Stephan Richter, srichter@shoobx.com

 * Albertas Agejevas, alga@shoobx.com

 * Greg Kempe, greg@laws.africa

 * Filip Demski, glamhoth@protonmail.com

The diff algorithm is based on "`Change Detection in Hierarchically Structured Information <http://ilpubs.stanford.edu/115/1/1995-46.pdf>`_",
and the text diff is using Google's ``diff_match_patch`` algorithm.

Changes
=======

2.6.3 (2023-05-21)
------------------

- And there was a namespace bug in the patch as well. #118


2.6.2 (2023-05-21)
------------------

- Solved an error in the xmlformatter when using default namespaces. #89


2.6.1 (2023-04-05)
------------------

- #108: Fixed an error that happens if using namespaces like ns0 or ns1.


2.6 (2023-04-03)
----------------

- Added `InsertNamespace` and `DeleteNamespace` actions for better handling
  of changing namespaces. Should improve any "Unknown namespace prefix"
  errors. Changing the URI of a a namespace prefix is not supported, and will
  raise an error.

2.6b1 (2023-01-12)
------------------

- Used geometric mean for the node_ratio, for better handling of simple nodes.

- Added an experimental --best-match method that is slower, but generate
  smaller diffs when you have many nodes that are similar.

- The -F argument now also affects the --fast-match stage.


2.5 (2023-01-11)
----------------

- Make it possible to adjust the attributes considered when comparing nodes.

- Python versions 3.7 to 3.11 are now supported.

- Improved node matching method, that puts more emphasis similarities than
  differences when weighing attributes vs children.

- Added a parameter to return error code 1 when there are differences between the files

- Added a parameter for ignoring attributes in comparison.

- Solved a bug in xmlpatch in certain namespace situations.

- Added a --diff-encoding parameter to xmlpatch, to support diff-files that are
  not in your system default encoding.


2.4 (2019-10-09)
----------------

- Added an option to pass pairs of (element, attr) as unique
  attributes for tree matching.  Exposed this option on the command
  line, too.


2.3 (2019-02-27)
----------------

- Added a simple ``xmlpatch`` command and API.

- Multiple updates to documentation and code style


2.2 (2018-10-12)
----------------

- A workaround for dealing with top level comments and the xml formatter


2.1 (2018-10-03)
----------------

- Changed the substitution unicode character area to use the Private Use Area
  in BMP(0), to support narrow Python builds

- Added --unique-attributes argument.


2.1b1 (2018-10-01)
------------------

- Added options for faster node comparisons. The "middle" option is now
  default, it had very few changes in matches, but is much faster.

- Implemented a Fast Match algorithm for even faster diffing.

- Speed improvements through caching

- Fixed a bug where MoveNode actions sometimes was in the wrong order

- Added an InsertComment action, as comments require different handling,
  so it's easier to deal with them this way. You can still use DeleteNode and
  UpdateTextIn for them with no special handling.

- When renaming tags the XMLFormatter will mark them with "diff:rename"
  instead of making a new tag and deleting the old.

- Tags will now be moved first, and updated and renamed later, as the new
  tag name or attributes might not be valid in the old location.


2.0 (2018-09-25)
----------------

- A complete, bottom-up, pure-python rewrite

- New easy API

- 100% test coverage

- New output formats:

  - A new default output format with new actions

  - A format intended to be parseable by anyone parsing the old format.

  - XML with changes marked though tags and attributes

- xmldiff 2.0 is significantly slower than xmldiff 0.6 or 1.0,
  the emphasis so far is on correctness, not speed.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Shoobx/xmldiff",
    "name": "xmldiff",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "xml,html,diff",
    "author": "Lennart Regebro",
    "author_email": "lregebro@shoobx.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/5d/75f88f059d3929554ebf9aaa16b9a7990f8146e8dacd44aad9889b826876/xmldiff-2.6.3.tar.gz",
    "platform": null,
    "description": "xmldiff\n========\n\n.. image:: https://travis-ci.org/Shoobx/xmldiff.svg?branch=master\n  :target: https://travis-ci.org/Shoobx/xmldiff\n\n.. image:: https://coveralls.io/repos/github/Shoobx/xmldiff/badge.svg\n  :target: https://coveralls.io/github/Shoobx/xmldiff\n\n``xmldiff`` is a library and a command-line utility for making diffs out of XML.\nThis may seem like something that doesn't need a dedicated utility,\nbut change detection in hierarchical data is very different from change detection in flat data.\nXML type formats are also not only used for computer readable data,\nit is also often used as a format for hierarchical data that can be rendered into human readable formats.\nA traditional diff on such a format would tell you line by line the differences,\nbut this would not be be readable by a human.\n``xmldiff`` provides tools to make human readable diffs in those situations.\n\nFull documentation is on `xmldiff.readthedocs.io <https://xmldiff.readthedocs.io>`_\n\n``xmldiff`` is still under rapid development,\nand no guarantees are done that the output of one version will be the same as the output of any previous version.\n\n\nQuick usage\n-----------\n\n``xmldiff`` is both a command-line tool and a Python library.\nTo use it from the command-line, just run ``xmldiff`` with two input files::\n\n  $ xmldiff file1.xml file2.xml\n\nThere is also a command to patch a file with the output from the ``xmldiff`` command::\n\n  $ xmlpatch file.diff file1.xml\n\nThere is a simple API for using ``xmldiff`` as a library::\n\n  from lxml import etree\n  from xmldiff import main, formatting\n\n  diff = main.diff_files('file1.xml', 'file2.xml',\n                         formatter=formatting.XMLFormatter())\n\nThere is also a method ``diff_trees()`` that take two lxml trees,\nand a method ``diff_texts()`` that will take strings containing XML.\nSimilarly, there is ``patch_file()`` ``patch_text()`` and ``patch_tree()``::\n\n  result = main.patch_file('file.diff', 'file1.xml')\n\n\nChanges from ``xmldiff`` 0.6/1.x\n--------------------------------\n\n  * A complete, ground up, pure-Python rewrite\n\n  * Easier to maintain, the code is less complex and more Pythonic,\n    and uses more custom classes instead of just nesting lists and dicts.\n\n  * Fixes the problems with certain large files and solves the memory leaks.\n\n  * A nice, easy to use Python API for using it as a library.\n\n  * Adds support for showing the diffs in different formats,\n    mainly one where differences are marked up in the XML,\n    useful for making human readable diffs.\n\n    These formats can show text differences in a semantically meaningful way.\n\n  * An output format compatible with 0.6/1.x is also available.\n\n  * 2.0 is currently significantly slower than ``xmldiff`` 0.6/1.x,\n    but this will change in the future.\n    Currently we make no effort to make ``xmldiff`` 2.0 fast,\n    we concentrate on making it correct and usable.\n\n\nContributors\n------------\n\n * Lennart Regebro, regebro@gmail.com (main author)\n\n * Stephan Richter, srichter@shoobx.com\n\n * Albertas Agejevas, alga@shoobx.com\n\n * Greg Kempe, greg@laws.africa\n\n * Filip Demski, glamhoth@protonmail.com\n\nThe diff algorithm is based on \"`Change Detection in Hierarchically Structured Information <http://ilpubs.stanford.edu/115/1/1995-46.pdf>`_\",\nand the text diff is using Google's ``diff_match_patch`` algorithm.\n\nChanges\n=======\n\n2.6.3 (2023-05-21)\n------------------\n\n- And there was a namespace bug in the patch as well. #118\n\n\n2.6.2 (2023-05-21)\n------------------\n\n- Solved an error in the xmlformatter when using default namespaces. #89\n\n\n2.6.1 (2023-04-05)\n------------------\n\n- #108: Fixed an error that happens if using namespaces like ns0 or ns1.\n\n\n2.6 (2023-04-03)\n----------------\n\n- Added `InsertNamespace` and `DeleteNamespace` actions for better handling\n  of changing namespaces. Should improve any \"Unknown namespace prefix\"\n  errors. Changing the URI of a a namespace prefix is not supported, and will\n  raise an error.\n\n2.6b1 (2023-01-12)\n------------------\n\n- Used geometric mean for the node_ratio, for better handling of simple nodes.\n\n- Added an experimental --best-match method that is slower, but generate\n  smaller diffs when you have many nodes that are similar.\n\n- The -F argument now also affects the --fast-match stage.\n\n\n2.5 (2023-01-11)\n----------------\n\n- Make it possible to adjust the attributes considered when comparing nodes.\n\n- Python versions 3.7 to 3.11 are now supported.\n\n- Improved node matching method, that puts more emphasis similarities than\n  differences when weighing attributes vs children.\n\n- Added a parameter to return error code 1 when there are differences between the files\n\n- Added a parameter for ignoring attributes in comparison.\n\n- Solved a bug in xmlpatch in certain namespace situations.\n\n- Added a --diff-encoding parameter to xmlpatch, to support diff-files that are\n  not in your system default encoding.\n\n\n2.4 (2019-10-09)\n----------------\n\n- Added an option to pass pairs of (element, attr) as unique\n  attributes for tree matching.  Exposed this option on the command\n  line, too.\n\n\n2.3 (2019-02-27)\n----------------\n\n- Added a simple ``xmlpatch`` command and API.\n\n- Multiple updates to documentation and code style\n\n\n2.2 (2018-10-12)\n----------------\n\n- A workaround for dealing with top level comments and the xml formatter\n\n\n2.1 (2018-10-03)\n----------------\n\n- Changed the substitution unicode character area to use the Private Use Area\n  in BMP(0), to support narrow Python builds\n\n- Added --unique-attributes argument.\n\n\n2.1b1 (2018-10-01)\n------------------\n\n- Added options for faster node comparisons. The \"middle\" option is now\n  default, it had very few changes in matches, but is much faster.\n\n- Implemented a Fast Match algorithm for even faster diffing.\n\n- Speed improvements through caching\n\n- Fixed a bug where MoveNode actions sometimes was in the wrong order\n\n- Added an InsertComment action, as comments require different handling,\n  so it's easier to deal with them this way. You can still use DeleteNode and\n  UpdateTextIn for them with no special handling.\n\n- When renaming tags the XMLFormatter will mark them with \"diff:rename\"\n  instead of making a new tag and deleting the old.\n\n- Tags will now be moved first, and updated and renamed later, as the new\n  tag name or attributes might not be valid in the old location.\n\n\n2.0 (2018-09-25)\n----------------\n\n- A complete, bottom-up, pure-python rewrite\n\n- New easy API\n\n- 100% test coverage\n\n- New output formats:\n\n  - A new default output format with new actions\n\n  - A format intended to be parseable by anyone parsing the old format.\n\n  - XML with changes marked though tags and attributes\n\n- xmldiff 2.0 is significantly slower than xmldiff 0.6 or 1.0,\n  the emphasis so far is on correctness, not speed.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Creates diffs of XML files",
    "version": "2.6.3",
    "project_urls": {
        "Homepage": "https://github.com/Shoobx/xmldiff",
        "Source Code": "https://github.com/Shoobx/xmldiff"
    },
    "split_keywords": [
        "xml",
        "html",
        "diff"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1bf8399f82456aeb9e2676ee4f69e67b8eb296c2ba96167fa5c000a256af48eb",
                "md5": "6902c7a41f3035497a6ee9336ff7dc0a",
                "sha256": "5e18e7c2f69e92da05454fea7132b0c69943c973cf8b6f304cd0f7ddac291e67"
            },
            "downloads": -1,
            "filename": "xmldiff-2.6.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6902c7a41f3035497a6ee9336ff7dc0a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 43062,
            "upload_time": "2023-05-21T16:15:14",
            "upload_time_iso_8601": "2023-05-21T16:15:14.742223Z",
            "url": "https://files.pythonhosted.org/packages/1b/f8/399f82456aeb9e2676ee4f69e67b8eb296c2ba96167fa5c000a256af48eb/xmldiff-2.6.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c5d75f88f059d3929554ebf9aaa16b9a7990f8146e8dacd44aad9889b826876",
                "md5": "139f973cd3b66a642c1dd1737bce40dd",
                "sha256": "19b030b3fa37d1f0b5c5ad9ada9059884c3bf2c751c5dd8f1eb4ed49cfe3fc60"
            },
            "downloads": -1,
            "filename": "xmldiff-2.6.3.tar.gz",
            "has_sig": false,
            "md5_digest": "139f973cd3b66a642c1dd1737bce40dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 86132,
            "upload_time": "2023-05-21T16:15:17",
            "upload_time_iso_8601": "2023-05-21T16:15:17.156034Z",
            "url": "https://files.pythonhosted.org/packages/7c/5d/75f88f059d3929554ebf9aaa16b9a7990f8146e8dacd44aad9889b826876/xmldiff-2.6.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-21 16:15:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Shoobx",
    "github_project": "xmldiff",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": true,
    "lcname": "xmldiff"
}
        
Elapsed time: 0.07242s