%global _empty_manifest_terminate_build 0 Name: python-knex Version: 0.5.0 Release: 1 Summary: Python library for building composable text parsers License: GNU GPLv3 URL: https://clay584.github.io/knex/ Source0: https://mirrors.nju.edu.cn/pypi/web/packages/70/ff/aae0df02afc1c19a8981b9aef08b026f1c2bf5b22547c51065cf86f1866d/knex-0.5.0.tar.gz BuildArch: noarch Requires: python3-regex Requires: python3-textfsm Requires: python3-macaddr %description # KNEX Python library for creating chainable data transformers. ## Installation `pip install knex` ## Usage ```python >>> 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" >>> >>> end = ( Start(input_data) > RegexExtractAll(pattern) > GetIndex(0) > Concat("", "/24") > IpNetwork() ) >>> >>> print(end.result) 192.168.190.0/24 >>> print(json.dumps(end.history, indent=4)) [ { "parser": "RegexExtractAll", "input": "...omitted for brevity...", "args": { "pattern": "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b" }, "error": false, "output": [ "192.168.190.235", "192.168.191.2" ] }, { "parser": "GetIndex", "input": [ "192.168.190.235", "192.168.191.2" ], "args": { "idx": 0 }, "error": false, "output": "192.168.190.235" }, { "parser": "Concat", "input": "192.168.190.235", "args": { "prefix": "", "suffix": "/24" }, "error": false, "output": "192.168.190.235/24" }, { "parser": "IpNetwork", "input": "192.168.190.235/24", "args": {}, "error": false, "output": "192.168.190.0/24" } ] >>> ``` %package -n python3-knex Summary: Python library for building composable text parsers Provides: python-knex BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-knex # KNEX Python library for creating chainable data transformers. ## Installation `pip install knex` ## Usage ```python >>> 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" >>> >>> end = ( Start(input_data) > RegexExtractAll(pattern) > GetIndex(0) > Concat("", "/24") > IpNetwork() ) >>> >>> print(end.result) 192.168.190.0/24 >>> print(json.dumps(end.history, indent=4)) [ { "parser": "RegexExtractAll", "input": "...omitted for brevity...", "args": { "pattern": "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b" }, "error": false, "output": [ "192.168.190.235", "192.168.191.2" ] }, { "parser": "GetIndex", "input": [ "192.168.190.235", "192.168.191.2" ], "args": { "idx": 0 }, "error": false, "output": "192.168.190.235" }, { "parser": "Concat", "input": "192.168.190.235", "args": { "prefix": "", "suffix": "/24" }, "error": false, "output": "192.168.190.235/24" }, { "parser": "IpNetwork", "input": "192.168.190.235/24", "args": {}, "error": false, "output": "192.168.190.0/24" } ] >>> ``` %package help Summary: Development documents and examples for knex Provides: python3-knex-doc %description help # KNEX Python library for creating chainable data transformers. ## Installation `pip install knex` ## Usage ```python >>> 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" >>> >>> end = ( Start(input_data) > RegexExtractAll(pattern) > GetIndex(0) > Concat("", "/24") > IpNetwork() ) >>> >>> print(end.result) 192.168.190.0/24 >>> print(json.dumps(end.history, indent=4)) [ { "parser": "RegexExtractAll", "input": "...omitted for brevity...", "args": { "pattern": "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b" }, "error": false, "output": [ "192.168.190.235", "192.168.191.2" ] }, { "parser": "GetIndex", "input": [ "192.168.190.235", "192.168.191.2" ], "args": { "idx": 0 }, "error": false, "output": "192.168.190.235" }, { "parser": "Concat", "input": "192.168.190.235", "args": { "prefix": "", "suffix": "/24" }, "error": false, "output": "192.168.190.235/24" }, { "parser": "IpNetwork", "input": "192.168.190.235/24", "args": {}, "error": false, "output": "192.168.190.0/24" } ] >>> ``` %prep %autosetup -n knex-0.5.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-knex -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue May 30 2023 Python_Bot - 0.5.0-1 - Package Spec generated