We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I'm hitting a problem where it could be a bug but could be how Im using TTP with a regex string variable.
If I defined/hard code under and create a variable POLICY_RE like so:
And using it to scrape a juniper
<group name="policy_options.{{ policy }}" itemize="network"> {{ ignore("\s*") }}set policy-options prefix-list {{ policy | re(POLICY_RE) }} {{ network }} </group>
It works fine.
But if I try this
<group name="policy_options.{{ policy }}" itemize="network"> {{ ignore("\s*") }}set policy-options prefix-list {{ policy | re(MY_CUSTOM_REGEX) }} {{ network }} </group> search_policies = ".*MANAGEMENT.*" parser = ttp(data=config, template=ttp_template) parser.add_vars({"MY_CUSTOM_REGEX": search_policies}) parser.parse()
It doesn't work and when I step through the library code I see that the variable for parserObj.groups.0.start_re
parserObj.groups.0.start_re
is showing the name of the variable rather than the contents of the variable, the regex string like so:
'\\n(?:\\s*)set[ \\t] policy\\-options[ \\t] prefix\\-list[ \\t] (?P<policy>(?:MY_CUSTOM_REGEX))[ \\t] (?P<network>(?:\\S ))[\\t ]*(?=\\n|\\r\\n)'
whereas in the working case with hardcoding vars in template im getting the full regex string appearing
parserObj.groups.0.start_re '\\n(?:\\s*)set[ \\t] policy\\-options[ \\t] prefix\\-list[ \\t] (?P<policy>(?:.*MANAGEMENT.*))[ \\t] (?P<network>(?:\\S ))[\\t ]*(?=\\n|\\r\\n)'
Is this by design or am I using it incorrectly?
Many thanks,
Jon.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I'm hitting a problem where it could be a bug but could be how Im using TTP with a regex string variable.
If I defined/hard code under and create a variable POLICY_RE like so:
POLICY_RE = ".*MANAGEMENT.*"And using it to scrape a juniper
It works fine.
But if I try this
It doesn't work and when I step through the library code I see that the variable for
parserObj.groups.0.start_re
is showing the name of the variable rather than the contents of the variable, the regex string like so:
'\\n(?:\\s*)set[ \\t] policy\\-options[ \\t] prefix\\-list[ \\t] (?P<policy>(?:MY_CUSTOM_REGEX))[ \\t] (?P<network>(?:\\S ))[\\t ]*(?=\\n|\\r\\n)'
whereas in the working case with hardcoding vars in template im getting the full regex string appearing
Is this by design or am I using it incorrectly?
Many thanks,
Jon.
The text was updated successfully, but these errors were encountered: