All Projects → trailofbits → Graphtage

trailofbits / Graphtage

Licence: lgpl-3.0
A semantic diff utility and library for tree-like files such as JSON, JSON5, XML, HTML, YAML, and CSV.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Graphtage

Asciigraph
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.
Stars: ✭ 1,805 (-12.46%)
Mutual labels:  utility, command-line-tool, hacktoberfest2021
json2xml
json to xml converter in python3
Stars: ✭ 76 (-96.31%)
Mutual labels:  utility, command-line-tool
diskusage
FANTASTIC SPEED utility to find out top largest folders/files on the disk.
Stars: ✭ 64 (-96.9%)
Mutual labels:  utility, command-line-tool
Nomino
Batch rename utility for developers
Stars: ✭ 282 (-86.32%)
Mutual labels:  utility, command-line-tool
gee
🏵 Gee is tool of stdin to each files and stdout. It is similar to the tee command, but there are more functions for convenience. In addition, it was written as go
Stars: ✭ 65 (-96.85%)
Mutual labels:  utility, command-line-tool
Infinite-File-Curtailer
Curtail is a utility program that reads stdin and writes to a file bound by size.
Stars: ✭ 23 (-98.88%)
Mutual labels:  utility, command-line-tool
goto
Goto - The Good Way to Program
Stars: ✭ 14 (-99.32%)
Mutual labels:  utility, command-line-tool
Gitlab Cli
Create a merge request from command line in gitlab
Stars: ✭ 224 (-89.14%)
Mutual labels:  utility, command-line-tool
K2tf
Kubernetes YAML to Terraform HCL converter
Stars: ✭ 477 (-76.87%)
Mutual labels:  utility, command-line-tool
Text Minimap
Generate text minimap/preview using Braille Patterns
Stars: ✭ 21 (-98.98%)
Mutual labels:  utility, command-line-tool
Jardiff
A tool for comparing JAR files, including Scala pickled signatures and method code
Stars: ✭ 112 (-94.57%)
Mutual labels:  diff, command-line-tool
wifiqr
Create a QR code with your Wi-Fi login details
Stars: ✭ 207 (-89.96%)
Mutual labels:  utility, command-line-tool
dotfiles
dotfiles symbolic links management CLI
Stars: ✭ 156 (-92.43%)
Mutual labels:  utility, command-line-tool
freshpaper
This utility automatically sets the wallpaper of the day from various sources as your Desktop wallpaper.
Stars: ✭ 35 (-98.3%)
Mutual labels:  utility, hacktoberfest2021
Differentia.js
No longer being supported or maintained. A Graph Theory & Data Structure Library for JavaScript.
Stars: ✭ 13 (-99.37%)
Mutual labels:  diff, graph-algorithms
imgur-scraper
Retrieve years of imgur.com's data without any authentication.
Stars: ✭ 26 (-98.74%)
Mutual labels:  command-line-tool, hacktoberfest2021
Remarshal
Convert between CBOR, JSON, MessagePack, TOML, and YAML
Stars: ✭ 421 (-79.58%)
Mutual labels:  utility, command-line-tool
Endlines
Easy conversion between new-line conventions
Stars: ✭ 112 (-94.57%)
Mutual labels:  utility, command-line-tool
Georaptor
Python Geohash Compression Tool
Stars: ✭ 143 (-93.06%)
Mutual labels:  utility, command-line-tool
Shallowequal
↔️ Like lodash v3.x isEqualWith but for shallow equal.
Stars: ✭ 151 (-92.68%)
Mutual labels:  utility

Graphtage

PyPI version Tests Slack Status

Graphtage is a command-line 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.

Installation

$ pip3 install graphtage

Command Line Usage

Output Formatting

Graphtage performs an 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 example, 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. © 2020, Trail of Bits.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].