Skip to content

Instantly share code, notes, and snippets.

@mentat
Created November 10, 2011 16:04
Show Gist options
  • Save mentat/1355213 to your computer and use it in GitHub Desktop.
Save mentat/1355213 to your computer and use it in GitHub Desktop.
Generate Protocol Buffer definition file from Python ProtoRPC Module
"""
Thanks to rafek@google.com (Rafe Kaplan) for this tip.
Create a .proto file from a module containing ProtoRPC Message
classes.
"""
import logging
from protorpc import descriptor
from protorpc import generate
from protorpc.generate_proto import format_proto_file
__all__ = ['format_proto_module']
def format_proto_module(module, output, indent_space=2):
file_descriptor = descriptor.describe_file(module)
format_proto_file(file_descriptor, output, indent_space=indent_space)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment