Skip to main content

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

  1. Install Poetry
  2. Clone the repo: git clone https://github.com/clay584/knex && cd knex
  3. Install pre-requisits for developement: poetry install
  4. Install PyPI API Key: poetry config pypi-token.pypi <token>
  5. Activate the environment: poetry shell
  6. Install git pre-commit hook: pre-commit install && pre-commit autoupdate

Publishing to PyPI

  1. Run tests and validate coverage: pytest -v --cov=knex --cov-report html tests
  2. Commit all changes, and have clean git repo on main branch.
  3. Bump version: bump2version <major|minor|patch>
  4. Push to git: git push origin main --tags
  5. Build for PyPI: poetry build
  6. Publish to PyPI: poetry publish

Project details


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)

Uploaded Source

Built Distribution

knex-0.1.7-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

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

Hashes for knex-0.1.7.tar.gz
Algorithm Hash digest
SHA256 3efd56c6293e79bf10390ed5f76128be3a51ab077f9facab679e328dd9af8617
MD5 1b79b56fa129fdab865162bd370d20b8
BLAKE2b-256 1b7c332f9b4fbd1f7c427dc8cca7acae2870cd83bf7750fef20a28de34242773

See more details on using hashes here.

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

Hashes for knex-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 52b6d0317052063db71d1b7c59777dc46e30dde06f0c5adab575f75425f447fd
MD5 20ede9a92dfd3c7a29283f6b8394ffc4
BLAKE2b-256 7167970335bf662dabc498d6f1511a8ebdd295925c1cb4df7f823ddbf4326262

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page