blob: 3456edc33b26408c179c22cb22a6adec73dfe805 [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
Daniele Moro538eba72020-02-12 22:07:24 -080024from chameleon.protos import schema_pb2
25from google.api import annotations_pb2
Zsolt Harasztidca6fa12016-11-03 16:56:17 -070026from protobuf_to_dict import protobuf_to_dict
27
28
29if __name__ == '__main__':
30
31 data = sys.stdin.read()
32 schemas = schema_pb2.Schemas()
33 schemas.ParseFromString(data)
34
35 data = protobuf_to_dict(schemas, use_enum_labels=True)
36 json.dump(data, sys.stdout)