commands.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:vspheretools 作者: devopshq 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号