Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ttp template
#4
Hi @deanhystad

For the same scenario as below,where we have a description in number of lines,How do we retrieve all the lines.I used _line_ but it gave the information of only the first line

import json
from ttp import ttp
 
temp = """
System Info
IPv4 configuration : {{ ipv4_configuration |  _exact_ }}
IPv6 configuration : {{ ipv6_configuration |  _exact_ }}
Description           : {{description | _line_}}
"""
 
data_to_parse = """
System Info
IPv4 configuration : Disabled
IPv6 configuration : Enabled
Description           : It is used to connect to the network 
                             using the IPV6 and IPV4 which is 
                             secure
"""
parser = ttp(data=data_to_parse, template=temp)
parser.parse()
 
result = json.loads(parser.result(format="json")[0])[0]
print(result)
My output is
Output:
{ipv4_configuration:'Disabled',ipv6_configuration:'Disabled',description': ' It is used to connect to the network '}
Reply


Messages In This Thread
ttp template - by jss - Aug-22-2023, 07:24 PM
RE: ttp template - by deanhystad - Aug-22-2023, 11:50 PM
RE: ttp template - by jss - Aug-23-2023, 05:26 AM
RE: ttp template - by jss - Aug-23-2023, 08:10 PM
RE: ttp template - by deanhystad - Aug-23-2023, 08:58 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020