New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sproto

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sproto

sproto encode and decode

  • 0.1.4
  • PyPI
  • Socket score

Maintainers
1

✨ Pysproto ✨

Another Pythonic Sproto Python binding for sproto

Powered by cython, high performance, pythonic

pypi python implementation wheel license action

Usage

  • install
pip install sproto
  • encode & decode
from pysproto import parse, parse_ast, Sproto
ast = parse(""".package {
                    type 0 : integer
                    session 1 : integer
                    }""")
dump = parse_ast(ast)
proto = Sproto(dump)
tp = proto.querytype("package")
encoded = tp.encode({"type": 1, "session": 2})
print(tp.decode(encoded))
  • Public functions
from typing import Union, Tuple, Optional

class Sproto:
    def dump(self)->None: ...
    def protocol(self, tag_or_name: Union[int, str]) -> Tuple[Union[int, str], Optional["SprotoType"], Optional["SprotoType"]]: ...
    def querytype(self, type_name) -> "SprotoType": ...
    def sproto_protoresponse(self, intproto) -> int: ...

class SprotoError(Exception): ...

class SprotoType:
    @classmethod
    def __init__(self, *args, **kwargs) -> None: ...
    def decode(self, buffer: bytes) -> dict: ...
    def encode(self, data: dict) -> bytes: ...
    def encode_into(self, data: dict, buffer: bytearray) -> int: ...

def pack(data: bytes) -> bytes: ...
def pack_into(data: bytes, buffer: bytearray) -> int: ...
def unpack(data: bytes) -> bytes: ...
def unpack_into(data: bytes, buffer: bytearray) -> int: ...
  • xx_into functions accepts buffer protocol objects, which is zerocopy.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc