You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by aascedu October 7, 2024
Hello Anton, hello everyone,
I am trying to use name sets to help with complience tests.
I want to use the re module.
import re
def find_deny_rule(device, target):
normalized_target = re.sub(r'\s+', ' ', target).strip()
for rule in device.config["access-lists"]["98"]["rules"]:
if "source" in rule and "mode" in rule:
normalized_rule = re.sub(r'\s+', ' ', rule).strip()
if normalized_rule == normalized_target:
return True
return False
__all__ = ['find_deny_rule', 're']
Is not allowed in the GUI since the import re is not a from-import.
However how do I import the module re then ? I tried this then :
from re import sub
def find_deny_rule(device, target):
normalized_target = sub(r'\s+', ' ', target).strip()
for rule in device.config["access-lists"]["98"]["rules"]:
if "source" in rule and "mode" in rule:
normalized_rule = sub(r'\s+', ' ', rule).strip()
if normalized_rule == normalized_target:
return True
return False
__all__ = ['find_deny_rule', 'sub']
And I get this error : NameError: name 'sub' is not defined
The text was updated successfully, but these errors were encountered:
Discussed in #128
Originally posted by aascedu October 7, 2024
Hello Anton, hello everyone,
I am trying to use name sets to help with complience tests.
I want to use the re module.
Is not allowed in the GUI since the import re is not a from-import.
However how do I import the module re then ? I tried this then :
And I get this error :
NameError: name 'sub' is not defined
The text was updated successfully, but these errors were encountered: