Protocol Buffers file formatter.
Project description
proto-formatter
Protocol Buffers file formatter.
Install
pip install proto-formatter
Usage
- Format protobuf file using default config:
indents=2
all_top_comments=False
equal_sign=False
flatten=False
comment_max_length=None
new_fp=None.
Original protobuf file
test.proto
will be rewritten with formatted content.
from proto_formatter import format_file
format_file('test.proto')
- Format protobuf file with specified config:
indents=2
all_top_comments=False
equal_sign=False
flatten=False
comment_max_length=None
new_fp='formatted.proto.
Original protobuf file
test.proto
not be rewritten, create new protobuf fileformatted.proto
instead.
from proto_formatter import format_file
format_file('test.proto', indents=4, all_top_comments=True, equal_sign=True, flatten=False, comment_max_length=None, new_fp='formatted.proto')
- Format protobuf string align with equal sign: equal_sign=True, other configs are default values.
from proto_formatter import format_str
proto_str = """
/*
Person balabala
*/
message Person {
// comment of name a
required string name = 1; // comment of name b
/*
comment of id a
// comment of id b
*/
required int32 id = 2;// comment of id c
optional string email = 3;// comment of email
}
"""
formatted_proto_str = format_str(proto_str, equal_sign=True)
The formatted_proto_str is:
/*
Person balabala
*/
message Person {
/*
comment of name a
*/
required string name = 1; // comment of name b
/*
comment of id a
comment of id b
*/
required int32 id = 2; // comment of id c
optional string email = 3; // comment of email
}
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-formatter-0.1.3.tar.gz
(13.2 kB
view hashes)
Built Distribution
Close
Hashes for proto_formatter-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4adab76c5928b93a86b0572c207a05ae44ade90a1d8f3768e79609836f926361 |
|
MD5 | 9e8e1aabbca6996aaa28af679243ab46 |
|
BLAKE2b-256 | e57d05d62d8d8033bccff102f0aed2fc0685a398618fb28ca8af922d49a0d8b7 |