A Pure Python Protobuf 3 .proto Parser
Project description
Protobuf Schema Parser
A Pure Python Protobuf 3 .proto schema Parser
Install
pip install proto-schema-parser
Usage
from pprint import pprint
from proto_schema_parser import Parser
messages = Parser().parse("""
syntax = "proto3";
message SearchRequest {
string query = 1 [(validate.rules).double = {gte: -90, lte: 90}];
optional int32 page_number = 2;
option foo = "bar";
int32 results_per_page = 3;
}
""")
pprint(messages)
"""
{'SearchRequest': Message(name='SearchRequest',
fields=[Field(name='query',
type='string',
cardinality=<FieldCardinality.REQUIRED: 'REQUIRED'>,
options=[Option(name='(validate.rules).double',
value='{gte:-90,lte:90}')]),
Field(name='page_number',
type='int32',
cardinality=<FieldCardinality.OPTIONAL: 'OPTIONAL'>,
options=[]),
Field(name='results_per_page',
type='int32',
cardinality=<FieldCardinality.REQUIRED: 'REQUIRED'>,
options=[])])}
"""
About
proto-schema-parser
is a pure Python implementation of a .proto
parser. It uses Buf.build's ANTLR Proto .g4 files to generate a Python Protocol buffer lexer and parser. The lexer and parser are complete implementations of Proto 2 and 3.
The project also includes a very simple Parser class and data model to make parsing .proto text easier.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
proto_schema_parser-0.1.0.tar.gz
(53.4 kB
view hashes)
Built Distribution
Close
Hashes for proto_schema_parser-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4621ae407323c5c084d8d93374d94a9408ef41ce9cedf72690ed30ef207cc885 |
|
MD5 | 31452de4d962f772cc9fb0442fac41da |
|
BLAKE2b-256 | a029463f6ac2d293c9ea36b81eb09ebd13002dac542a8d1cebf3c602b8a80a47 |
Close
Hashes for proto_schema_parser-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcae629300291bd3af1f0cfe5971ccae40c1e3ff838c67dde267a8a4ecbb1872 |
|
MD5 | 0cdd5e896632e4e1ae626ab57b6311e8 |
|
BLAKE2b-256 | b72dce0a6dd03460174cd853a868c84aae65bb5a1fde6fefe79c7c7a1f84d5e2 |