https://github.com/trailofbits/graphtage Skip to content Sign up * Why GitHub? Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Project management - + Integrations - + GitHub Sponsors - + Customer stories- + Security - * Team * Enterprise * Explore + Explore GitHub - Learn and contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing Plans - + Compare plans - + Contact Sales - + Nonprofit - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} trailofbits / graphtage * Notifications * Star 1.3k * Fork 20 A semantic diff utility and library for tree-like files such as JSON, JSON5, XML, HTML, YAML, and CSV. LGPL-3.0 License 1.3k stars 20 forks Star Notifications * Code * Issues 13 * Pull requests 1 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights master Switch branches/tags [ ] Branches Tags Nothing to show {{ refName }} default View all branches Nothing to show {{ refName }} default View all tags 6 branches 8 tags Go to file Code Clone HTTPS GitHub CLI [https://github.com/t] Use Git or checkout with SVN using the web URL. [gh repo clone trailo] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching Xcode If nothing happens, download Xcode and try again. Go back Launching Visual Studio If nothing happens, download the GitHub extension for Visual Studio and try again. Go back Latest commit @ESultanik ESultanik Up the version for the next release ... 0d5f550 Feb 12, 2021 Up the version for the next release 0d5f550 Git stats * 432 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows Test against Python 3.9 in CI (#36) Dec 6, 2020 docs Packaging for a new release Feb 12, 2021 graphtage Up the version for the next release Feb 12, 2021 test Add formatting unit test for plist Feb 12, 2021 .gitignore git ignore build and dist Aug 29, 2020 LICENSE Added a `LICENSE` Apr 24, 2020 MANIFEST.in add test and LICENSE in MANIFEST.in Aug 29, 2020 README.md Packaging for a new release Feb 12, 2021 setup.py Add `numpy` as a project dependency (even though it was already impli... Dec 6, 2020 View code README.md Graphtage PyPI version Tests Slack Status Graphtage is a commandline utility and underlying library for semantically comparing and merging tree-like structures, such as JSON, XML, HTML, YAML, plist, and CSS files. Its name is a portmanteau of "graph" and "graftage"--the latter being the horticultural practice of joining two trees together such that they grow as one. [example] Installation $ pip3 install graphtage Command Line Usage Output Formatting Graphtage performs is analysis on an intermediate representation of the trees that is divorced from the filetypes of the input files. This means, for example, that you can diff a JSON file against a YAML file. Also, the output format can be different from the input format (s). By default, Graphtage will format the output diff in the same file format as the first input file. But one could, for example, diff two JSON files and format the output in YAML. There are several command line arguments to specify these transformations; please check the --help output for more information. By default, Graphtage pretty-prints its output with as many line breaks and indents as possible. { "foo": [ 1, 2, 3 ], "bar": "baz" } Use the --join-lists or -jl option to suppress linebreaks after list items: { "foo": [1, 2, 3], "bar": "baz" } Likewise, use the --join-dict-items or -jd option to suppress linebreaks after key/value pairs in a dict: {"foo": [ 1, 2, 3 ], "bar": "baz"} Use --condensed or -j to apply both of these options: {"foo": [1, 2, 3], "bar": "baz"} The --only-edits or -e option will print out a list of edits rather than applying them to the input file in place. Matching Options By default, Graphtage tries to match all possible pairs of elements in a dictionary. While computationally tractable, this can sometimes be onerous for input files with huge dictionaries. The --no-key-edits or -k option will instead only attempt to match dictionary items that share the same key, drastically reducing computation. Likewise, the --no-list-edits or -l option will not consider interstitial insertions and removals when comparing two lists. The --no-list-edits-when-same-length or -ll option is a less drastic version of -l that will behave normally for lists that are of different lengths, but behave like -l for lists that are of the same length. ANSI Color By default, Graphtage will only use ANSI color in its output if it is run from a TTY. If, for example, you would like to have Graphtage emit colorized output from a script or pipe, use the --color or -c argument. To disable color even when running on a TTY, use --no-color. HTML Output Graphtage can optionally emit the diff in HTML with the --html option. $ graphtage --html original.json modified.json > diff.html Status and Logging By default, Graphtage prints status messages and a progress bar to STDERR. To suppress this, use the --no-status option. To additionally suppress all but critical log messages, use --quiet. Fine grained control of log messages is via the --log-level option. Why does Graphtage exist? Diffing tree-like structures with unordered elements is tough. Say you want to compare two JSON files. There are limited tools available , which are effectively equivalent to canonicalizing the JSON (e.g., sorting dictionary elements by key) and performing a standard diff. This is not always sufficient. For exmaple, if a key in a dictionary is changed but its value is not, a traditional diff will conclude that the entire key/value pair was replaced by the new one, even though the only change was the key itself. See our documentation for more information. Using Graphtage as a Library See our documentation for more information. Extending Graphtage Graphtage is designed to be extensible; new filetypes can easily be defined, as well as new node types, edit types, formatters, and printers. See our documentation for more information. Complete API documentation is available here. License and Acknowledgements This research was developed by Trail of Bits with partial funding from the Defense Advanced Research Projects Agency (DARPA) under the SafeDocs program as a subcontractor to Galois. It is licensed under the GNU Lesser General Public License v3.0. Contact us if you're looking for an exception to the terms. (c) 2020, Trail of Bits. About A semantic diff utility and library for tree-like files such as JSON, JSON5, XML, HTML, YAML, and CSV. Resources Readme License LGPL-3.0 License Releases 8 Graphtage v0.2.5 Latest Feb 12, 2021 + 7 releases Packages 0 No packages published Used by 1 * @cyproterone @cyproterone / ansible-shell Contributors 4 * * * * Languages * Python 100.0% * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.