diff options
author | Daniil Baturin <daniil@baturin.org> | 2017-09-12 16:10:15 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2017-09-12 16:10:15 +0200 |
commit | f6f2d9114bc4ed9a176be51b537c0d4e3d1cf734 (patch) | |
tree | 44a928cbd36f541ddcc6e3ae079fdae4a93a623c | |
parent | e5cc6c0a804308fb025bbe907ef7729b56486861 (diff) | |
parent | 5404d4108b510765150c2ac54098cd26ec18a683 (diff) | |
download | vyos-1x-f6f2d9114bc4ed9a176be51b537c0d4e3d1cf734.tar.gz vyos-1x-f6f2d9114bc4ed9a176be51b537c0d4e3d1cf734.zip |
Merge branch 'current' of github.com:vyos/vyos-1x into current
-rwxr-xr-x | scripts/build-command-templates | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/scripts/build-command-templates b/scripts/build-command-templates index 3ed205c07..0bac920fb 100755 --- a/scripts/build-command-templates +++ b/scripts/build-command-templates @@ -22,8 +22,11 @@ import sys import os +import getopt import copy import functools +import pprint + from lxml import etree as ET @@ -38,6 +41,18 @@ input_file = sys.argv[1] schema_file = sys.argv[2] output_dir = sys.argv[3] + +debug = False +try: + opts, args = getopt.getopt(sys.argv[4:], '', ['debug=', ]) + for opt, arg in opts: + if opt == '--debug': + if arg == "1": + debug = True +except getopt.GetoptError as err: + pass + + ## Load and validate the inputs try: @@ -67,7 +82,10 @@ if not os.access(output_dir, os.W_OK): ## If we got this far, everything must be ok and we can convert the file def make_path(l): - return(functools.reduce(os.path.join, l)) + path = functools.reduce(os.path.join, l) + if debug: + print(path) + return path def get_properties(p): props = {} @@ -130,10 +148,10 @@ def make_node_def(props): if "owner" in props: node_def += "end: sudo sh -c \"{0}\"\n".format(props["owner"]) - + if debug: + print("The content of node_def:", node_def) return node_def - def process_node(n, tmpl_dir): # Avoid mangling the path from the outer call my_tmpl_dir = copy.copy(tmpl_dir) @@ -146,6 +164,9 @@ def process_node(n, tmpl_dir): node_type = n.tag my_tmpl_dir.append(name) + + if debug: + print("Name of the node: {};\n Created directory: ".format(name), end="") os.makedirs(make_path(my_tmpl_dir), exist_ok=True) props = get_properties(props_elem) @@ -168,6 +189,8 @@ def process_node(n, tmpl_dir): process_node(inner_n, my_tmpl_dir) if node_type == "tagNode": my_tmpl_dir.append("node.tag") + if debug: + print("Created path for the tagNode:", end="") os.makedirs(make_path(my_tmpl_dir), exist_ok=True) inner_nodes = children.iterfind("*") for inner_n in inner_nodes: @@ -175,7 +198,7 @@ def process_node(n, tmpl_dir): else: # This is a leaf node pass - + root = xml.getroot() |