blob: 9c30d5eb1c4752930caa8338a36ba6b2f15127e7 [file] [log] [blame]
Zsolt Harasztidca6fa12016-11-03 16:56:17 -07001#!/usr/bin/env python
2#
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
24from chameleon.protos.third_party.google.api import annotations_pb2
25_ = annotations_pb2
26from chameleon.protos import schema_pb2
27from protobuf_to_dict import protobuf_to_dict
28
29
30if __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)