Python library for building composable text parsers
Project description
KNEX
Python library for creating chainable data transformers.
Installation
pip install knex
Usage
>>> from knex.parsers import *
>>>
>>> input_data = """
... Interface IP-Address OK? Method Status Protocol
... GigabitEthernet0/1 unassigned YES unset up up
... GigabitEthernet0/2 192.168.190.235 YES unset up up
... GigabitEthernet0/3 unassigned YES unset up up
... GigabitEthernet0/4 192.168.191.2 YES unset up up
... TenGigabitEthernet2/1 unassigned YES unset up up
... Virtual36 unassigned YES unset up up
... """
>>>
>>> pattern = r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
>>>
>>> result = (
Start(input_data)
> RegexExtractAll(pattern)
> GetIndex(0)
> Concat("", "/24")
> IpNetwork()
).result
>>>
>>> print(result)
192.168.190.0/24
>>>
Development
Environment Setup
- Install Poetry
- Clone the repo:
git clone https://github.com/clay584/knex && cd knex
- Install pre-requisits for developement:
poetry install
- Install PyPI API Key:
poetry config pypi-token.pypi <token>
- Activate the environment:
poetry shell
- Install git pre-commit hook:
pre-commit install && pre-commit autoupdate
Publishing to PyPI
- Run tests and validate coverage:
pytest -v --cov=knex --cov-report html tests
- Commit all changes, and have clean git repo on
main
branch. - Bump version:
bump2version <major|minor|patch>
- Push to git:
git push origin main --tags
- Build for PyPI:
poetry build
- Publish to PyPI:
poetry publish
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
knex-0.1.7.tar.gz
(15.7 kB
view details)
Built Distribution
knex-0.1.7-py3-none-any.whl
(15.7 kB
view details)
File details
Details for the file knex-0.1.7.tar.gz
.
File metadata
- Download URL: knex-0.1.7.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.7 Linux/5.11.0-34-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3efd56c6293e79bf10390ed5f76128be3a51ab077f9facab679e328dd9af8617 |
|
MD5 | 1b79b56fa129fdab865162bd370d20b8 |
|
BLAKE2b-256 | 1b7c332f9b4fbd1f7c427dc8cca7acae2870cd83bf7750fef20a28de34242773 |
File details
Details for the file knex-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: knex-0.1.7-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.7 Linux/5.11.0-34-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52b6d0317052063db71d1b7c59777dc46e30dde06f0c5adab575f75425f447fd |
|
MD5 | 20ede9a92dfd3c7a29283f6b8394ffc4 |
|
BLAKE2b-256 | 7167970335bf662dabc498d6f1511a8ebdd295925c1cb4df7f823ddbf4326262 |