Ravenports generated: 24 Apr 2023 15:00
[ravenports.git] / bucket_19 / python-ttp
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               python-ttp
4 VERSION=                0.9.4
5 KEYWORDS=               python
6 VARIANTS=               py310 v11
7 SDESC[py310]=           Template Text Parser (3.10)
8 SDESC[v11]=             Template Text Parser (3.11)
9 HOMEPAGE=               https://github.com/dmulyalin/ttp
10 CONTACT=                Python_Automaton[python@ironwolf.systems]
11
12 DOWNLOAD_GROUPS=        main
13 SITES[main]=            PYPIWHL/0c/1c/256f6491e644468225e5618cda8ef74b9dbf007d5c5692128ac2c5c64940
14 DISTFILE[1]=            ttp-0.9.4-py2.py3-none-any.whl:main
15 DF_INDEX=               1
16 SPKGS[py310]=           single
17 SPKGS[v11]=             single
18
19 OPTIONS_AVAILABLE=      PY310 PY311
20 OPTIONS_STANDARD=       none
21 VOPTS[py310]=           PY310=ON PY311=OFF
22 VOPTS[v11]=             PY310=OFF PY311=ON
23
24 DISTNAME=               ttp-0.9.4.dist-info
25
26 GENERATED=              yes
27
28 [PY310].USES_ON=                        python:py310,wheel
29
30 [PY311].USES_ON=                        python:v11,wheel
31
32 [FILE:2346:descriptions/desc.single]
33 [Downloads]
34 [PyPI versions]
35 [Documentation status]
36
37 # Template Text Parser
38
39 TTP is a Python library for semi-structured text parsing using templates.
40
41 ## Why?
42
43 To save ones time on transforming raw text into structured data and beyond.
44
45 ## How?
46
47 Regexes, regexes everywhere... but, dynamically formed out of TTP templates
48 with added capabilities to simplify the  process of getting desired
49 outcome.
50
51 ## What?
52
53 In essence TTP can help to:
54   - Prepare, sort and load text data for parsing
55   - Parse text using regexes dynamically derived out of templates
56   - Process matches on the fly using broad set of built-in or custom
57 functions
58   - Combine match results in a structure with arbitrary hierarchy
59   - Transform results in desired format to ease consumption by humans or
60 machines
61   - Return results to various destinations for storage or further
62 processing
63
64 Reference [documentation] for more information.
65
66 TTP [Networktocode Slack channel]
67
68 Collection of [TTP Templates]
69
70 ## Example - as simple as it can be
71
72 Simple interfaces configuration parsing example
73
74 <details><summary>Code</summary>
75
76 ```python
77 from ttp import ttp
78 import pprint
79
80 data = """
81 interface Loopback0
82  description Router-id-loopback
83  ip address 192.168.0.113/24
84 !
85 interface Vlan778
86  description CPE_Acces_Vlan
87  ip address 2002::fd37/124
88  ip vrf CPE1
89 !
90 """
91
92 template = """
93 interface {{ interface }}
94  ip address {{ ip }}/{{ mask }}
95  description {{ description }}
96  ip vrf {{ vrf }}
97 """
98
99 parser = ttp(data, template)
100 parser.parse()
101 pprint.pprint(parser.result(), width=100)
102
103 # prints:
104 # [[[{'description': 'Router-id-loopback',
105 #     'interface': 'Loopback0',
106 #     'ip': '192.168.0.113',
107 #     'mask': '24'},
108 #    {'description': 'CPE_Acces_Vlan',
109 #     'interface': 'Vlan778',
110 #     'ip': '2002::fd37',
111 #     'mask': '124',
112 #     'vrf': 'CPE1'}]]]
113 ```
114 </details>
115
116 ## Example - a bit more complicated
117
118 For this example lets say we want to parse BGP peerings output, but combine
119 state with configuration data, at the end we want to get pretty looking
120 text table printed to screen.
121
122 <details><summary>Code</summary>
123
124 ```python
125 template="""
126 <doc>
127 This template first parses "show bgp vrf CUST-1 vpnv4 unicast summary"
128 commands
129 output, forming results for "bgp_state" dictionary, where peer ip is a key.
130
131 Following that, "show run | section bgp" output parsed by group "bgp_cfg".
132 That
133
134
135 [FILE:109:distinfo]
136 550e26fd742703f9fd0fac09e3701766190d4551978fccdead294d49cdec2423        85592 ttp-0.9.4-py2.py3-none-any.whl
137