{"id":10313,"library":"ttp-templates","title":"TTP Templates","description":"ttp-templates is a Python library that provides a curated collection of Text Template Parser (TTP) templates, primarily focused on parsing network device CLI output. It extends the core TTP parser by offering an easy way to access and apply pre-built templates for various vendors and commands, including \"getter\" templates for normalized data. The current version is 0.5.1, with releases occurring periodically to add new templates and features or address issues.","status":"active","version":"0.5.1","language":"en","source_language":"en","source_url":"https://github.com/dmulyalin/ttp_templates","tags":["network","parsing","templates","cli","automation","ttp"],"install":[{"cmd":"pip install ttp-templates","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core parsing engine for which these templates are designed. Automatically installed as a dependency.","package":"ttp"}],"imports":[{"symbol":"TTPTemplates","correct":"from ttp_templates import TTPTemplates"}],"quickstart":{"code":"from ttp_templates import TTPTemplates\n\n# Initialize TTPTemplates\nparser = TTPTemplates()\n\n# Example device output for `get/inventory.txt` on Cisco NX-OS\n# This output structure is a simplified representation of `show inventory`\ndevice_output = \"\"\"\nNAME: \"Chassis\", DESCR: \"Nexus9000 C9372PX Chassis\"\nPID: N9K-C9372PX, VID: V01, SN: FOC12345678\n\nNAME: \"Slot 1\", DESCR: \"Supervisor\"\nPID: N9K-SUP-A, VID: V01, SN: JAE12345678\n\"\"\"\n\n# Parse the output using the 'get/inventory.txt' template\n# The 'platform' argument is often crucial for getter templates to select the right internal logic\nresult = parser.parse_output(\n    data=device_output,\n    template_name=\"get/inventory.txt\",\n    platform=\"cisco_nxos\" \n)\n\n# Print the normalized result\n# 'result' is typically a list of lists, where inner list contains dictionaries\n# In v0.5.1, it returns only the parsing result for the matched template.\nif result and result[0]:\n    print(\"Parsed Inventory Data:\")\n    for item in result[0]:\n        print(item)\nelse:\n    print(\"No data parsed or template did not match.\")","lang":"python","description":"Initializes the TTPTemplates parser, provides sample network device output, and demonstrates how to use a bundled 'getter' template to parse and normalize the data. The 'platform' argument helps select the correct template logic for vendor-specific output."},"warnings":[{"fix":"Ensure `parse_output` is always called with one of `template_name`, `template_path`, or `template_string` arguments correctly populated.","message":"Calling `parse_output` without a valid template-locating argument (e.g., `template_name`, `template_path`, `template_string`) now raises a `ValueError`. Previously, it silently forwarded `None` to the TTP constructor, leading to confusing downstream errors.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Adjust code that processes the `result` from `parser.parse_output` to expect a more direct data structure, typically `result[0]` containing the list of parsed dictionaries.","message":"The `get` results return now includes only the parsing result for the matched template. This streamlines the output but might change the structure if prior versions returned additional metadata around the result.","severity":"breaking","affected_versions":">=0.5.1"},{"fix":"Understand that `ttp-templates` is a collection of templates and convenience methods, whereas `ttp` is the fundamental parsing library. For advanced parsing or custom templates, you might interact directly with `ttp`.","message":"While `ttp-templates` installs the underlying `ttp` parser library automatically, users often confuse the two. `ttp-templates` provides the template files and a simplified API to access them, but `ttp` is the core engine for parsing.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Provide a valid template identifier, for example: `parser.parse_output(data=my_data, template_name='misc/N2G/cli_ip_data/arista_eos.txt')`","cause":"Attempting to call `TTPTemplates().parse_output()` without any argument to specify which template to use (e.g., no `template_name`, `template_path`, or `template_string`).","error":"ValueError: No template-locating argument provided. Please specify 'template_name', 'template_path', or 'template_string'."},{"fix":"Install the package using pip: `pip install ttp-templates`","cause":"The `ttp-templates` Python package is not installed in the current environment.","error":"ModuleNotFoundError: No module named 'ttp_templates'"},{"fix":"Verify the `template_name` against the list of available templates (e.g., using `TTPTemplates().list_templates()`) or ensure `template_path` points to an existing file.","cause":"The specified `template_name` does not correspond to any bundled template, or the path is incorrect for a custom template.","error":"TTPTemplates: failed to find template 'your_template_name.txt'"}]}