Skip to content

Commit

Permalink
Remove ci directory
Browse files Browse the repository at this point in the history
Centralize requirements in a dedicated directory
Add google address book example to README
  • Loading branch information
decitre committed Feb 4, 2024
1 parent fe2007a commit 36ae987
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ It is useful for Python programs needing to parse protobuf messages without havi

pip install proto-topy

## Google address book
## Example: address book

Adaptation of the [example](https://github.com/protocolbuffers/protobuf/tree/main/examples):
Adaptation of the `protocolbuffers` [example](https://github.com/protocolbuffers/protobuf/tree/main/examples):

```python
import requests
Expand All @@ -28,12 +28,15 @@ from pathlib import Path

# Retrieve protobuf messages definitions
example_source = requests.get(
"https://raw.githubusercontent.com/protocolbuffers/protobuf/main/examples/addressbook.proto").text
"https://raw.githubusercontent.com/protocolbuffers/protobuf/main/"
"examples/addressbook.proto").text

example_path = Path(
"protocolbuffers/protobuf/blob/main/examples/addressbook.proto")

# Compile and import
module = ProtoModule(file_path=example_path, source=example_source).compiled(Path(which("protoc")))
module = (ProtoModule(file_path=example_path, source=example_source)
.compiled(Path(which("protoc"))))
sys.modules["addressbook"] = module.py

# Produce a serialized address book
Expand Down

0 comments on commit 36ae987

Please sign in to comment.