Skip to main content

A Textual TUI for interactively testing TextFSM and TTP templates with live parsing, JSON/table results, and exportable Python snippets.

Project description

tptpy

A terminal UI for interactively testing TextFSM and TTP templates against network device output — with live parsed results and auto-generated Python snippets you can drop straight into your automation.

Parse Tester TUI

What this is for and why

Writing TextFSM and TTP templates is an iterative process: tweak the template, run it, check the output, repeat. Most workflows involve bouncing between a text editor, a Python REPL, and maybe a browser-based tool that doesn't have your files.

tptpy puts everything in one screen:

  • Source text (left top) — paste or load device output from the file tree
  • Template (right top) — your TextFSM or TTP template
  • Parsed result (left bottom) — JSON or table view, updated on each parse
  • Python snippet (right bottom) — a self-contained script embedding your source + template, ready to copy

The directory tree auto-routes files: .textfsm, .template, .ttp, and .tpl extensions load into the template pane; everything else loads into the source pane.

Installation

From PyPI

pip install tptpy

From Source

git clone https://github.com/scottpeterman/tptpy.git
cd tptpy
pip install .

Development

git clone https://github.com/scottpeterman/tptpy.git
cd tptpy
pip install -e ".[dev]"

Usage

# Launch in current directory
tptpy

# Launch rooted at a specific project
tptpy ~/templates/bgp

# Or run as a module
python -m tptpy ~/templates/bgp

Keyboard Shortcuts

Key Action
Ctrl+P Run parse
Ctrl+S Save source pane (directory picker)
Ctrl+T Save template pane (directory picker)
Ctrl+R Focus the root path input
F2 Rename selected file/folder
Delete Delete selected file/folder
Ctrl+Q Quit

Supported Parsers

Parser Template Style Best For
TextFSM Value declarations + regex state machine Structured CLI output (show commands)
TTP Template with {{ variable }} placeholders Output that closely mirrors the template shape

Features

  • Four-pane layout — source, template, results, and snippet visible simultaneously
  • File tree with smart routing — template extensions auto-load to the template pane
  • File management — create, rename, and delete files and folders directly from the sidebar
  • Save with directory picker — save source or template content to any location in your project tree
  • JSON and table views — toggle between structured JSON and a tabular DataTable
  • Actionable error messages — parse failures include line numbers, context, and fix hints
  • Auto-generated snippets — each successful parse produces a standalone Python script
  • Filtered directory tree — shows only text and template files (.txt, .log, .cfg, .textfsm, .ttp, .yaml, .json, etc.)

Quick Example

  1. Launch tptpy pointed at a directory containing your show command output and templates
  2. Click a .txt or .log file — it loads into Source Text
  3. Click a .textfsm file — it loads into Template
  4. Hit Ctrl+P or click ▶ Parse
  5. Review results in JSON or Table view; grab the Python snippet for your project
  6. Hit Ctrl+S to save source or Ctrl+T to save your template — pick the directory and filename

Requirements

  • Python 3.10+
  • Textual — TUI framework
  • TextFSM — Google's template-based state machine parser
  • TTP — Template Text Parser

Project Structure

tptpy/
├── pyproject.toml
├── README.md
├── screenshots/
│   └── tui1.png
└── tptpy/
    ├── __init__.py
    └── __main__.py

License

MIT

Author

Scott Peterman — Principal Infrastructure Engineer, network automation toolsmith. Part of a broader toolkit for practical network engineering: github.com/scottpeterman

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

tptpy-1.0.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tptpy-1.0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file tptpy-1.0.1.tar.gz.

File metadata

  • Download URL: tptpy-1.0.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for tptpy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0a763d932e6bc2729bbd7571ba39b676c73310e61a4bdf183bd4b94714f3d496
MD5 93fa5e79a96bd1024a1a10dd908b5261
BLAKE2b-256 88b5041859e32d22c496d3226750bceee25bdf97c0a4173fcf920b4b7f799216

See more details on using hashes here.

File details

Details for the file tptpy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tptpy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for tptpy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21a78a4917362d5ad8579db2b5e5818b9f827253604f71d20b5f8fbddbe8d8e7
MD5 12ac6f933f614516ffbd3bb596ab3bc3
BLAKE2b-256 8afb619f1356ba93e4d5ee2d0bd7cb441d680b62a536d3209f42c920cef7baf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page