Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
Zsolt Haraszti | 3eb27a5 | 2017-01-03 21:56:48 -0800 | [diff] [blame^] | 3 | # Copyright 2017 the original author or authors. |
Zsolt Haraszti | 2bdb6b3 | 2016-11-03 16:56:17 -0700 | [diff] [blame] | 4 | # |
| 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 | """ |
| 19 | Convert a schema.Schema object given on the standard input as protobuf data |
| 20 | file (from standard output) to a Python dictionary. |
| 21 | """ |
| 22 | import json |
| 23 | import sys |
| 24 | from chameleon.protos.third_party.google.api import annotations_pb2 |
| 25 | _ = annotations_pb2 |
| 26 | from chameleon.protos import schema_pb2 |
| 27 | from protobuf_to_dict import protobuf_to_dict |
| 28 | |
| 29 | |
| 30 | if __name__ == '__main__': |
| 31 | |
| 32 | data = sys.stdin.read() |
| 33 | schemas = schema_pb2.Schemas() |
| 34 | schemas.ParseFromString(data) |
| 35 | |
| 36 | data = protobuf_to_dict(schemas, use_enum_labels=True) |
| 37 | json.dump(data, sys.stdout) |