Registry / data / ttp
library0.10.1pypypi✓ verified 85d ago

TTP is a Python library designed for fast and flexible parsing of semi-structured text data using templates. It was initially developed for processing CLI output from network devices but is versatile enough for any text with repetitive patterns. TTP offers features such as groups for results hierarchy, dynamic regex parsing, on-the-fly data processing with built-in or custom functions (macros), various output formats, and an input system. The library is actively maintained, with its latest version being 0.10.1.

pip install ttp
INSTALL
IMPORT
SIG · TTP
T
ttp
datapythonv0.10.1
Install
5.1s avg
Import
107ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.10.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.940 runs
installs and imports cleanly · install 0.0s · import 0.113s · 18.8MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 5.1s · import 0.101s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ttp
from ttp import ttp

This quickstart demonstrates parsing network interface configuration. It initializes the `ttp` parser with input data and a template, then parses the data and prints the results in JSON format. The template uses `group` tags to define the output structure and `{{ variable }}` for data extraction, including optional fields using `_start_` and `_end_` tags.

from ttp import ttp import pprint data = """ interface Loopback0 description Router-id-loopback ip address 192.168.0.113/24 ! interface Vlan778 description CPE_Acces_Vlan ip address 2002::fd37/124 ip vrf CPE1 ! """ template = """ <group> interface {{ interface }} description {{ description }} ip address {{ ip }}/{{ mask }} {{ _start_ -}} ip vrf {{ vrf }}{{ -_end_ }} </group> """ parser = ttp(data=data, template=template) parser.parse() results = parser.result(format='json')[0] pprint.pprint(results)
ttp --version
Debug
Known issues
breakingPython 2.7 support has been removed, and the minimum required Python version is now 3.9.
fix
Ensure your project is running on Python 3.9 or newer. Consider upgrading your Python environment.
affects: >=0.10.0
breakingThe 'input sources' feature, including Nornir and Netmiko sources, was removed in version 0.9.0. This was due to better integration methods with Netmiko and updates to Nornir.
fix
Migrate any reliance on the removed 'input sources' by directly integrating with Netmiko/Nornir or manually providing data to TTP using its `data` argument.
affects: >=0.9.0
gotchaWhen using `lookup` functions where one group's results are used for a lookup in another group, those groups must process separate inputs. TTP combines results on a per-input basis, which can lead to unexpected behavior if lookups cross shared input boundaries.
fix
Design your templates and input strategy such that groups relying on each other's results for lookups are processing distinct input data sets.
affects: All
gotchaOutput results often come as deeply nested lists, which can be unintuitive for new users. For example, `parser.result()` returns `[[[...]]]`, requiring indexing like `parser.result()[0]` or `parser.result(format='json')[0]` to access the main results.
fix
Always be mindful of the nested list structure when accessing results. Use `parser.result(format='json')[0]` or `parser.result(format='flat_json')` for a potentially simpler structure, or chain indices as needed to reach the desired data.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ttp'
The ttp library is not installed in the current Python environment or the environment is not activated.
fix
pip install ttp
ttp.errors.TtpError: Template data is empty. Make sure to provide non-empty template.
The 'template' argument provided to the ttp parser constructor was None or an empty string.
fix
Ensure the template variable contains a valid non-empty string with TTP template syntax.
ttp.errors.TtpError: Template file 'path/to/your/template.txt' not found.
The 'template' argument was provided as a file path, and 'template_file=True' was set, but the specified file does not exist at the given location.
fix
Verify the path to the template file is correct, and ensure the file exists and is accessible.
ttp.errors.TemplateSyntaxError: Encountered unexpected token '...' at line ..., column ....
The TTP template string contains invalid syntax, an unexpected token, or a structural error that prevents the parser from understanding it.
fix
Review the template string for typos, incorrect block delimiters (e.g., {{, {%), unclosed tags, or malformed regex patterns.
Upgrade
Version history
0.10.1latest on PyPI · released Mar 21, 2026
Audit
Dependencies
PythonrequiredRuntime environment
PyYAMLrequiredCore dependency, updated in 0.10.0
deepdiffrequiredCore dependency, updated in 0.10.0
jinja2requiredCore dependency, updated in 0.10.0
tabulaterequiredCore dependency, updated in 0.10.0
geoip2optionalRequired for the `geoip_lookup` function within templates
Agent activity
51 hits · last 30 days
node
40
OpenAI (training)
2
Resources
ttp — pip install ttp · libregistry