This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
armadillo_program_helper_test.py
389 lines (338 loc) · 11.8 KB
/
armadillo_program_helper_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
#!/usr/bin/python
"""
Title: Armadillo program helper
Author: JG
Date: fev 2017
Space used: 4
Variable: varName
Function: function_name()
Help: Given by args -h or -Help
Input: Yaml file with program information given by -y
Outputs:
- Properties file
- Program file
- Editor form file
- Editor java file
At the end if is test is used of the program, you will be able to export :
- programName.properties in armadillo/data/properties/
- programName.java in armadillo/src/programs/
- programNameEditors.java in armadillo/src/editors/
- programNameEditors.form in armadillo/src/editors/
For the editor, you will have to move buttons (reset,run,stop) to gets the right output (need to be fixed)
The explanation of yaml content is in this directory
Examples are available in the sub directory examples
"""
"""
TO DO :
- change OneConnectorOnlyFor and SolelyConnectors for true and false
- If isMenu is false, change button to box
- check if tooltype is added in editor form and file
- if imputs is empty
- Fixed to not move the buttons (reset/stop/run)
- Set selected in command
- Add other possibilities like list, textfield, directory files or file
- Add appication web services
- Check how inputs connector names are added in inputs
"""
import sys,os,getopt
import tarfile
import time
import yaml
import sub.util as u
import sub.test_yml as test
import sub.java_program as pgrm
import sub.java_properties as prop
import sub.java_file_editor as fileEdit
import sub.java_form_editor as formEdit
import os.path
author = "J-G"
date = (time.strftime("%d-%m-%Y"))
kword = "armadilloWF"
def main(argv):
inputFile = ''
isTest = False
try:
opts, args = getopt.getopt(argv,"hty:",["help"])
except getopt.GetoptError:
print_help()
sys.exit(2)
for opt, arg in opts:
if opt == '-h' or opt == '--help':
print_help()
sys.exit()
elif opt in ("-t"):
isTest = True
elif opt in ("-y"):
inputFile = arg
if inputFile == '':
inputFile = 'examples/repeatMasker.yml'
print 'WARNING =>\tThe file used will be '+inputFile
if os.path.isfile(inputFile):
yml = yaml.safe_load("")
with open(inputFile, 'r') as stream:
try:
yml = yaml.safe_load(stream)
print('loaded')
except yaml.YAMLError as exc:
print(exc)
if yml is not None:
# Add in yaml
yml['author'] = author
yml['date'] = date
yml['kword'] = kword
out = test.test_yml_file(yml)
if out == "":
isTest = True
u.update_command_opposites_names(yml)
pgrm.create_program_file(yml,isTest)
prop.create_properties_file(yml,isTest)
fileEdit.create_java_editor_file(yml,isTest)
formEdit.create_java_editor_form(yml,isTest)
print('created')
else:
print out
raise SystemExit
else:
print "File not found"
raise SystemExit
def print_help():
print ('armadillo_parser.py [options]\n'+
'[-h,--help]\tHelp\n'+
'[-t,--test]\tAs test\n'+
'[-y <input yanl file>]\tdirectory to yaml file\n')
if __name__ == '__main__':
if len(sys.argv)>1:
main (sys.argv[1:])
else:
print_help()
"""
u.update_command_opposites_names(yml)
pgrm.create_program_file(yml)
prop.create_properties_file(yml)
fileEdit.create_java_editor_file(yml)
formEdit.create_java_editor_form(yml)
for Panel in yml['Menus']:
if 'Panel' in Panel:
for Tab in Panel['Panel']:
if 'Arguments' in Tab:
print '>'+str(Tab['Arguments'])+'<\n'
yml['dicti'] = 'noone'
yml['dicti'] = {'noone':'coucou','prout':'zouzou'}
print yml['dicti']
for K in yml['dicti']:
print K
print yml['dicti'][K]
for Panel in yml['Menus']:
print "\t"+Panel['name']
if 'Panel' in Panel:
if len(yml['Menus'])>2: # Means need a tab
print("\ttab")
for Tab in Panel['Panel']:
print("\t\tlen(tab) "+str(len(Tab)))
print "\t\t"+Tab['tab']
print "\t\tlt"+str(len(Tab))
print "\t\tlp"+str(len(Panel['Panel']))
for Panel in yml['Menus']:
if 'Panel' in Panel:
for Tab in Panel['Panel']:
if 'Arguments' in Tab:
print '>'+str(Tab['Arguments'])+'<\n'
for commands in Tab['Arguments']:
if 'vValues' in commands['values']:
st = ', '.join(commands['values']['vValues'])
print '>'+st+'<\n'
print '>'+str(len(commands['values']['vValues']))+'<\n'
print '>'+str(commands['values']['vValues'])+'<\n'
#if commands['values']['vValues'] != None:
# print commands['values']['max']
for Panel in yml['Menus']:
print Panel['name']
if 'Panel' in Panel:
if len(yml['Menus'])>2: # Means need a tab
print("tab")
for Tab in Panel['Panel']:
print "\t"+Tab['tab']
print "lt"+str(len(Tab))
print "lp"+str(len(Panel['Panel']))
# if 'Arguments' in Tab:
# for commands in Tab['Arguments']:
# if 'vValues' in commands['values']:
# st = ', '.join(commands['values']['vValues'])
# print '>'+st+'<\n'
#if commands['values']['vValues'] != None:
# print commands['values']['max']
for Panel in yml['Menus']:
if 'Panel' in Panel:
tLength = len(Panel['Panel'])
print str(tLength)+"\n"
mLen = 7
boo = False
for x in range(0,mLen):
if mLen>1 and (mLen-x-1)%2==0 and mLen-x>1:
print 'group ('+str(x)
boo = True
if x%2 != 0 and mLen>1 :
print '\tadd gap'
boo = True
print '\t>Val start '+str(x)+''
if boo:
print '\t>Val middle'
print '\t>Val end'
if mLen>1 and (mLen-x-1)%2==1 and mLen-x>1:
print ')close group'
boo=False
for Panel in yml['Menus']:
pName = Panel['name']
if 'Panel' in Panel:
pLength = len(Panel['Panel'])
if pLength>2: # Means need a tabs
print "tabs level one finaly always here"
for Tab in Panel['Panel']:
if len(Tab)>1: # Means need a tabs
print "yes"
else:
print "non"
for op in yml['FrameDefaultVariables']:
print u.name_without_space(yml['FrameDefaultVariables'][op])
#pgrm.createProgramsFile(yml)
#prop.createPropertiesFile(yml)
y = 7
for x in range(0,y):
if x%2==0:
print '>GAPspace'
if y>1 and (y-x-1)%2==0 and y-x>1:
print 'group'+str(x)
if x%2 != 0 and y>1 : #:
print '>gap'
print '>'+str(x)+''
print yml['Program']
print "\n\n\n\n"
for Panel in yml['Docker']:
print Panel
#print Panel['dockerName']
u.get_color(yml)
print "\n\n\n\n"
# Set docker Name if empty
if not (yml['Docker']['dockerName']):
yml['Docker']['dockerName'] = u.set_docker_name(yml)
yml['FrameDefaultVariables'] = {
"boxName":"jTextField"
}
print 'no docker name'
#for paths in yml['Program']['Path']:
# print yml['Program']['Path'][paths]
if not (yml['Program']['publication']):
print 'no pub'
else:
print 'youy'
if (yml['Program']['publication']):
print yml['Program']['publication']
else:
print "COUC"
for Panel in yml['Menus']:
print Panel['name']
if 'Panel' in Panel:
for title in Panel['Panel']:
if 'Arguments' in title:
for commands in title['Arguments']:
if 'values' in Arguments and Arguments['values'] is not None:
#print commands['values']['default']
for values in commands['values']:
print values.val()
from sub.prgmInput import make_input
from sub.prgmOutput import make_output
from sub.docker import make_docker
from sub.program import make_program
from sub.command import make_command
from sub.menu import make_menu, make_titles
if yml['author']:
print (yml['author']+"\n"+
"hello")
if yml['Program']['name']:
print (yml['Program']['name'].replace (" ", "_"))
for Inputs in yml['Inputs']:
if Inputs['command2Call']:
print Inputs['command2Call']
else:
print 'command2Call is empty'
for Panel in yml['Menus']:
print Panel['name']
if 'Panel' in Panel:
if len(Panel)>1: # Means need a tab
print("tab")
for title in Panel['Panel']:
print "\t"+title['name']
if 'Arguments' in title:
if len(title)>1: # Means need a tab in a tab
print("tab-tab")
for commands in title['Arguments']:
if 'values' not in commands:
print "\t\t yes\n\n\n"
for x in range(0,mLen):
if mLen%2 != 0:
if mLen>1 and (mLen-x-1)%2==0 and mLen-x>1:
print 'group ('+str(x)
boo = True
if x%2 != 0 and mLen>1 :
print '\tadd gap'
boo = True
print '\t>Val start '+str(x)+''
if boo:
print '\t>Val middle'
print '\t>Val end'
if mLen>1 and (mLen-x-1)%2==1 and mLen-x>1:
print ')close group'
boo=False
if mLen%2 == 0:
if x%2 == 0:
print 'group ('+str(x)
boo = True
if x%2 != 0 and mLen>1 :
print '\tadd gap'
boo = True
print '\t>Val start '+str(x)+''
if boo:
print '\t>Val middle'
print '\t>Val end'
if x%2 != 0:
print ')close group'
boo=False
if mLen%2 != 0:
if x%2 == 0:
print '\tadd gap'
if mLen>1 and (mLen-x-1)%2==0 and mLen-x>1:
print 'group ('+str(x)
if x%2 != 0 and mLen>1 :
print '\tadd gap'
print '\t>Val end'
if mLen>1 and (mLen-x-1)%2==1 and mLen-x>1:
print ')close group'
if mLen%2 == 0:
if x%2 == 0:
print '\tadd gap'
print 'group ('+str(x)
if x%2 != 0 and mLen>1 :
print '\tadd gap'
print '\t>Val end'
if x%2 != 0:
print ')close group'
mLen = 5
boo = False
for x in range(0,mLen):
if mLen%2 != 0:
if mLen>1 and (mLen-x-1)%2==0 and mLen-x>1:
print 'group ('+str(x)
if x%2 != 0 and mLen>1 :
print '\tadd gap'
print '\t>Val end'
if mLen>1 and (mLen-x-1)%2==1 and mLen-x>1:
print ')close group'
if mLen%2 == 0:
if x%2==0:
print 'group ('+str(x)
print '\t>Val end'
if x%2 == 0 and mLen>1 :
print '\tadd gap'
if x%2 != 0:
print ')close group'
"""