Skip to main content

BGPKIT Parser Python Binding

Project description

bgpkit-parser-py

Python binding for bgpkit-parser

Example

from pybgpkit_parser import Parser
import json

parser = Parser(
    url="https://spaces.bgpkit.org/parser/update-example",
    filters={"peer_ips": "185.1.8.65, 2001:7f8:73:0:3:fa4:0:1"},
)

for elem in parser:
    print(elem["origin_asns"])
    print(json.dumps(elem, indent=4))
    break

You can also add cache_dir to Parser to cache the downloaded files to a specified directory.

Here is an example:

from pybgpkit_parser import Parser
import json

parser = Parser(
    url="https://spaces.bgpkit.org/parser/update-example",
    filters={"peer_ips": "185.1.8.65, 2001:7f8:73:0:3:fa4:0:1"},
    cache_dir="./"
)

for elem in parser:
    print(elem["origin_asns"])
    print(json.dumps(elem, indent=4))
    break

Supported Python Version

  • Python3.7
  • Python3.8
  • Python3.9
  • Python3.10
  • Python3.11

Installation

python3 -m pip install pybgpkit-parser

Develop

maturin develop builds local python module and add to the venv.

Publish for Linux

Install multiple Python interpreters:

sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa

Build and upload for multiple interpreter versions:

maturin publish --interpreter python3.7 --skip-existing
maturin publish --interpreter python3.8 --skip-existing
maturin publish --interpreter python3.9 --skip-existing
maturin publish --interpreter python3.10 --skip-existing
maturin publish --interpreter python3.11 --skip-existing

Using docker

docker build -t bgpkit-builder:latest .
docker run --rm -it bgpkit-builder:latest bash

####
# TODO: copy the content of .pypirc to the root folder
####
git clone https://github.com/bgpkit/bgpkit-parser.git
cd bgpkit-parser/bgpkit-parser-py

maturin publish --interpreter python3.7 --skip-existing
maturin publish --interpreter python3.8 --skip-existing
maturin publish --interpreter python3.9 --skip-existing
maturin publish --interpreter python3.10 --skip-existing
maturin publish --interpreter python3.11 --skip-existing

Publish for MacOS

maturin publish --skip-existing

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

pybgpkit_parser-0.4.3.tar.gz (14.5 kB view hashes)

Uploaded Source

Built Distributions

pybgpkit_parser-0.4.3-cp311-cp311-manylinux_2_27_x86_64.whl (3.5 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.27+ x86-64

pybgpkit_parser-0.4.3-cp311-cp311-macosx_11_0_arm64.whl (1.7 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pybgpkit_parser-0.4.3-cp310-cp310-manylinux_2_27_x86_64.whl (3.5 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.27+ x86-64

pybgpkit_parser-0.4.3-cp310-cp310-macosx_11_0_arm64.whl (1.7 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pybgpkit_parser-0.4.3-cp39-cp39-manylinux_2_27_x86_64.whl (3.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.27+ x86-64

pybgpkit_parser-0.4.3-cp39-cp39-macosx_11_0_arm64.whl (1.7 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pybgpkit_parser-0.4.3-cp38-cp38-manylinux_2_27_x86_64.whl (3.5 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.27+ x86-64

pybgpkit_parser-0.4.3-cp38-cp38-macosx_11_0_arm64.whl (1.7 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pybgpkit_parser-0.4.3-cp37-cp37m-manylinux_2_27_x86_64.whl (3.5 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.27+ x86-64

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