comparison WebServiceExtensionsV1.1/WebServiceToolWorkflow_REST_SOAP/clientGenerator/wsdl2path.py @ 0:049760c677de default tip

Galaxy WSExtensions added successfully
author uga-galaxy-group
date Tue, 05 Jul 2011 19:34:18 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:049760c677de
1 '''
2 @author Rui Wang
3 @see LICENSE (MIT style license file).
4 '''
5
6 import os
7 import sys;
8 from ZSI.generate.commands import wsdl2py
9
10 __author__="Rui Wang"
11
12 class wsdlLoader:
13 '''all methods to load wsdl from file/url'''
14
15 def wsdlUrl2path(self, url, folderName):
16 '''given wsdl url, folder name
17 create a folder under current directory,
18 invoke wsdl2py
19 return the path of generated python file by wsdl2py'''
20
21 path=os.path.join(os.getcwd(), folderName)
22 if not os.path.isdir(path):
23 os.mkdir(path)
24
25 fileOb=open(os.path.join(path,'__init__.py'), 'a')
26 fileOb.close()
27 wsdl2py([url, '-o', path]) #zsi 2.1
28 #wsdl2py(['-u',url, '-o', path]) #zsi 2.0
29
30 #get path required by creatorEngine.py, such as: blast.WSWUBlast_services, WSWUBlast_client
31 pyFileList=os.listdir(path)
32 for f in pyFileList:
33 if f.endswith('_client.py'): #zsi2.1
34 #if f.endswith('_services.py'): #zsi2.0
35 importPath=folderName+'.'+f[:-3]
36 break
37
38 return importPath
39
40 def wsdlFile2path(self, filePath, folderName):
41 '''given wsdl file path, folder name
42 create a folder under current directory,
43 invoke wsdl2py
44 return the path of generated python file by wsdl2py'''
45 path=os.path.join(os.getcwd(), folderName)
46 if not os.path.isdir(path):
47 os.mkdir(path)
48 else:
49 print 'Warning: writing files into an already existed path!!!!'
50
51 fileOb=open(os.path.join(path,'__init__.py'), 'a')
52 fileOb.close()
53 wsdl2py([filePath, '-o', path])
54 # wsdl2py(['-f',filePath, '-o', path])
55
56 #get path required by creatorengine.py, such as: blast.WSWUBlast_services
57 pyFileList=os.listdir(path)
58 for f in pyFileList:
59 #if f.endswith('_client.py'): #zsi2.1
60 if f.endswith('_services.py'): #zsi 2.0
61 importPath=folderName+'.'+f[:-3] # f[:-3] will take off the .py extention
62 break
63
64 return importPath
65
66 #testing this module
67 if __name__=="__main__":
68 test=wsdlLoader()
69 test.wsdlUrl2path('http://www.ebi.ac.uk/Tools/webservices/wsdl/WSWUBlast.wsdl','blast')
70 #print test.wsdlFile2path('..\\wsdl\\WSWUBlast.wsdl', 'blast')
71 # print test.wsdlFile2path('..\\wsdl\\picr.wsdl', 'picr')
72
73 # print test.wsdlFile2path('..\\wsdl\\WSDbfetch.wsdl', 'dbfetch')
74
75 # print test.wsdlFile2path('..\\wsdl\\NewGeneByLocation.wsdl', 'gbLocation')
76
77
78 #'http://www.ebi.ac.uk/Tools/webservices/wsdl/WSWUBlast.wsdl'
79 #'-u http://www.ebi.ac.uk/Tools/webservices/wsdl/WSDbfetch.wsdl'
80 #-o OUTPUT_DIR
81 #-b add convenience functions for complexTypes, including Getters, Setters, factory methods, and properties (via metaclass). *** DONT USE WITH --simple-naming