Skip to main content

Utility functions and generators for working with the Google protobuf array format.

Project description

protobuf2arr-tools

Utility functions and generators for working with the Google protobuf array format.

Proto model generator

Generate a protobuf model from an unknown format protobuf array object. Often times we get protobuf array messages from Google internal services and need to build proto models to interact with them. This tool generates a template for that protobuf array by trying to guess the data type of each index.

CLI Usage

usage: proto_builder.py [-h] [--package PACKAGE] arr_json output_proto

Build a .proto model for an protobuf array.

positional arguments:
  arr_json           File containing the arr protobuf object.
  output_proto       File name to save the output .proto model.

options:
  -h, --help         show this help message and exit
  --package PACKAGE  .proto model package name.

Example

>>> head data.json
[[null, [[1650289911312855, 44780456, 1997349351], null, 2], 0, "92xdYpeME6iXrcUP58O0uAc"], [[[[["YSF", 0], "Hello World", ... 

>>> proto_builder.py data.json message.proto
Generated protobuf model: message.proto

>>> head message.proto
syntax = "proto3";

package generated;

message EntryPoint {
	Msg2 msg1 = 1;
	Msg11 msg2 = 2;
	string none3 = 3 [(nullable) = ''];
	Msg29 msg4 = 4;
	string none5 = 5 [(nullable) = ''];
	string none6 = 6 [(nullable) = ''];
	Msg31Container msg7 = 7;
	Msg41 msg8 = 8;
	string none9 = 9 [(nullable) = ''];
	string none10 = 10 [(nullable) = ''];
	string none11 = 11 [(nullable) = ''];
	Msg42Container msg12 = 12;
	Msg3 msg13 = 13;
	string none14 = 14 [(nullable) = ''];
	Msg1 msg15 = 15;
	string none16 = 16 [(nullable) = ''];
	string none17 = 17 [(nullable) = ''];
	Msg47 msg18 = 18;
	Msg3 msg19 = 19;
	string none20 = 20 [(nullable) = ''];
	bool field21 = 21;
}

...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protobuf2arr-tools-0.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

protobuf2arr_tools-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file protobuf2arr-tools-0.1.1.tar.gz.

File metadata

  • Download URL: protobuf2arr-tools-0.1.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for protobuf2arr-tools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6efd8d0cef3fd767b92765037391095876ec989ec591b9781e69fffacc8e5e21
MD5 eb236cc0aa97ba0248ebecc41b44060e
BLAKE2b-256 11138438d81b13879fe6de823dac14cc38e53ab578ab622cbc2bd009c19608f7

See more details on using hashes here.

File details

Details for the file protobuf2arr_tools-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for protobuf2arr_tools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f27a19d843e32c303557a3f51eec1af2bd7b07a6d08182d4ae3dd9b2ee2fc4c
MD5 2a7181de005197fc250fe7c6d9b49e00
BLAKE2b-256 70e028c71e0654333d27f475f60ab602b8b261a9a98f97302fe39fcbcbc463aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page