Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behavior if text notstartswith '\n' and template with '_end_' indicates #104

Open
matrix273 opened this issue Apr 18, 2023 · 0 comments

Comments

@matrix273
Copy link

matrix273 commented Apr 18, 2023

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

[
    {
        "interfaces": {
            "interface": "Port-Channel12",
            "line": " ip address 1.1.1.124 255.255.255.255\n    !"
        }
    }
]
@matrix273 matrix273 changed the title Incorrect behavior if text notstartswith '\n' Incorrect behavior if text notstartswith '\n' with '_end_' indicates Apr 18, 2023
@matrix273 matrix273 changed the title Incorrect behavior if text notstartswith '\n' with '_end_' indicates Incorrect behavior if text notstartswith '\n' and template with '_end_' indicates Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant