Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dirty conversion of protobuf_config.py from https://github.com/mildsunrise/protobuf-inspector to .proto
Replace
"([^"]+)": ?\{
With
message $1 {
Replace
},
With
}
Replace
((\d+): ?\("([^"]+)", "([^"]+)"[^\n]+)
With
$3 $4 = $2;
syntax = "proto3";
package stuff;
message Packet {
uint32 timestamp = 1;
string username = 2;
packed varint stuff = 7;
float other_stuff = 10;
item available_items = 14;
}
message Item {
string name = 1;
varint price = 2;
}
types = {
"root": {
1: ("uint32", "timestamp"),
2: ("string", "username"),
7: ("packed varint", "stuff"),
10: ("float", "other_stuff"),
14: ("item", "available_items"),
},
"item": {
1: ("string", "name"),
2: ("varint", "price"),
},
}
types = {
message root {
uint32 timestamp = 1;
string username = 2;
packed varint stuff = 7;
float other_stuff = 10;
item available_items = 14;
}
message item {
string name = 1;
varint price = 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment