Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
tools
reformat-json.py
Go to the documentation of this file.
1
#!/usr/bin/python
2
3
4
'''
5
Copyright 2013 Google Inc.
6
7
Use of this source code is governed by a BSD-style license that can be
8
found in the LICENSE file.
9
'''
10
11
'''
12
Rewrites a JSON file to use Python's standard JSON pretty-print format,
13
so that subsequent runs of rebaseline.py will generate useful diffs
14
(only the actual checksum differences will show up as diffs, not obscured
15
by format differences).
16
17
Should not modify the JSON contents in any meaningful way.
18
'''
19
20
21
# System-level imports
22
from
__future__
import
print_function
23
import
argparse
24
import
os
25
import
sys
26
27
28
# Imports from within Skia
29
#
30
# We need to add the 'gm' directory, so that we can import gm_json.py within
31
# that directory. That script allows us to parse the actual-results.json file
32
# written out by the GM tool.
33
# Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end*
34
# so any dirs that are already in the PYTHONPATH will be preferred.
35
#
36
# This assumes that the 'gm' directory has been checked out as a sibling of
37
# the 'tools' directory containing this script, which will be the case if
38
# 'trunk' was checked out as a single unit.
39
GM_DIRECTORY = os.path.realpath(
40
os.path.join(os.path.dirname(os.path.dirname(__file__)),
'gm'
))
41
if
GM_DIRECTORY
not
in
sys.path:
42
sys.path.append(GM_DIRECTORY)
43
import
gm_json
44
45
def
Reformat
(filename):
46
print
(
'Reformatting file %s...'
% filename)
47
gm_json.WriteToFile(gm_json.LoadFromFile(filename), filename)
48
49
def
_Main
():
50
parser = argparse.ArgumentParser(description=
'Reformat JSON files in-place.'
)
51
parser.add_argument(
'filenames'
, metavar=
'FILENAME'
, nargs=
'+'
,
52
help=
'file to reformat'
)
53
args = parser.parse_args()
54
for
filename
in
args.filenames:
55
Reformat
(filename)
56
sys.exit(0)
57
58
if
__name__ ==
'__main__'
:
59
_Main
()
print
void print(void *str)
Definition
bridge.cpp:126
tools.reformat-json._Main
_Main()
Definition
reformat-json.py:49
tools.reformat-json.Reformat
Reformat(filename)
Definition
reformat-json.py:45
Generated on Fri Apr 26 2024 06:18:11 for Flutter Engine by
1.9.8