# Buildsheet autogenerated by ravenadm tool -- Do not edit.
NAMEBASE= python-ttp-templates
VERSION= 0.5.6
KEYWORDS= python
VARIANTS= v13 v14
SDESC[v13]= Template Text Parser Templates collections (3.13)
SDESC[v14]= Template Text Parser Templates collections (3.14)
HOMEPAGE= https://github.com/dmulyalin/ttp_templates
CONTACT= Python_Automaton[python@ravenports.com]
DOWNLOAD_GROUPS= main
SITES[main]= PYPIWHL/63/75/42aff2b7e9a2024576ff5f2af89f34f8db95a1c5c2b1707e4b65ab16009f
DISTFILE[1]= ttp_templates-0.5.6-py3-none-any.whl:main
DIST_SUBDIR= python-src
DF_INDEX= 1
SPKGS[v13]= single
SPKGS[v14]= single
OPTIONS_AVAILABLE= PY313 PY314
OPTIONS_STANDARD= none
VOPTS[v13]= PY313=ON PY314=OFF
VOPTS[v14]= PY313=OFF PY314=ON
DISTNAME= ttp_templates-0.5.6.dist-info
GENERATED= yes
[PY313].RUN_DEPENDS_ON= python-pydantic:single:v13
python-ttp:single:v13
[PY313].USES_ON= python:v13,wheel
[PY314].RUN_DEPENDS_ON= python-pydantic:single:v14
python-ttp:single:v14
[PY314].USES_ON= python:v14,wheel
[FILE:2328:descriptions/desc.single]
[Downloads]
[PyPI versions]
# Template Text Parser Templates
This repository contains a collection of [TTP] templates.
If you solved a problem using TTP and feel that your work can be useful to
other people, feel
free to raise an issue or submit pull request to include your template(s)
in this repository.
Refer to [Contribute Guide] for details.
Documentation: [https://dmulyalin.github.io/ttp_templates/]
Repository: [https://github.com/dmulyalin/ttp_templates]
TTP: [https://ttp.readthedocs.io/]
## Installation
From PyPi:
`pip install ttp-templates`
or latest from GitHub master branch (need Git installed on the system):
`pip install git+https://github.com/dmulyalin/ttp_templates.git`
## Sample usage
This example demonstrates how to parse `Test Platform` output for `show run
| sec interface` command using
`platform/test_platform_show_run_pipe_sec_interface.txt` template.
Code
```python
from ttp_templates import parse_output
import pprint
data = """
interface GigabitEthernet1/3.251
description Customer #32148
encapsulation dot1q 251
ip address 172.16.33.10 255.255.255.128
shutdown
!
interface GigabitEthernet1/3.251
description Customer #32148
encapsulation dot1q 251
ip address 172.16.33.10 255.255.255.128
shutdown
"""
result = parse_output(
data=data,
platform="Test Platform",
command="show run | sec interface"
)
pprint.pprint(result)
# prints:
# [[[{'description': 'Customer #32148',
# 'disabled': True,
# 'dot1q': '251',
# 'interface': 'GigabitEthernet1/3.251',
# 'ip': '172.16.33.10',
# 'mask': '255.255.255.128'},
# {'description': 'Customer #32148',
# 'disabled': True,
# 'dot1q': '251',
# 'interface': 'GigabitEthernet1/3.251',
# 'ip': '172.16.33.10',
# 'mask': '255.255.255.128'}]]]
```
Sample code to parse `Cisco IOS` output in a structure compatible with
`ietf-interfaces` YANG module.
Code
```python
from ttp_templates import get_template
from ttp import ttp
import pprint
data1 = """
interface GigabitEthernet1/3.251
description Customer #32148
encapsulation dot1q 251
ip address 172.16.33.10 255.255.255.128
shutdown
!
interface GigabitEthernet1/4
description vCPEs access control
ip address 172.16.33.10 255.255.255.128
!
"""
data2 = """
[FILE:126:distinfo]
8612a3f3209dad6d2f7a664a4188002c5d6c9c9e6f337c03179834c30f6cdc1e 113357 python-src/ttp_templates-0.5.6-py3-none-any.whl