pproto_py is Python implementation of "Point Of View" communication protocol
Project description
pproto-py 2.0
Example Client
import asyncio
from uuid import UUID
from pproto_py import Client, BaseContent, to_model, BasePprotoErrorContent
from uuid import uuid4, UUID
class testMy(BaseContent):
value1: int
value2: str
async def answer(self, data) -> None:
print(data)
class testMy2(BaseContent):
value1: int
value2: UUID
@to_model(testMy)
async def answer(self, data: testMy) -> None:
print(data.model_dump_json())
@to_model(BasePprotoErrorContent)
async def error(self, data: BasePprotoErrorContent) -> None:
print(data.model_dump_json())
async def main():
client = await Client.create_connect(host="127.0.0.1", port=8888)
test2 = testMy2(value1=10, value2=uuid4())
test_id2 = await test2.send(client, command="114949cb-2b6a-48f4-a5a4-15a682b2f45a")
print("dsa")
if __name__ == "__main__":
asyncio.run(main())
Example Server
import asyncio
from typing import Dict
from uuid import UUID
from pproto_py import Pproto
from pproto_py import BaseContent, BaseMessage, Status, BasePprotoErrorContent
class CommonException(Exception):
def __init__(self, error: str) -> None:
super().__init__()
self.error = error
class testMy(BaseContent):
value1: int
value2: str
server = Pproto()
@server.exception_handler(CommonException)
async def common_exception(message: Dict[str,str], exc: CommonException):
print(exc.error)
message_error = BaseMessage(command=message.command)
message_error.flags.exec_status.value = Status.ERROR.value
message_error.content = BasePprotoErrorContent(error=exc.error)
return message_error
@server.command(id=UUID("114949cb-2b6a-48f4-a5a4-15a682b2f45a"),
response_model=testMy)
async def example1(content):
# raise CommonException(error="Фигня какая-то")
dsa = testMy(value1=1,value2="dsa")
return dsa
async def main():
await server.run()
if __name__ == "__main__":
asyncio.run(main())
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 pproto_py-2.1.5.tar.gz.
File metadata
- Download URL: pproto_py-2.1.5.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0da13dd7083cf0f50ba7ee413d9375e64691c7dbf2750f85f20246f4a24bd0ea
|
|
| MD5 |
3085a2c7887d3d1ccd66d7100c0dd947
|
|
| BLAKE2b-256 |
b0056ab449540b60aad03014a9a6db52ccca88100ee14378f0b195c80b458882
|
Provenance
The following attestation bundles were made for pproto_py-2.1.5.tar.gz:
Publisher:
python-build-release.yml on TochkaAI/pproto_py-2.0
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pproto_py-2.1.5.tar.gz -
Subject digest:
0da13dd7083cf0f50ba7ee413d9375e64691c7dbf2750f85f20246f4a24bd0ea - Sigstore transparency entry: 1008386025
- Sigstore integration time:
-
Permalink:
TochkaAI/pproto_py-2.0@6273c4b8ed5cabde01f7c168bdefa2577432b45e -
Branch / Tag:
refs/tags/2.1.5 - Owner: https://github.com/TochkaAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-build-release.yml@6273c4b8ed5cabde01f7c168bdefa2577432b45e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pproto_py-2.1.5-py3-none-any.whl.
File metadata
- Download URL: pproto_py-2.1.5-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fbc5c307008ebd2372bb805aacee6381260e09c0aba245e5a7c8bd7bda2cede
|
|
| MD5 |
e1baeae2bec508ee36df799ef204f883
|
|
| BLAKE2b-256 |
c9d75c880720f7320600f6275e515312be50cfb77c3b4ef2e80d4d86f7ceacc5
|
Provenance
The following attestation bundles were made for pproto_py-2.1.5-py3-none-any.whl:
Publisher:
python-build-release.yml on TochkaAI/pproto_py-2.0
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pproto_py-2.1.5-py3-none-any.whl -
Subject digest:
8fbc5c307008ebd2372bb805aacee6381260e09c0aba245e5a7c8bd7bda2cede - Sigstore transparency entry: 1008386028
- Sigstore integration time:
-
Permalink:
TochkaAI/pproto_py-2.0@6273c4b8ed5cabde01f7c168bdefa2577432b45e -
Branch / Tag:
refs/tags/2.1.5 - Owner: https://github.com/TochkaAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-build-release.yml@6273c4b8ed5cabde01f7c168bdefa2577432b45e -
Trigger Event:
push
-
Statement type: