Elegant service objects for Python.
Project description
unimog
Elegant service objects for Python.
Composable business logic and uniform error handling for business logic actions. A single action does one thing, and multiple actions can be organized in groups. Groups and Actions can be arbitrarily nested and form complex DAGs (directed acyclic graph).
Service objects are useful to represent complex business logic in an easy to digest form.
Usage
pip install unimog
Action
import gzip
from unimog import Action
class CompressText(Action):
def perform(self):
compressed_text = gzip.compress(self.context.input)
return {"compressed_text": compressed_text}
result = CompressText()(input="Hello, World!")
result.is_success() # True
result.compressed_text # b'\x1f\x8b\x08\x00r\x92\xb7e…
Organizer
import gzip
from unimog import Action, Organizer
class CompressText(Action):
def perform(self):
compressed_text = gzip.compress(self.context.input)
return {"compressed_text": compressed_text}
class DecompressText(Action):
def perform(self):
text = gzip.decompress(self.context.data)
return {"text": text}
CompressAndDecompressText = Organizer(CompressText, DecompressText)
result = CompressAndDecompressText(input="Hello, World!")
result.is_success() # True
result.text # "Hello, World!"
Contributing
Tests
python -m pytest
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
unimog-0.1.0.tar.gz
(3.0 kB
view details)
Built Distribution
File details
Details for the file unimog-0.1.0.tar.gz
.
File metadata
- Download URL: unimog-0.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.6 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac957e1b93bb0e6a2182e80af4cf6e5497b999f316191f42a97878230f037815 |
|
MD5 | e6e2482c2d2943ba81c31edc0574703d |
|
BLAKE2b-256 | cb02c7e5d59b66a249b5309793a0b402d8a96c1c30c20e402afdd230a6becb63 |
File details
Details for the file unimog-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: unimog-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.6 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1061f9ef28fce3bb34d691fc775678d4011aa3824956213e0c598687fcb833e6 |
|
MD5 | d934e0dc89f839b0e4cab3c773fd2510 |
|
BLAKE2b-256 | b4a9cda0bd3137bdf3eb5fbc87184e3ba257e447c3e3d83004f341c8d1513bba |