blob: e644ba8dc1c8835df90427d9e784655177f1e9ab [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
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)