blob: 3a7a63b95c3d7951864632ec87dc710af45c7608 [file] [log] [blame]
Zsolt Harasztidca6fa12016-11-03 16:56:17 -07001#!/usr/bin/env python
Matteo Scandolo11d074c2017-08-29 13:29:37 -07002
Zsolt Harasztiaccad4a2017-01-03 21:56:48 -08003# Copyright 2017 the original author or authors.
Zsolt Harasztidca6fa12016-11-03 16:56:17 -07004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18"""
19Convert a schema.Schema object given on the standard input as protobuf data
20file (from standard output) to a Python dictionary.
21"""
22import json
23import sys
Zack Williamsf97bf092018-03-22 21:27:28 -070024from chameleon.protos import schema_pb2, annotations_pb2
Zsolt Harasztidca6fa12016-11-03 16:56:17 -070025from protobuf_to_dict import protobuf_to_dict
26
27
28if __name__ == '__main__':
29
30 data = sys.stdin.read()
31 schemas = schema_pb2.Schemas()
32 schemas.ParseFromString(data)
33
34 data = protobuf_to_dict(schemas, use_enum_labels=True)
35 json.dump(data, sys.stdout)