Skip to main content

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.

  1. 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 -
    
  2. Install Protobuf Compiler: The Protobuf compiler (protoc) is required for compiling .proto files 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.

  3. Install the Package: Navigate to the root directory of the moschitta-serialization package 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.

  1. Define Protobuf Messages: Create a .proto file in the proto/ directory and define your Protobuf messages in it.

  2. Compile .proto Files: Run the compile_protos.py script to compile the .proto files into Python code:

    python compile_protos.py
    
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moschitta_serialization-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moschitta_serialization-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

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

Hashes for moschitta_serialization-0.1.1.tar.gz
Algorithm Hash digest
SHA256 07afe6b8a808e7a2e43aa2c9416e0c799f30a82ae318592ec447d6965323705c
MD5 31cd8451694a9514f4ec8205176b15b9
BLAKE2b-256 2bef4238f3f7f11069e676fa82dfc627d5a00cb6de96ccffcec53e93e0018ef0

See more details on using hashes here.

File details

Details for the file moschitta_serialization-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for moschitta_serialization-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 580acb7bbfa84264d40c26a879f02e213992e65a721c981f4cc944f257c89bcf
MD5 67c02eae7b2d871a09a065c192726f8a
BLAKE2b-256 138446dd0b8b67f03cec64969e7a48456db860f22f1b448e978ae4fb9f8a0f43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page