A teeworlds network protocol library, designed according to sans I/O (http://sans-io.readthedocs.io/) principles
Go to file
2023-03-19 11:24:25 +01:00
requirements Release 0.0.1 2023-03-16 14:50:20 +01:00
scripts Some changelog helpers 2023-03-18 10:29:28 +01:00
tests Add chunk parsing tests 2023-03-18 11:47:20 +01:00
twnet_parser Commit int packer with dbg to keep it in history 2023-03-19 11:24:25 +01:00
.gitignore Overengineer release script 2023-03-16 16:51:57 +01:00
.gitlab-ci.yml Overengineer release script 2023-03-16 16:51:57 +01:00
.pylintrc First actual parse 2023-03-16 10:26:36 +01:00
LICENSE.txt Release 0.0.1 2023-03-16 14:50:20 +01:00
pyproject.toml Release 0.0.1 2023-03-16 14:50:20 +01:00
pytest.ini Add tests 2023-03-16 14:04:48 +01:00
README.md Break api packet.parse -> packet.parse7 2023-03-18 10:04:11 +01:00
requirements.txt Release 0.0.1 2023-03-16 14:50:20 +01:00
setup.cfg Release 0.1.0 2023-03-18 10:10:02 +01:00

A teeworlds network protocol library, designed according to sans I/O (http://sans-io.readthedocs.io/) principles

install

pip install twnet_parser

sample usage

import twnet_parser.packet
packet = twnet_parser.packet.parse7(b'\x04\x0a\x00\xcf\x2e\xde\x1d\04') # 0.7 close

print(packet) # => <class: 'TwPacket'>: {'version': '0.7', 'header': <class: 'Header'>, 'messages': [<class: 'CtrlMessage'>]}
print(packet.header) # => <class: 'Header'>: {'flags': <class: 'PacketFlags7, 'size': 0, 'ack': 10, 'token': b'\xcf.\xde\x1d', 'num_chunks': 0}
print(packet.header.flags) # => <class: 'PacketFlags7'>: {'control': True, 'resend': False, 'compression': False, 'connless': False}
for msg in packet.messages:
    print(msg.name) # => close

Features

Feature Status
Deserialize 0.7 packet headers ✔️
Deserialize 0.7 chunk headers
Deserialize 0.7 messages
Serialize 0.7 packet headers
Serialize 0.7 chunk headers
Serialize 0.7 messages
Deserialize 0.6 packet headers
Deserialize 0.6 chunk headers
Deserialize 0.6 messages
Serialize 0.6 packet headers
Serialize 0.6 chunk headers
Serialize 0.6 messages

Non-Features (also not planned for this library)

Feature Status Where to find it
Networking TODO: link if someone implemented it on top
Protocol version detection TODO: link if someone implemented it on top

Look elsewhere for these features. Or use this library to implement them on top.

development setup

git clone https://gitlab.com/teeworlds-network/twnet_parser
cd twnet_parser
python -m venv venv
source venv/bin/activate
pip install -r requirements/dev.txt

tests and linting

# dev dependencies
pip install -r requirements/dev.txt

# run unit tests
pytest .

# run style linter
pylint src/

# run type checker
mypy src/

package and release

# manual
pip install -r requirements/dev.txt
version=0.0.2
sed "s/^version =.*/version = $version/" setup.cfg
python -m build
git tag -a "v$version" -m "# version $version"
python -m twine upload dist/*

# or use the interactive convience script
./scripts/release.sh