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()
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
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