Mercurial > hg > config
comparison python/example/ymldiff.py @ 807:26786fae0703
this relies on a requirement that is not part of my (2.7.12) stdlib; i almost deleted it. instead, i will keep for fun and note the requirement for further research
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Fri, 28 Oct 2016 17:09:04 -0700 |
| parents | python/ymldiff.py@d213d21e371b |
| children | 48ea50d346de |
comparison
equal
deleted
inserted
replaced
| 806:5364185dcb9b | 807:26786fae0703 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 import datadiff | |
| 4 import optparse | |
| 5 import sys | |
| 6 import yaml | |
| 7 | |
| 8 def main(args=sys.argv[1:]): | |
| 9 usage = '%prog [options] from.yml to.yml' | |
| 10 parser = optparse.OptionParser(usage=usage) | |
| 11 options, args = parser.parse_args() | |
| 12 if len(args) != 2: | |
| 13 parser.error("Please supply two .yml files") | |
| 14 | |
| 15 # compare the output | |
| 16 output0 = yaml.load(file(args[0])) | |
| 17 output1 = yaml.load(file(args[1])) | |
| 18 diff = datadiff.diff(output0, output1, context=1, fromfile=args[0], tofile=args[1]) | |
| 19 print diff | |
| 20 | |
| 21 if __name__ == '__main__': | |
| 22 main() |
