Generates a JSON file with definitions from validator.protoascii. This method reads the specfile and emits JSON to out. Args: specfile: Path to validator.protoascii, the specfile to generate Javascript from. validator_pb2: The proto2 Python module generated from validator.proto
(specfile, validator_pb2, text_format,
json_format, out)
| 928 | |
| 929 | |
| 930 | def GenerateValidatorGeneratedJson(specfile, validator_pb2, text_format, |
| 931 | json_format, out): |
| 932 | """Generates a JSON file with definitions from validator.protoascii. |
| 933 | |
| 934 | This method reads the specfile and emits JSON to out. |
| 935 | |
| 936 | Args: |
| 937 | specfile: Path to validator.protoascii, the specfile to generate |
| 938 | Javascript from. |
| 939 | validator_pb2: The proto2 Python module generated from validator.proto. |
| 940 | text_format: The text_format module from the protobuf package, e.g. |
| 941 | google.protobuf.text_format. |
| 942 | json_format: The json_format module from the protobuf package, e.g. |
| 943 | google.protobuf.json_format. |
| 944 | out: a list of lines to output (without the newline characters), to |
| 945 | which this function will append. |
| 946 | """ |
| 947 | |
| 948 | rules = validator_pb2.ValidatorRules() |
| 949 | text_format.Merge(open(specfile).read(), rules) |
| 950 | out.append(json_format.MessageToJson(rules)) |