A package for parsing proto3 files
Project description
Protoparser-ng
A package for parsing proto3 files
Introduction
The purpose of this package is to parse the .proto file (version 3) into a Python data structure. We use it for code generation or other operations where analysing the structure of the schema is the goal. This project is a fork of https://github.com/khadgarmage/protoparser by xiaochun.liu with the following features/fixes:
- Parse oneof definitions
- Parse comments without crashing
How to Use
pip install proto-parser-ng
Output format is as following:
{
"messages": {
"MessageItem": {
"comment": {
"content": "",
"tags": {}
},
"name": "MessageItem",
"fields": [
{
"comment": {
"content": "",
"tags": {}
},
"type": "string",
"key_type": "string",
"val_type": "string",
"name": "Title",
"number": 1
}
],
"messages": {},
"enums": {}
},
"Player": {
"comment": {
"content": "//@entry\n//@schema\n",
"tags": {
"entry": true,
"schema": true
}
},
"name": "Player",
"fields": [
{
"comment": {
"content": "//@fmt=date\n//@desc=Player's birthday\n",
"tags": {
"fmt": "date",
"desc": "Player's birthday"
}
},
"type": "string",
"key_type": "string",
"val_type": "string",
"name": "Birthday",
"number": 5
},
{
"comment": {
"content": "//@required\n",
"tags": {
"required": true
}
},
"type": "PlayerType",
"key_type": "PlayerType",
"val_type": "PlayerType",
"name": "Type",
"number": 6
},
{
"comment": {
"content": "// @title App version history\n",
"tags": {}
},
"type": "repeated",
"key_type": "string",
"val_type": "string",
"name": "AppVerHistory",
"number": 7
},
{
"comment": {
"content": "",
"tags": {}
},
"type": "repeated",
"key_type": "MessageItem",
"val_type": "MessageItem",
"name": "MessageBox",
"number": 8
},
{
"comment": {
"content": "//@ title =Warehouse\n",
"tags": {
"title": "Warehouse"
}
},
"type": "map",
"key_type": "uint64",
"val_type": "StoreItem",
"name": "Storage",
"number": 9
},
{
"comment": {
"content": "//@pattern=^(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]$\n",
"tags": {
"pattern": "^(https?|ftp|file)://[-A-Za-z0-9+&",
"#/%?": "~_|!:,.;]+[-A-Za-z0-9+&",
"#/%": "~_|]$"
}
},
"type": "string",
"key_type": "string",
"val_type": "string",
"name": "HomePage",
"number": 11
}
],
"messages": {
"StoreItem": {
"comment": {
"content": "",
"tags": {}
},
"name": "StoreItem",
"fields": [
{
"comment": {
"content": "",
"tags": {}
},
"type": "uint32",
"key_type": "uint32",
"val_type": "uint32",
"name": "Num",
"number": 1
}
],
"messages": {},
"enums": {}
}
},
"enums": {
"InnerType": {
"comment": {
"content": "",
"tags": {}
},
"name": "InnerType",
"fields": [
{
"comment": {
"content": "",
"tags": {}
},
"type": "enum",
"key_type": "enum",
"val_type": "enum",
"name": "TEST",
"number": "0"
}
]
}
}
}
},
"enums": {
"PlayerType": {
"comment": {
"content": "",
"tags": {}
},
"name": "PlayerType",
"fields": [
{
"comment": {
"content": "//normal player\n",
"tags": {}
},
"type": "enum",
"key_type": "enum",
"val_type": "enum",
"name": "NORMAL",
"number": "0"
},
{
"comment": {
"content": "//cheater\n",
"tags": {}
},
"type": "enum",
"key_type": "enum",
"val_type": "enum",
"name": "CHEATER",
"number": "1"
}
]
}
},
"services": {
"JobFileService": {
"name": "JobFileService",
"functions": [
{
"name": "GDriveFileList",
"in_type": "msg.GDriveFileListReq",
"out_type": "msg.FileListRep",
"uri": "/api/files/gdrive"
}
]
}
}
}
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file proto_parser_ng-1.0.1-py3-none-any.whl.
File metadata
- Download URL: proto_parser_ng-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db5e74a214ea828c9099628e7475ab1401f1c7f26bf91e1b4f16e8115b65aa60
|
|
| MD5 |
8b70ed376a8277c85c0673355ef15da9
|
|
| BLAKE2b-256 |
28cf21ecdeaf8359f78a4d132cb8569ed3b9fb5ab01d1d5e40948ccda85677c9
|