Exemple #1
0
 def process(self):
     namespaces = []
     nodoc = False
     internal = False
     permissions = None
     for node in self.idl:
         if node.cls == 'Namespace':
             namespace = Namespace(node, nodoc, permissions, internal)
             namespaces.append(namespace.process())
             nodoc = False
             internal = False
         elif node.cls == 'Copyright':
             continue
         elif node.cls == 'Comment':
             continue
         elif node.cls == 'ExtAttribute':
             if node.name == 'nodoc':
                 nodoc = bool(node.value)
             elif node.name == 'permissions':
                 permission = node.value.split(',')
             elif node.name == 'internal':
                 internal = bool(node.value)
             else:
                 continue
         else:
             sys.exit('Did not process %s %s' % (node.cls, node))
     schema_util.PrefixSchemasWithNamespace(namespaces)
     return namespaces
Exemple #2
0
 def process(self):
     namespaces = []
     for node in self.idl:
         nodoc = False
         cls = node.cls
         if cls == 'Namespace':
             namespace = Namespace(node, nodoc)
             namespaces.append(namespace.process())
         elif cls == 'Copyright':
             continue
         elif cls == 'Comment':
             continue
         elif cls == 'ExtAttribute':
             if node.name == 'nodoc':
                 nodoc = bool(node.value)
             else:
                 continue
         else:
             sys.exit("Did not process %s %s" % (node.cls, node))
     schema_util.PrefixSchemasWithNamespace(namespaces)
     return namespaces
Exemple #3
0
def Load(filename):
    with open(filename, 'r') as handle:
        schemas = json_parse.Parse(handle.read())
    schema_util.PrefixSchemasWithNamespace(schemas)
    return schemas
Exemple #4
0
def Load(filename):
    with open(filename, 'r') as handle:
        schemas = json.loads(json_comment_eater.Nom(handle.read()))
    schema_util.PrefixSchemasWithNamespace(schemas)
    return schemas
Exemple #5
0
    def testPrefixSchemasWithNamespace(self):
        schemas = [
            {
                'namespace':
                'n1',
                'types': [{
                    'id': 'T1',
                    'customBindings': 'T1',
                    'properties': {
                        'p1': {
                            '$ref': 'T1'
                        },
                        'p2': {
                            '$ref': 'fully.qualified.T'
                        },
                    }
                }],
                'functions': [
                    {
                        'parameters': [
                            {
                                '$ref': 'T1'
                            },
                            {
                                '$ref': 'fully.qualified.T'
                            },
                        ],
                        'returns': {
                            '$ref': 'T1'
                        }
                    },
                ],
                'events': [
                    {
                        'parameters': [
                            {
                                '$ref': 'T1'
                            },
                            {
                                '$ref': 'fully.qualified.T'
                            },
                        ],
                    },
                ],
            },
        ]
        schema_util.PrefixSchemasWithNamespace(schemas)
        self.assertEquals('n1.T1', schemas[0]['types'][0]['id'])
        self.assertEquals('n1.T1', schemas[0]['types'][0]['customBindings'])
        self.assertEquals('n1.T1',
                          schemas[0]['types'][0]['properties']['p1']['$ref'])
        self.assertEquals('fully.qualified.T',
                          schemas[0]['types'][0]['properties']['p2']['$ref'])

        self.assertEquals('n1.T1',
                          schemas[0]['functions'][0]['parameters'][0]['$ref'])
        self.assertEquals('fully.qualified.T',
                          schemas[0]['functions'][0]['parameters'][1]['$ref'])
        self.assertEquals('n1.T1',
                          schemas[0]['functions'][0]['returns']['$ref'])

        self.assertEquals('n1.T1',
                          schemas[0]['events'][0]['parameters'][0]['$ref'])
        self.assertEquals('fully.qualified.T',
                          schemas[0]['events'][0]['parameters'][1]['$ref'])