Skip to content

the python bindings for jomiel (protobuf) messages

License

Notifications You must be signed in to change notification settings

guendto/jomiel-messages

Repository files navigation

jomiel-messages

pypi-pyversions pypi-v pypi-wheel pypi-status code-style

The Python bindings for the jomiel protobuf messages.

About

The bindings have been generated from the protobuf declaration files of jomiel-proto

Installation

pip install jomiel-messages

Install from the repository, e.g. for development:

git clone https://github.com/guendto/jomiel-messages.git
cd jomiel-messages
./bin/gen
pip install -e .

Usage

Serialize an inquiry message:

from jomiel_messages.protobuf.v1alpha1.message_pb2 import Inquiry

inquiry = Inquiry()
inquiry.media.input_uri = 'https://foo.bar/baz'
serialized_string = Inquiry.SerializeToString(inquiry)
# ...

De-serialize a response message:

from jomiel_messages.protobuf.v1alpha1.message_pb2 import Response
from jomiel_messages.protobuf.v1alpha1.status_pb2 import STATUS_CODE_OK

response = Response()
response.ParseFromString(serialized_string)

if response.status.code != STATUS_CODE_OK:
  print(f"message={response.status.message})
  print(f"status-code={response.status.code}")
  print(f"error-code={response.status.error}")
  print(f"http-code={response.status.http.code}")
  # ...
else:
  # ...

License

jomiel-messages is licensed under the Apache License version 2.0.

Acknowledgements

Subprojects (as git subtrees)