Template Text Parser Templates collections
Actively maintained. Last release 3 days ago, commits in 15 of the last 26 weeks. A safe choice.
pip install ttp-templatesTemplate 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
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'}]]]