diff options
author | Craig Tiller <ctiller@google.com> | 2015-08-31 15:53:36 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-08-31 15:53:36 -0700 |
commit | 1ebb7c885e55e16c8b65b7cb5c9ea08038cd67f4 (patch) | |
tree | a1267c94be1ca071ea393e889d84c13262ae4944 /tools/buildgen/build-cleaner.py | |
parent | e28e140afd0cb76de807375f28684e3d963931c4 (diff) |
Hand-written changes
Diffstat (limited to 'tools/buildgen/build-cleaner.py')
-rwxr-xr-x | tools/buildgen/build-cleaner.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/buildgen/build-cleaner.py b/tools/buildgen/build-cleaner.py index fba103723c..939143c4cb 100755 --- a/tools/buildgen/build-cleaner.py +++ b/tools/buildgen/build-cleaner.py @@ -28,16 +28,16 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# produces cleaner build.json files +# produces cleaner build.yaml files import collections -import json import os import sys +import yaml TEST = (os.environ.get('TEST', 'false') == 'true') -_TOP_LEVEL_KEYS = ['settings', 'filegroups', 'libs', 'targets'] +_TOP_LEVEL_KEYS = ['settings', 'filegroups', 'libs', 'targets', 'vspackages'] _VERSION_KEYS = ['major', 'minor', 'micro', 'build'] _ELEM_KEYS = [ 'name', @@ -50,6 +50,11 @@ _ELEM_KEYS = [ 'src', 'deps'] +def repr_ordered_dict(dumper, odict): + return dumper.represent_mapping(u'tag:yaml.org,2002:map', odict.items()) + +yaml.add_representer(collections.OrderedDict, repr_ordered_dict) + def rebuild_as_ordered_dict(indict, special_keys): outdict = collections.OrderedDict() for key in sorted(indict.keys()): @@ -75,7 +80,7 @@ def clean_elem(indict): for filename in sys.argv[1:]: with open(filename) as f: - js = json.load(f) + js = yaml.load(f) js = rebuild_as_ordered_dict(js, _TOP_LEVEL_KEYS) js['settings']['version'] = rebuild_as_ordered_dict( js['settings']['version'], _VERSION_KEYS) @@ -83,7 +88,7 @@ for filename in sys.argv[1:]: if grp not in js: continue js[grp] = sorted([clean_elem(x) for x in js[grp]], key=lambda x: (x.get('language', '_'), x['name'])) - output = json.dumps(js, indent = 2) + output = yaml.dump(js, indent=2, width=80) # massage out trailing whitespace lines = [] for line in output.splitlines(): |