No project description provided
Project description
Moschitta Serialization Documentation
moschitta-serialization is a Python package that provides serializers for converting data to and from various formats, including JSON, MessagePack, YAML, and Protobuf.
Table of Contents
Installation
To install moschitta-serialization, you'll need Python 3.7 or higher, as well as Poetry for dependency management and building the package.
-
Install Poetry: If you haven't already, install Poetry, a tool for dependency management and building Python packages. You can install it with the following command:
curl -sSL https://install.python-poetry.org | python -
-
Install Protobuf Compiler: The Protobuf compiler (
protoc) is required for compiling.protofiles into Python code. You can install it as follows:-
On Ubuntu/Debian:
sudo apt-get install protobuf-compiler
-
On macOS:
brew install protobuf
-
On Windows, download pre-compiled binaries from the Protocol Buffers GitHub repository. After downloading and unzipping the archive, add the
bin/directory to your PATH.
-
-
Install the Package: Navigate to the root directory of the
moschitta-serializationpackage and run the following command to install the package and its dependencies:poetry install
Usage
The moschitta-serialization package provides several serializers that you can use in your application. Here's an example of how to use the JSONSerializer:
from moschitta_serialization.json_serializer import JSONSerializer
serializer = JSONSerializer()
data = {"name": "John", "age": 30}
serialized_data = serializer.serialize(data)
print(serialized_data) # '{"name": "John", "age": 30}'
You can use the other serializers in a similar way.
Protobuf Serialization
To use the ProtobufSerializer, you'll need to define your Protobuf messages in .proto files, compile these files into Python code, and import the generated classes in your application.
-
Define Protobuf Messages: Create a
.protofile in theproto/directory and define your Protobuf messages in it. -
Compile
.protoFiles: Run thecompile_protos.pyscript to compile the.protofiles into Python code:python compile_protos.py -
Import Message Types: In your Python code, import the generated classes from the Python files:
from proto.person_pb2 import Person
You can then use these classes with the ProtobufSerializer.
Testing
The moschitta-serialization package includes a suite of tests that you can run with pytest. To run the tests, navigate to the root directory of the package and run the following command:
poetry run pytest
Contributing
Contributions to the moschitta-serialization package are welcome! Please submit a pull request or open an issue on the GitHub repository.
License
This project is licensed under the terms of the MIT License.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moschitta_serialization-0.1.1.tar.gz.
File metadata
- Download URL: moschitta_serialization-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.2 Linux/6.5.0-13parrot1-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07afe6b8a808e7a2e43aa2c9416e0c799f30a82ae318592ec447d6965323705c
|
|
| MD5 |
31cd8451694a9514f4ec8205176b15b9
|
|
| BLAKE2b-256 |
2bef4238f3f7f11069e676fa82dfc627d5a00cb6de96ccffcec53e93e0018ef0
|
File details
Details for the file moschitta_serialization-0.1.1-py3-none-any.whl.
File metadata
- Download URL: moschitta_serialization-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.2 Linux/6.5.0-13parrot1-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
580acb7bbfa84264d40c26a879f02e213992e65a721c981f4cc944f257c89bcf
|
|
| MD5 |
67c02eae7b2d871a09a065c192726f8a
|
|
| BLAKE2b-256 |
138446dd0b8b67f03cec64969e7a48456db860f22f1b448e978ae4fb9f8a0f43
|