OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 ''' | 3 ''' |
4 Copyright 2013 Google Inc. | 4 Copyright 2013 Google Inc. |
5 | 5 |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 ''' | 8 ''' |
9 | 9 |
10 ''' | 10 ''' |
11 Gathers diffs between 2 JSON expectations files, or between actual and | 11 Gathers diffs between 2 JSON expectations files, or between actual and |
12 expected results within a single JSON actual-results file, | 12 expected results within a single JSON actual-results file, |
13 and generates an old-vs-new diff dictionary. | 13 and generates an old-vs-new diff dictionary. |
| 14 |
| 15 TODO(epoger): Fix indentation in this file (2-space indents, not 4-space). |
14 ''' | 16 ''' |
15 | 17 |
16 # System-level imports | 18 # System-level imports |
17 import argparse | 19 import argparse |
18 import json | 20 import json |
19 import os | 21 import os |
20 import sys | 22 import sys |
21 import urllib2 | 23 import urllib2 |
22 | 24 |
23 # Imports from within Skia | 25 # Imports from within Skia |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 oldfile. | 153 oldfile. |
152 """ | 154 """ |
153 old_results = self._GetExpectedResults(oldfile) | 155 old_results = self._GetExpectedResults(oldfile) |
154 if newfile: | 156 if newfile: |
155 new_results = self._GetExpectedResults(newfile) | 157 new_results = self._GetExpectedResults(newfile) |
156 else: | 158 else: |
157 new_results = self._GetActualResults(oldfile) | 159 new_results = self._GetActualResults(oldfile) |
158 return self._DictionaryDiff(old_results, new_results) | 160 return self._DictionaryDiff(old_results, new_results) |
159 | 161 |
160 | 162 |
161 # main... | 163 def _Main(): |
162 parser = argparse.ArgumentParser() | 164 parser = argparse.ArgumentParser() |
163 parser.add_argument('old', | 165 parser.add_argument( |
164 help='Path to JSON file whose expectations to display on ' + | 166 'old', |
165 'the "old" side of the diff. This can be a filepath on ' + | 167 help='Path to JSON file whose expectations to display on ' + |
166 'local storage, or a URL.') | 168 'the "old" side of the diff. This can be a filepath on ' + |
167 parser.add_argument('new', nargs='?', | 169 'local storage, or a URL.') |
168 help='Path to JSON file whose expectations to display on ' + | 170 parser.add_argument( |
169 'the "new" side of the diff; if not specified, uses the ' + | 171 'new', nargs='?', |
170 'ACTUAL results from the "old" JSON file. This can be a ' + | 172 help='Path to JSON file whose expectations to display on ' + |
171 'filepath on local storage, or a URL.') | 173 'the "new" side of the diff; if not specified, uses the ' + |
172 args = parser.parse_args() | 174 'ACTUAL results from the "old" JSON file. This can be a ' + |
173 differ = GMDiffer() | 175 'filepath on local storage, or a URL.') |
174 diffs = differ.GenerateDiffDict(oldfile=args.old, newfile=args.new) | 176 args = parser.parse_args() |
175 json.dump(diffs, sys.stdout, sort_keys=True, indent=2) | 177 differ = GMDiffer() |
| 178 diffs = differ.GenerateDiffDict(oldfile=args.old, newfile=args.new) |
| 179 json.dump(diffs, sys.stdout, sort_keys=True, indent=2) |
| 180 |
| 181 |
| 182 if __name__ == '__main__': |
| 183 _Main() |
OLD | NEW |