Mercurial > hg > config
comparison python/ymldiff.py @ 220:192015ae3e4c
add ymldiff.py, requires datadiff and pyyaml to be installed
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 08 May 2012 08:26:55 -0700 |
parents | |
children | d213d21e371b |
comparison
equal
deleted
inserted
replaced
219:4390ca34912c | 220:192015ae3e4c |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import datadiff | |
4 imoprt 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 = 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() |