Esempio n. 1
0
    def getTypesModuleName(self):
        '''return module name.
        '''
        assert self.wsdl is not None, 'initialize, call fromWSDL'
        if self.types_module_name is not None:
            return self.types_module_name

        wsm = WriteServiceModule(self.wsdl)
        return wsm.getTypesModuleName()
Esempio n. 2
0
    def getTypesModuleName(self):
        '''return module name.
        '''
        assert self.wsdl is not None, 'initialize, call fromWSDL'
        if self.types_module_name is not None:
            return self.types_module_name

        wsm = WriteServiceModule(self.wsdl)
        return wsm.getTypesModuleName()
Esempio n. 3
0
def _wsdl2py(options, wsdl):

    if options.twisted:
        from pysphere.ZSI.generate.containers import ServiceHeaderContainer
        try:
            ServiceHeaderContainer.imports.remove(
                'from pysphere.ZSI import client')
        except ValueError:
            pass
        ServiceHeaderContainer.imports.append(
            'from pysphere.ZSI.twisted import client')

    if options.simple_naming:
        # Use a different client suffix
        # WriteServiceModule.client_module_suffix = "_client"
        # Write messages definitions to a separate file.
        #wsdl2pyServiceDescription.separate_messages = True
        # Use more simple type and element class names
        containers.SetTypeNameFunc(lambda n: '%s_' % (NC_to_CN(n)))
        containers.SetElementNameFunc(lambda n: '%s' % (NC_to_CN(n)))
        # Don't add "_" to the attribute name (remove when --aname works well)
        containers.ContainerBase.func_aname = lambda instnc, n: TextProtect(
            str(n))
        # write out the modules with their names rather than their number.
        utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(
            ns)

    files = []
    append = files.append
    if isinstance(wsdl, XMLSchema.XMLSchema):
        wsm = WriteServiceModule(_XMLSchemaAdapter(wsdl.location, wsdl),
                                 addressing=options.address)
    else:
        wsm = WriteServiceModule(wsdl, addressing=options.address)
        client_mod = wsm.getClientModuleName()
        client_file = join(options.output_dir, '%s.py' % client_mod)
        append(client_file)
        fd = open(client_file, 'w+')
        wsm.writeClient(fd)
        fd.close()

    types_mod = wsm.getTypesModuleName()
    types_file = join(options.output_dir, '%s.py' % types_mod)
    append(types_file)
    fd = open(types_file, 'w+')
    wsm.writeTypes(fd)
    fd.close()

    return files
Esempio n. 4
0
def GetPartsSubNames(args, wsdl):
    do_extended = True
    from pysphere.ZSI.generate.wsdl2python import WriteServiceModule, SchemaDescription
    wsm = WriteServiceModule(wsdl, do_extended=do_extended)
    wsm.gatherNamespaces()
    toReturn = []
    for arg in args:
        argSubnames = []
        for l in wsm.usedNamespaces.values():
            for schema in l:
                sd = SchemaDescription(do_extended=do_extended)
                sd.fromSchema(schema)
                argNamespace = arg.element[0]
                if (sd.targetNamespace == argNamespace):
                    for i in sd.items:
                        # arg.name is the part name, but we want it's type
                        argElementType = arg.element[1]
                        if str(argElementType) == str(i.content.name):
                            argSubnames = []
                # I'm not sure when the name attribute was dropped
                # but at some point, or in some circumstance it's not
                # there, but instead a ref attribute is there which is
                    # tuple of (namespace, name). This hack fixes things,
                # but I'm not sure why this happens or has happened.
                # IRJ - 2005-05-25
                            if i.content.mgContent != None:
                                for c in i.content.mgContent:
                                    nValue = "None"
                                    if c.isWildCard():
                                        nValue="any"
                                    elif "name" in c.attributes:
                                        nValue = c.attributes["name"]
                                    elif "ref" in c.attributes:
                                        nValue = c.attributes["ref"][1]
                                    argSubnames.append(nValue)

        toReturn.append(argSubnames)
    return toReturn
Esempio n. 5
0
def GetPartsSubNames(args, wsdl):
    do_extended = True
    from pysphere.ZSI.generate.wsdl2python import WriteServiceModule, SchemaDescription
    wsm = WriteServiceModule(wsdl, do_extended=do_extended)
    wsm.gatherNamespaces()
    toReturn = []
    for arg in args:
        argSubnames = []
        for l in wsm.usedNamespaces.itervalues():
            for schema in l:
                sd = SchemaDescription(do_extended=do_extended)
                sd.fromSchema(schema)
                argNamespace = arg.element[0]
                if (sd.targetNamespace == argNamespace):
                    for i in sd.items:
                        # arg.name is the part name, but we want it's type
                        argElementType = arg.element[1]
                        if str(argElementType) == str(i.content.name):
                            argSubnames = []
                            # I'm not sure when the name attribute was dropped
                            # but at some point, or in some circumstance it's not
                            # there, but instead a ref attribute is there which is
                            # tuple of (namespace, name). This hack fixes things,
                            # but I'm not sure why this happens or has happened.
                            # IRJ - 2005-05-25
                            if i.content.mgContent != None:
                                for c in i.content.mgContent:
                                    nValue = "None"
                                    if c.isWildCard():
                                        nValue = "any"
                                    elif "name" in c.attributes:
                                        nValue = c.attributes["name"]
                                    elif "ref" in c.attributes:
                                        nValue = c.attributes["ref"][1]
                                    argSubnames.append(nValue)

        toReturn.append(argSubnames)
    return toReturn
Esempio n. 6
0
def _wsdl2py(options, wsdl):

    if options.simple_naming:
        # Use a different client suffix
        # WriteServiceModule.client_module_suffix = "_client"
        # Write messages definitions to a separate file.
        #wsdl2pyServiceDescription.separate_messages = True
        # Use more simple type and element class names
        containers.SetTypeNameFunc( lambda n: '%s_' %(NC_to_CN(n)) )
        containers.SetElementNameFunc( lambda n: '%s' %(NC_to_CN(n)) )
        # Don't add "_" to the attribute name (remove when --aname works well)
        containers.ContainerBase.func_aname = lambda instnc,n: TextProtect(str(n))
        # write out the modules with their names rather than their number.
        utility.namespace_name = lambda cls, ns: utility.Namespace2ModuleName(ns)

    files = []
    append =  files.append
    if isinstance(wsdl, XMLSchema.XMLSchema):
        wsm = WriteServiceModule(_XMLSchemaAdapter(wsdl.location, wsdl),
                                 addressing=options.address)
    else:
        wsm = WriteServiceModule(wsdl, addressing=options.address)
        client_mod = wsm.getClientModuleName()
        client_file = join(options.output_dir, '%s.py' %client_mod)
        append(client_file)
        fd = open(client_file, 'w+')
        wsm.writeClient(fd)
        fd.close()

    types_mod = wsm.getTypesModuleName()
    types_file = join(options.output_dir, '%s.py' %types_mod)
    append(types_file)
    fd = open(types_file, 'w+' )
    wsm.writeTypes(fd)
    fd.close()

    return files