Created
February 27, 2020 08:36
-
-
Save remyleone/54725a5be6d152a406929036512981e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import pdb | |
from google.protobuf.compiler import plugin_pb2 as plugin | |
def generate_code(request, response): | |
with open("request.txt", "w") as f: | |
f.write(str(request)) | |
if __name__ == '__main__': | |
# Read request message from stdin | |
data = sys.stdin.read() | |
# Parse request | |
request = plugin.CodeGeneratorRequest() | |
request.ParseFromString(data) | |
# Create response | |
response = plugin.CodeGeneratorResponse() | |
# Generate code | |
generate_code(request, response) | |
# Serialise response message | |
output = response.SerializeToString() | |
# Write to stdout | |
sys.stdout.write(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment