# Check for words or syntax in schema names that collide with names used by pybcf import pybcf import argparse import sys parser = argparse.ArgumentParser(description='Check for use of reserved names in the schema') parser.add_argument('path', type=str, default='controller', nargs='?') parser.add_argument('--host', '-H', type=str, default="127.0.0.1", help="Controller IP/Hostname to connect to") parser.add_argument('--user', '-u', type=str, default="admin", help="Username") parser.add_argument('--password', '-p', type=str, default="adminadmin", help="Password") args = parser.parse_args() bcf = pybcf.connect(args.host, args.user, args.password) blacklist = set(dir(bcf.root)) seen = set() failed = False def traverse(node): name = 'name' in node and node.name or None if name and name not in seen: seen.add(name) if name in blacklist or '_' in name: print name failed = True if node.nodeType == 'CONTAINER' or node.nodeType == 'LIST_ELEMENT': for child_name in node.childNodes: traverse(getattr(node.childNodes, child_name))
default="adminadmin", help="Password") parser.add_argument("--max-depth", "-d", type=int, help="Maximum recursion depth") parser.add_argument("--raw", action="store_true", help="Print raw JSON") parser.add_argument("--verbose", "-v", action="store_true", help="Include descriptions in the output") args = parser.parse_args() bcf = pybcf.connect(args.host, args.user, args.password) def pretty_type(node): if not 'typeSchemaNode' in node: return node.leafType.lower() t = node.typeSchemaNode if t.leafType == 'ENUMERATION': names = [ x for x in t.typeValidator if x.type == 'ENUMERATION_VALIDATOR' ][0].names return "enum { %s }" % ', '.join(names) elif t.leafType == 'UNION': names = [x.name for x in t.typeSchemaNodes]