summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@sentrium.io>2019-12-11 00:53:57 +0700
committerGitHub <noreply@github.com>2019-12-11 00:53:57 +0700
commitfa85664ba050dab99d18d5d05018eea6a0fb0879 (patch)
tree47072696e5b3e00a0b0b76fb1c66a901b15ad195
parent27dabfab5419cbf00f3b80683f31453db8bed1f9 (diff)
parent22184e3d47b1de68c6ff7beaa78986e5ba7d20a8 (diff)
downloadvyos-1x-fa85664ba050dab99d18d5d05018eea6a0fb0879.tar.gz
vyos-1x-fa85664ba050dab99d18d5d05018eea6a0fb0879.zip
Merge pull request #181 from elbuit/current
convert from node.def to xml enhancement
-rwxr-xr-xscripts/import-conf-mode-commands23
1 files changed, 19 insertions, 4 deletions
diff --git a/scripts/import-conf-mode-commands b/scripts/import-conf-mode-commands
index 4bdd5ee03..996b31c9c 100755
--- a/scripts/import-conf-mode-commands
+++ b/scripts/import-conf-mode-commands
@@ -34,9 +34,10 @@ TAG_NODE = 2
def parse_command_data(t):
regs = {
- 'help': r'\bhelp:(.*)(?:\n|$)',
- 'priority': r'\bpriority:(.*)(?:\n|$)',
- 'type': r'\btype:(.*)(?:\n|$)'
+ 'help': r'\bhelp:(.*)(?:\n|$)',
+ 'priority': r'\bpriority:(.*)(?:\n|$)',
+ 'type': r'\btype:(.*)(?:\n|$)',
+ 'syntax_expression_var': r'\bsyntax:expression: \$VAR\(\@\) in (.*)'
}
data = {'multi': False, 'help': ""}
@@ -74,7 +75,7 @@ def walk(tree, base_path, name):
# Tag node dirs will always have 'node.tag' subdir and 'node.def' file
# Leaf node dirs have nothing but a 'node.def' file
# Everything that doesn't match either of these patterns is a normal node
- if contents == ['node.tag', 'node.def']:
+ if 'node.tag' in contents:
print("Creating a tag node from {0}".format(path))
elem = etree.Element('tagNode')
node_type = TAG_NODE
@@ -129,6 +130,20 @@ def walk(tree, base_path, name):
constraint_elem = etree.Element('constraint')
has_constraint = False
+ # Add regexp field for multiple options
+ if data['syntax_expression_var']:
+ regex = etree.Element('regex')
+ constraint_error=etree.Element('constraintErrorMessage')
+ values = re.search(r'(.+) ; (.+)', data['syntax_expression_var']).group(1)
+ message = re.search(r'(.+) ; (.+)', data['syntax_expression_var']).group(2)
+ values = re.findall(r'\"(.+?)\"', values)
+ regex.text = '|'.join(values)
+ constraint_error.text = re.sub('\".*?VAR.*?\"', '', message)
+ constraint_error.text = re.sub(r'[\"|\\]', '', message)
+ constraint_elem.append(regex)
+ props_elem.append(constraint_elem)
+ props_elem.append(constraint_error)
+
if data['val_help']:
for vh in data['val_help']:
vh_elem = etree.Element('valueHelp')