twnet_parser/README.md

48 lines
1.1 KiB
Markdown
Raw Normal View History

2023-03-16 13:49:55 +00:00
A teeworlds network protocol library, designed according to sans I/O (http://sans-io.readthedocs.io/) principles
2023-03-12 21:12:07 +00:00
2023-03-16 09:26:36 +00:00
## sample usage
2023-03-12 21:12:07 +00:00
```python
2023-03-16 11:08:02 +00:00
packet = parse(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:
2023-03-16 09:26:36 +00:00
print(msg.name) # => close
2023-03-12 21:12:07 +00:00
```
2023-03-14 21:58:06 +00:00
## setup
```bash
git clone https://gitlab.com/teeworlds-network/twnet_parser
cd twnet_parser
python -m venv venv
source venv/bin/activate
pip install -r requirements
```
2023-03-16 13:04:48 +00:00
## tests and linting
```bash
2023-03-16 13:49:55 +00:00
# dev dependencies
pip install -r requirements/dev.txt
2023-03-16 13:04:48 +00:00
# run unit tests
pytest .
# run style linter
pylint src/
# run type checker
mypy src/
```
2023-03-16 13:49:55 +00:00
## package and release
```bash
pip install -r requirements/dev.txt
python -m build
python -m twine upload dist/*
```