Open matrix273 opened 1 year ago
Data notstartswith '\n':
data = """interface Port-Channel12 ip address 1.1.1.124 255.255.255.255 ! """
Template with '_end_' indicates:
<group name="interfaces" > interface {{ interface }} {{line|_line_}} {{ endline|ORPHRASE|_end_}} </group>
code below
parser = ttp(data=data, template=template) parser.parse() # print result in JSON format results = parser.result(format='json')[0] print(results)
I got result like below,missing 'line'
[ { "interfaces": { "interface": "Port-Channel12" } } ]
If I remove the '_end_' indicates,Template like this
<group name="interfaces" > interface {{ interface }} {{line|_line_}} {{ endline|ORPHRASE}} </group>
the result will like below,include 'line'
[ { "interfaces": { "interface": "Port-Channel12", "line": " ip address 1.1.1.124 255.255.255.255\n !" } } ]
And If I did't change Template,Only make Data startswith '\n',Data like this
data = """ interface Port-Channel12 ip address 1.1.1.124 255.255.255.255 ! """
the result will like below,include 'line' too
Data notstartswith '\n':
Template with '_end_' indicates:
code below
I got result like below,missing 'line'
If I remove the '_end_' indicates,Template like this
the result will like below,include 'line'
And If I did't change Template,Only make Data startswith '\n',Data like this
the result will like below,include 'line' too