-
Notifications
You must be signed in to change notification settings - Fork 2
/
ns_l1_master_create.py
1770 lines (1504 loc) · 95.7 KB
/
ns_l1_master_create.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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'''
SPDX-License-Identifier: Apache-2.0
Copyright 2023 Cisco Systems, Inc. and its affiliates
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''
import tkinter as tk ,tkinter.ttk as ttk,tkinter.filedialog, tkinter.messagebox
from pptx import *
import sys, os, re
import numpy as np
import math
import ns_def
import openpyxl
class ns_l1_master_create():
def __init__(self):
'''parameter '''
flag_put_line_tag = True #Write Tag Name in <<POSITION_LINE>>
line_offset_value = 0.2 # in <<POSITION_LINE>> inches
wp_roundness = 0.5 # in <<STYLE_SHAPE>> 0.0-1.0 * 100(%)
wp_roundness_right_left = 0.2 # in <<STYLE_SHAPE>> 0.0-1.0 * 100(%) Ver2.0 add fix wp roundness when right or left pattern
shape_width_min = 0.5 # in <<STYLE_SHAPE>> inches
shape_hight_min = 0.2 # in <<STYLE_SHAPE>> inches
per_char_inchi = 0.16 # inches of per char count in shape
color_wp = 'BLUE' # in <<STYLE_SHAPE>> ORANGE , BLUE , GREEN ,GRAY, empty is ''
color_shape = 'GREEN' # in <<STYLE_SHAPE>> ORANGE , BLUE , GREEN ,GRAY, empty is ''
color_atmark = '' # in <<STYLE_SHAPE>> ORANGE , BLUE , GREEN ,GRAY, empty is ''
tag_offet_inche = 0.02 # in <<POSITION_TAG>> inches of per char count in shape
tag_name_prefix = 'GE 0/' # in <<POSITION_LINE>> TAG name prefix
port_name_prefix = 'GigabitEthernet' # in <<POSITION_LINE>> port name prefix
port_speed = 'Auto' # in <<POSITION_LINE>> port speed
port_duplex = 'Auto' # in <<POSITION_LINE>> port speed
port_type = '1000BASE-T' # in <<POSITION_LINE>> port speed
line_offset_ratio_wp = 3.0 # in <<POSITION_LINE>> increase ratio for WP , ver 1.12 reflect only up or down pattern
shape_hight_offset_inches_wp = 0.1 # in <<STYLE_SHAPE>> increase hight inches for WP , ver 1.12
self.shae_font_size = 6.0 #pt
'''
Create Excel file. And Write Template on Master_Data Sheet.
'''
### Define File path ###
if self.click_value == '92-3':
# check : file is being opened
if ns_def.check_file_open(str(self.inFileTxt_92_1.get()) + '__TMP__.xlsx') == True:
return ()
self.input_sketch_ppt = Presentation(self.inFileTxt_92_1.get())
self.output_diagram_path = str(self.inFileTxt_92_1.get()) + '__TMP__.pptx'
self.excel_file_path = self.inFileTxt_92_2.get()
elif self.click_value == '1-4a':
self.input_sketch_ppt = Presentation("./_tmp_tmp_tmp_.pptx")
self.output_diagram_path = self.outFileTxt_1a_1.get()
self.excel_file_path = self.outFileTxt_1a_2.get()
elif self.click_value == '1-4b':
self.input_sketch_ppt = Presentation("./_tmp_tmp_tmp_.pptx")
#self.output_diagram_path = self.outFileTxt_1b_1.get()
#self.excel_file_path = self.outFileTxt_1b_2.get()
else:
self.input_sketch_ppt = Presentation(self.inFileTxt_1_1.get())
self.output_diagram_path = self.outFileTxt_1_1.get()
self.excel_file_path = self.outFileTxt_1_2.get()
if self.click_value == '92-3' and self.click_value_2nd != 'self.sub1_1_button_3':
self.worksheet_name = 'Master_Data'
wb = openpyxl.load_workbook(self.excel_file_path)
del wb[self.worksheet_name]
wb.create_sheet(index=0, title=self.worksheet_name )
wb.save(self.excel_file_path)
elif self.click_value == '92-3' and self.click_value_2nd == 'self.sub1_1_button_3':
self.worksheet_name = 'Master_Data_tmp_'
wb = openpyxl.load_workbook(self.excel_file_path)
wb.create_sheet(index=0, title=self.worksheet_name )
wb.save(self.excel_file_path)
else:
### Create new data excel file
self.worksheet_name = 'Master_Data'
wb = openpyxl.Workbook()
sheet = wb.active
sheet.title = self.worksheet_name
wb.save(self.excel_file_path)
'''
Write Template on Master_Data Sheet
'''
tmp_master_data_array = []
tmp_master_data_array.append([1,['<<ROOT_FOLDER>>','Title Text','ratio_x(0.1-1.00)','ratio_y(0.1-1.00)','left(inches)','top(inches)','width(inches)','hight(inches)']])
tmp_master_data_array.append([4, ['<<POSITION_FOLDER>>']])
tmp_master_data_array.append([9, ['<<STYLE_FOLDER>>','Outline(YES/NO)','Text(NO/UP/DOWN)','Offset Upside Margin(<AUTO> or inches)','Offset Downside Margin(<AUTO> or inches)']])
tmp_master_data_array.append([10, ['<DEFAULT>','YES','N/A','N/A','N/A']])
tmp_master_data_array.append([11, ['<EMPTY>','NO','N/A','N/A','N/A']])
tmp_master_data_array.append([15, ['<<POSITION_SHAPE>>']])
tmp_master_data_array.append([19, ['<<STYLE_SHAPE>>','Width(Inches)','Hight(Inches)','Roundness(0.0-1.0)','Color(ORANGE/BLUE/GREEN/GRAY']])
tmp_master_data_array.append([20, ['<DEFAULT>','0.5','0.3','0','N/A']])
tmp_master_data_array.append([21, ['<EMPTY>','0.5','0.3','0','N/A']])
tmp_master_data_array.append([25, ['<<POSITION_LINE>>']])
tmp_master_data_array.append([26, ['From_Name','To_Name','From_Tag_Name','To_Tag_Name','From_Side(RIGHT/LEFT)','To_Side(RIGHT/LEFT)','Offset From_X (inches)','Offset From_Y (inches)','Offset To_X (inches)','Offset To_Y (inches)','Channel(inches)','Color(No) only)' \
,'From_Port_Name','From_Speed','From_Duplex','From_Port_Type','To__Port_Name','To_Speed','To_From_Duplex','To_From_Port_Type']])
tmp_master_data_array.append([30, ['<<POSITION_TAG>>','Type(SHAPE/LINE)','Offset_SHAPE_X','Offset_SHAPE_Y','Offset_LINE(inches)','Adjust_LINE_Angle(YES/NO)']])
tmp_master_data_array.append([31, ['<DEFAULT>','SHAPE','0','0','0.3','YES']])
#print(tmp_master_data_array)
template_master_data_tuple = {}
template_master_data_tuple = ns_def.convert_array_to_tuple(tmp_master_data_array)
#print('Create --- template_master_data_tuple---')
#print(template_master_data_tuple)
offset_row = 0
offset_column = 0
write_to_section = '_template_'
ns_def.write_excel_meta(template_master_data_tuple, self.excel_file_path, self.worksheet_name, write_to_section, offset_row, offset_column)
'''
MAIN RUN
'''
# get number of slides
for idx, slide in enumerate(self.input_sketch_ppt.slides):
num_slide = idx + 1
print('---- number of slides %d ----' % num_slide)
# get shapes folder waypoint
tmp_shape_array = []
master_shape_array = []
folder_array = []
wp_array = []
tmp_line_array = []
line_array = []
exclude_folder_array = []
tmp_shp = 0
x_grid = 0
y_grid = 0
icon_num = 1
for i, sld in enumerate(self.input_sketch_ppt.slides, start=1):
#print(f'-- {i} --')
current_folder_size = 0
second_folder_size = 0 # multiple area check. add at ver 2.2.2(b)
for shp in sld.shapes:
### GET Group(Icons),Picture and icon # Add Ver 1.1
if 'GROUP' in str(shp.shape_type) or 'PICTURE' in str(shp.shape_type) :
tmp_shape_array.append(['@Icon@~'+str(icon_num)+'~', shp.left, shp.top, shp.width, shp.height, shp.rotation, i])
tmp_shp += 1
icon_num += 1
### GET Line ( connector )
if 'LINE' in str(shp.shape_type):
tmp_line_array.append([shp.begin_x, shp.begin_y, shp.end_x, shp.end_y, i])
line_array.append([shp.begin_x, shp.begin_y, shp.end_x, shp.end_y, i])
### GET Shape
if 'AUTO_SHAPE' in str(shp.shape_type) and str(shp.text) != '':
# check updated device '/n' and append array ver 1.1
if '\n' in str(shp.text):
idx = str(shp.text).find('\n')
self.updated_name_array.append([str(shp.text)[:idx],str(shp.text)[idx + 1:] ])
tmp_shape_array.append([str(shp.text)[idx + 1:], shp.left, shp.top, shp.width, shp.height, shp.rotation, i ])
else:
tmp_shape_array.append([shp.text, shp.left, shp.top, shp.width, shp.height, shp.rotation, i])
### Add multiple _AIR_ # Add Ver 1.11
if '_AIR_' in str(shp.text):
tmp_air = str(shp.text).replace('_AIR_','')
if tmp_air.isdigit() == True:
#print('### Add multiple _AIR_###')
tmp_air = int(tmp_air) - 1
for tmp_air_num in range(tmp_air):
tmp_shape_array.append([shp.text, shp.left + tmp_air_num , shp.top, shp.width, shp.height, shp.rotation, i])
tmp_shp += 1
'''Elect Folder array '''
if current_folder_size < (shp.width * shp.height):
current_folder_size = shp.width * shp.height
current_folder_array = tmp_shape_array[tmp_shp-1]
elif second_folder_size < (shp.width * shp.height): # multiple area check. add at ver 2.2.2(b)
second_folder_size = shp.width * shp.height
second_folder_array = tmp_shape_array[tmp_shp - 1]
### add root folder if there is not root folder. Add ver 1.11
tmp_count_include_shape = 0
tmp_count_include_shape_second = 0
for tmp_check_shape in tmp_shape_array:
if current_folder_array[1] < tmp_check_shape[1] and current_folder_array[2] < tmp_check_shape[2] and \
(current_folder_array[1] + current_folder_array[3]) > (tmp_check_shape[1] + tmp_check_shape[3]) and \
(current_folder_array[2] + current_folder_array[4]) > (tmp_check_shape[2] + tmp_check_shape[4]):
tmp_count_include_shape += 1
#print(current_folder_array,tmp_check_shape)
for tmp_check_shape in tmp_shape_array: # multiple area check. add at ver 2.2.2(b)
if second_folder_array[1] < tmp_check_shape[1] and second_folder_array[2] < tmp_check_shape[2] and \
(second_folder_array[1] + second_folder_array[3]) > (
tmp_check_shape[1] + tmp_check_shape[3]) and \
(second_folder_array[2] + second_folder_array[4]) > (
tmp_check_shape[2] + tmp_check_shape[4]):
tmp_count_include_shape_second += 1
# print(second_folder_array,tmp_check_shape)
#print('---tmp_count_include_shape--- \n', tmp_count_include_shape)
if tmp_count_include_shape != 0 and tmp_count_include_shape_second !=0: # multiple area check. add at ver 2.2.2(b)
tkinter.messagebox.showwarning("Warning","Only one area is allowed per page.")
if tmp_count_include_shape == 0:
tmp_shape_array.append(['_tmp_', 1, 1, 999999999999, 999999999999, 0.0, i])
current_folder_array = ['_tmp_','_tmp_', 1, 1, 999999999999, 999999999999, 0.0, i]
'''### duplicate folder name check ###''' #update ver 1.1
duplicate_num = 1
if str(current_folder_array[0])[-1] == "~":
p = r'\~.*\~'
r = re.findall(p, str(current_folder_array[0]))
r = re.sub("\[\'\~", "", str(r))
r = re.sub("\~\'\]", "", str(r))
if r.isdecimal() == True and current_folder_array[0] not in exclude_folder_array:
exclude_folder_array.append(current_folder_array[0])
#print(exclude_folder_array)
for tmp_tmp_array in folder_array:
if current_folder_array[0] == tmp_tmp_array[0]:
flag_num = True
while flag_num == True:
if str(current_folder_array[0]) + '~' + str(duplicate_num) + '~' in exclude_folder_array and '~' not in str(current_folder_array[0]):
duplicate_num += 1
else:
#print('current_folder_array[0] ',current_folder_array[0])
flag_num = False
current_folder_array[0]= str(current_folder_array[0]) + '~' + str(duplicate_num) + '~'
exclude_folder_array.append(current_folder_array[0])
duplicate_num += 1
folder_array.append(current_folder_array)
### insert Folder name ####
for tmp_shape in tmp_shape_array:
tmp_shape.insert(0,current_folder_array[0])
master_shape_array.append(tmp_shape)
tmp_shape_array = []
tmp_line_array = []
tmp_shp = 0
### Elect Way Point array ###
for tmp_folder in folder_array:
for tmp_master in master_shape_array:
if tmp_folder[0] == tmp_master[0]:
if tmp_master[3] < tmp_folder[3]:
wp_array.append([tmp_master[0], tmp_master[1], 'UP'])
elif (tmp_master[3]+tmp_master[5]) > (tmp_folder[3]+tmp_folder[5]):
wp_array.append([tmp_master[0], tmp_master[1], 'DOWN'])
elif tmp_master[2] < tmp_folder[2]:
wp_array.append([tmp_master[0], tmp_master[1], 'LEFT'])
elif (tmp_master[2]+tmp_master[4]) > (tmp_folder[2]+tmp_folder[4]):
wp_array.append([tmp_master[0], tmp_master[1], 'RIGHT'])
#print('master_shape_array ',master_shape_array)
### MAKE Shape array ###
pre_shape_array = []
for tmp_shape in master_shape_array:
tmp_include_bit = False
# exclude folder and way point
for tmp_folder in folder_array:
if tmp_shape[1] == tmp_folder[1]:
tmp_include_bit = True
for tmp_wp in wp_array:
if tmp_shape[1] == tmp_wp[1]:
tmp_include_bit = True
if tmp_include_bit == False:
pre_shape_array.append(tmp_shape)
'''duplicate shape name check''' # update ver 1.1
shape_array = []
duplicate_num = 1
#print('---pre_shape_array--- \n',pre_shape_array)
# check include '~' and get exclude_pre_shape_array
exclude_pre_shape_array = []
for tmp_exclude_array in pre_shape_array:
if str(tmp_exclude_array[1])[-1] == "~" and "~" in str(tmp_exclude_array[1]) :
p = r'\~.*\~'
r = re.findall(p, str(tmp_exclude_array[1]))
r = re.sub("\[\'\~", "", str(r))
r = re.sub("\~\'\]", "", str(r))
if r.isdecimal() == True:
exclude_pre_shape_array.append(tmp_exclude_array[1])
#print(exclude_pre_shape_array)
# check duplicate
for tmp_array in pre_shape_array:
tmp_count = 0
last_array = tmp_array
for tmp_tmp_array in pre_shape_array:
if tmp_array[1] == tmp_tmp_array[1] and "~" not in str(tmp_array[1]):
tmp_count += 1
if tmp_count >= 2:
flag_num = True
while flag_num == True:
if str(tmp_array[1]) + '~' + str(duplicate_num) + '~' in exclude_pre_shape_array:
duplicate_num += 1
else:
flag_num = False
tmp_array[1] = str(tmp_array[1]) + '~' + str(duplicate_num) + '~'
exclude_pre_shape_array.append(tmp_array[1])
duplicate_num += 1
last_array = tmp_array
duplicate_num = 1
shape_array.append(last_array)
print('-- master_shape_array --')
#print(master_shape_array)
print('-- shape_array --')
#print(shape_array)
print('-- line_array --')
#print(line_array)
print('-- folder_array --')
#print(folder_array)
print('-- wp_array --')
#print(wp_array)
### Add Way Point to Folder array ###
new_wp_array = wp_array
new_folder_wp_array =[]
tmp_up_flag = ''
tmp_down_flag = ''
tmp_right_flag = ''
tmp_left_flag = ''
for tmp_folder in folder_array:
for tmp_wp_array in new_wp_array:
if tmp_folder[0] == tmp_wp_array[0]:
if tmp_wp_array[2] == 'UP':
tmp_up_flag = tmp_wp_array[1]
elif tmp_wp_array[2] == 'DOWN':
tmp_down_flag = tmp_wp_array[1]
elif tmp_wp_array[2] == 'LEFT':
tmp_left_flag = tmp_wp_array[1]
elif tmp_wp_array[2] == 'RIGHT':
tmp_right_flag = tmp_wp_array[1]
new_folder_wp_array.append([tmp_folder[0],tmp_up_flag,tmp_down_flag,tmp_left_flag,tmp_right_flag,x_grid, y_grid])
x_grid += 1
tmp_up_flag = ''
tmp_down_flag = ''
tmp_right_flag = ''
tmp_left_flag = ''
print('-- new_folder_wp_array --')
#print(new_folder_wp_array)
''' add connected way point'''
up_flag = ''
down_flag = ''
left_flag = ''
right_flag = ''
connect_folder_wp_array = []
for tmp_folder in new_folder_wp_array:
for tmp_tmp_folder in new_folder_wp_array:
if tmp_folder[1] == tmp_tmp_folder[2]:
up_flag = tmp_folder[1]
if tmp_folder[2] == tmp_tmp_folder[1]:
down_flag = tmp_folder[2]
if tmp_folder[3] == tmp_tmp_folder[4]:
left_flag = tmp_folder[3]
if tmp_folder[4] == tmp_tmp_folder[3]:
right_flag = tmp_folder[4]
tmp_array= []
tmp_array.append(tmp_folder[0])
if up_flag != '':
tmp_array.append(up_flag)
else:
tmp_array.append('')
if down_flag != '':
tmp_array.append(down_flag)
else:
tmp_array.append('')
if left_flag != '':
tmp_array.append(left_flag)
else:
tmp_array.append('')
if right_flag != '':
tmp_array.append(right_flag)
else:
tmp_array.append('')
up_flag = ''
down_flag = ''
left_flag = ''
right_flag = ''
connect_folder_wp_array.append(tmp_array)
print('--connect_folder_wp_array--')
#print(connect_folder_wp_array)
''' grouping x grid folder'''
### pre Kyuusai ###
kyusai_a = []
kyusai_b = []
for tmp_folder in connect_folder_wp_array:
if str(tmp_folder[3]) != '' and str(tmp_folder[4]) == '':
kyusai_b.append(tmp_folder)
else:
kyusai_a.append(tmp_folder)
for tmp_folder in kyusai_b:
kyusai_a.append(tmp_folder)
connect_folder_wp_array = kyusai_a
tmp_array = []
group_folder_wp_array = []
for tmp_folder in connect_folder_wp_array:
if tmp_folder[4] != '':
for tmp_tmp_folder in connect_folder_wp_array:
if tmp_folder[4] == tmp_tmp_folder[3]:
if str(tmp_folder) in str(group_folder_wp_array) or str(tmp_tmp_folder) in str(group_folder_wp_array):
if str(tmp_folder) in str(group_folder_wp_array):
new_tmp_folder = tmp_folder
else:
new_tmp_folder = tmp_tmp_folder
ii = len(group_folder_wp_array)
for iii in range(ii):
if new_tmp_folder in group_folder_wp_array[iii]:
iiii = iii
n = len(group_folder_wp_array[iiii])
for nn in range(n-1):
if new_tmp_folder == group_folder_wp_array[iiii][nn]:
if nn == 0:
if str(tmp_folder) not in str(group_folder_wp_array[iiii]):
group_folder_wp_array[iiii].insert(0,tmp_folder)
else:
if str(tmp_tmp_folder) not in str(group_folder_wp_array[iiii]):
group_folder_wp_array[iiii].append(tmp_tmp_folder)
else:
tmp_array.append(tmp_folder)
tmp_array.append(tmp_tmp_folder)
if tmp_array != []:
group_folder_wp_array.append(tmp_array)
tmp_array = []
elif tmp_folder[3] == '':
group_folder_wp_array.append(tmp_folder)
else:
### Kyuusai-2 ###
if str(tmp_folder) not in str(group_folder_wp_array):
#print('--- Kyusai-2 --- ', tmp_folder,group_folder_wp_array)
tmp_i = 0
for tmp_folder2 in group_folder_wp_array:
if str(tmp_folder[3]+'\''+']]') in str(tmp_folder2):
break
tmp_i += 1
group_folder_wp_array[tmp_i].append(tmp_folder)
print('--group_folder_wp_array--')
#print(group_folder_wp_array)
''' set y grid folder'''
num_folder_group = len(group_folder_wp_array)
y_num_array = []
for i in range(num_folder_group):
y_num_array.append(1)
#add [] to single folder group
new_group_folder_array = []
for tmp_num_folder in group_folder_wp_array:
if ']]' not in str(tmp_num_folder):
#single folder
test_folder = []
test_folder.append(tmp_num_folder)
new_group_folder_array.append(test_folder)
else:
new_group_folder_array.append(tmp_num_folder)
print('--new_group_folder_array , add [] to single folder-')
#print(new_group_folder_array)
# change Y grid of y_num_array
print(' -- move each group to downside - ')
change_bit = True
first_change_bit = True
max_y_grid = 1
while change_bit == True:
pre_y_num_array = y_num_array
for b in range(len(new_group_folder_array)):
for i in range(len(new_group_folder_array[b])):
for bb in range(len(new_group_folder_array)):
for ii in range(len(new_group_folder_array[bb])):
#print(new_group_folder_array[b][i],new_group_folder_array[bb][ii],new_group_folder_array[b][i][2],new_group_folder_array[bb][ii][1],new_group_folder_array[b][i][2],y_num_array[b] , y_num_array[bb])
if new_group_folder_array[b][i] != new_group_folder_array[bb][ii] and new_group_folder_array[b][i][2] == new_group_folder_array[bb][ii][1] \
and new_group_folder_array[b][i][2] != '' and y_num_array[b] >= y_num_array[bb]:
y_num_array[bb] += 1
if y_num_array[bb] > max_y_grid:
max_y_grid = y_num_array[bb]
first_change_bit = True
#print(y_num_array)
'''a group which does not have UP and Down move to max downside'''
if new_group_folder_array[bb][ii][1] == '' and new_group_folder_array[bb][ii][2] == '' and max_y_grid >= y_num_array[bb]:
if new_group_folder_array[bb][ii][3] != '' and new_group_folder_array[bb][ii][4] != '': ## bug fix at ver 2.3.1(b)
y_num_array[bb] = max_y_grid + 1
first_change_bit = True
if len(y_num_array) == 1:
y_num_array[bb] = max_y_grid + 1
first_change_bit = True
if pre_y_num_array == y_num_array:
if first_change_bit == True:
first_change_bit = False
else:
change_bit = False
'''shapes convert to excel'''
y_num_bit = True
y_num_start = 1
update_group_folder_array = []
while y_num_bit == True:
y_num_current = -1
for tmp_yum in y_num_array:
y_num_current +=1
if tmp_yum == y_num_start or len(new_group_folder_array) == 1:
update_group_folder_array.append([new_group_folder_array[y_num_current] , tmp_yum])
y_num_start +=1
if y_num_start-1 == len(y_num_array):
y_num_bit = False
print(' -- Update group folder array for Excel position -- ')
#print(update_group_folder_array)
'''
make excel format
'''
# merge merge_group_folder_array <-- update_group_folder_array
folder_name_of_wp = [] # for put wp shapes in own wp folder
merge_group_folder_array = update_group_folder_array
for i in range(len(update_group_folder_array)):
for ii in range(len(update_group_folder_array[i][0])):
for tmp_new_folder_wp_array in new_folder_wp_array:
if update_group_folder_array[i][0][ii][0] == tmp_new_folder_wp_array[0]:
if tmp_new_folder_wp_array[1] != '':
merge_group_folder_array[i][0][ii][1] = tmp_new_folder_wp_array[1] + '_wp_'
if tmp_new_folder_wp_array[2] != '':
merge_group_folder_array[i][0][ii][2] = tmp_new_folder_wp_array[2] + '_wp_'
if tmp_new_folder_wp_array[3] != '':
merge_group_folder_array[i][0][ii][3] = tmp_new_folder_wp_array[3] + '_wp_'
if tmp_new_folder_wp_array[4] != '':
merge_group_folder_array[i][0][ii][4] = tmp_new_folder_wp_array[4] + '_wp_'
break
print(' -- merge_group_folder_array -- ')
#print(merge_group_folder_array)
#Line up shapes
row = 2 # Excel row
column = 2 # Excel column
offset_row = 0
offset_column =0
master_folder_tuple = {} # After this process, write the meta data to excel
max_num_y_grid = merge_group_folder_array[-1][1]
current_y_grid = 0
pre_y_num = merge_group_folder_array[0][1]
flag_sigle_y_num = True
flag_one_only = True
for cur_merge_group_folder_array in merge_group_folder_array:
if pre_y_num != cur_merge_group_folder_array[1]:
flag_sigle_y_num = False
#break
if cur_merge_group_folder_array[1] != pre_y_num: #add at ver 2.3.1(b)
flag_one_only = False
if flag_sigle_y_num == True:
if flag_one_only == True and len(merge_group_folder_array) == 1: #add at ver 2.3.1(b)
row -= 4
''' make master_folder_tuple'''
flag_first_shape = True
for i in range(1,max_num_y_grid+1):
print('---- Y Grid %d ---- ' % i)
flag_up_wp = False
flag_down_wp = False
flag_left_wp = False
current_y_grid += 1
# Check up flag and left and down flag
for tmp_array in merge_group_folder_array:
if tmp_array[1] == i:
for tmp_tmp_array in tmp_array[0]:
#check up or left side WP
if tmp_tmp_array[1] != '':
flag_up_wp = True
if tmp_tmp_array[2] != '':
flag_down_wp = True
if column == 2 and tmp_tmp_array[3] != '':
flag_left_wp = True
# kyusai Y
if flag_up_wp == False and i == 1:
flag_first_y_up = True
else:
flag_first_y_up = False
#print('Flag | UP DOWN LEFT |',flag_up_wp,flag_down_wp,flag_left_wp )
### adjust pre down flag ###
if i >=2:
if pre_flag_down_wp == False and flag_up_wp == False and flag_sigle_y_num == False:
## insert empty folder between folders that do not connect
master_folder_tuple[row + 1 -2 , 1] = '<SET_WIDTH>'
master_folder_tuple[row + 1 -2 , 2] = 10
master_folder_tuple[row + 2 -2 , 1] = 1
# kyusai y grid == 1
if flag_down_wp == False and flag_up_wp == False and flag_sigle_y_num == True:
row -= 1
if flag_down_wp == True and flag_up_wp == False and flag_sigle_y_num == True:
row -= 1
# make excel meta
flag_row_column_2_2 = False ### bug fix 001 ###
#flag_row_column_onetime = False ### bug fix 001 ###
flag_check_leftup_wp = False ### bug fix 001 ###
flag_check_leftup_wp_end = False ### bug fix 001 ###
for tmp_array in merge_group_folder_array:
write_up_wp = False
if tmp_array[1] == current_y_grid:
for tmp_tmp_array in tmp_array[0]:
# check the same wp on upside
if flag_row_column_2_2 == True: ### bug fix 001 ###
master_folder_tuple[row - 1, column] = 0.999 ### bug fix 001 ###
if flag_up_wp == True and tmp_tmp_array[1] != '':
tmp_i = 0
flag_write_up_wp = False
for num_wp_up in master_folder_tuple:
if num_wp_up[0] == row:
tmp_i += 1
if tmp_tmp_array[1] == master_folder_tuple[num_wp_up] and tmp_tmp_array[1] != '':
flag_write_up_wp = True
if flag_write_up_wp == True:
write_up_wp = False
else:
write_up_wp = True
if write_up_wp == True and flag_check_leftup_wp == False:
### bug fix 001
if row == 2 and column == 6:
column -= 1
flag_check_leftup_wp = True
master_folder_tuple[row, column] = tmp_tmp_array[1]
master_folder_tuple[row - 1, column] = 10
folder_name_of_wp.append(tmp_tmp_array[1])
#print(row, column,tmp_tmp_array[1])
### bug fix 001 ###
if row == 2 and column == 2:
flag_row_column_2_2 = True
master_folder_tuple[row, column - 1] = 10
# check previous right side
flag_previous_right_side = False
for check_right in master_folder_tuple:
if check_right == (row + 2, column):
flag_previous_right_side = True
if flag_previous_right_side == True:
add_x = 1
else:
add_x = 0
### check left side and wirte
if tmp_tmp_array[3] != '' or column == 2:
if write_up_wp == True and tmp_tmp_array[3] != '' and column != 3:
if flag_check_leftup_wp == False and (tmp_tmp_array[1] == '' or tmp_tmp_array[3] == ''): ### bug fix 001
column -= 1 ### bug fix 001
master_folder_tuple[row + 1, 1] = '<SET_WIDTH>'
master_folder_tuple[row + 2, 1] = 10
master_folder_tuple[row + 1, column + add_x] = 10
master_folder_tuple[row + 1, column + 1 + add_x] = 10
master_folder_tuple[row + 2, column + add_x] = tmp_tmp_array[3]
master_folder_tuple[row + 2, column + 1 + add_x] = tmp_tmp_array[0]
folder_name_of_wp.append(tmp_tmp_array[3])
if flag_row_column_2_2 == True and row == 2 and column == 2: ### bug fix 001 ###
master_folder_tuple[row - 1, column + 1] = 0.999 ### bug fix 001 ###
# kyusai y grid == 1
elif write_up_wp == False and tmp_tmp_array[3] != '' and column == 2:
master_folder_tuple[row + 1, 1] = '<SET_WIDTH>'
master_folder_tuple[row + 2, 1] = 10
master_folder_tuple[row + 1, column + add_x] = 10
master_folder_tuple[row + 1, column + 1 + add_x] = 10
master_folder_tuple[row + 2, column + add_x] = tmp_tmp_array[3]
master_folder_tuple[row + 2, column + 1 + add_x] = tmp_tmp_array[0]
folder_name_of_wp.append(tmp_tmp_array[3])
# kyusai y grid == 1
elif write_up_wp == False and flag_down_wp == True and tmp_tmp_array[3] == '' and column == 2 and flag_first_shape == True and flag_first_y_up == True:
if flag_first_shape == True:
row -= 1
flag_first_shape = False
master_folder_tuple[row + 1, 1] = '<SET_WIDTH>'
master_folder_tuple[row + 2, 1] = 10
master_folder_tuple[row + 1, column + add_x] = 10
master_folder_tuple[row + 2, column + add_x] = tmp_tmp_array[3]
master_folder_tuple[row + 2, column + add_x] = tmp_tmp_array[0]
folder_name_of_wp.append(tmp_tmp_array[3])
else:
master_folder_tuple[row + 1, 1] = '<SET_WIDTH>'
master_folder_tuple[row + 2, 1] = 10
master_folder_tuple[row + 1, column + add_x] = 10
master_folder_tuple[row + 2, column + add_x] = tmp_tmp_array[0]
if flag_row_column_2_2 == True and column != 2: ### bug fix 001 ###
master_folder_tuple[row - 1, column + add_x] = 0.999 ### bug fix 001 ###
else:
master_folder_tuple[row + 1, column + add_x] = 1
master_folder_tuple[row + 2, column + add_x] = ''
master_folder_tuple[row + 1, column + add_x + 1] = 10
master_folder_tuple[row + 2, column + add_x + 1] = tmp_tmp_array[0]
#if there is right wp
if tmp_tmp_array[4] != '':
if tmp_tmp_array[3] != '':
master_folder_tuple[row + 1, column + 2] = 10
master_folder_tuple[row + 2, column + 2] = tmp_tmp_array[4]
folder_name_of_wp.append(tmp_tmp_array[4])
else:
master_folder_tuple[row + 1, column + 1] = 10
master_folder_tuple[row + 2, column + 1] = tmp_tmp_array[4]
folder_name_of_wp.append(tmp_tmp_array[4])
#if there is down wp
if flag_down_wp == True and tmp_tmp_array[2] != '':
#check the same wp on downside
tmp_i = 0
write_down_wp = True
for num_wp_down in master_folder_tuple:
if num_wp_down[0] == row +4:
tmp_i += 1
if tmp_tmp_array[2] == master_folder_tuple[num_wp_down] and tmp_tmp_array[2] != '':
write_down_wp = False
if write_down_wp == True:
master_folder_tuple[row + 4, column] = tmp_tmp_array[2]
master_folder_tuple[row + 3, column] = 10
master_folder_tuple[row + 3, 1] = '<SET_WIDTH>'
master_folder_tuple[row + 4, 1] = 10
folder_name_of_wp.append(tmp_tmp_array[2])
#print(row + 4, column, tmp_tmp_array[2])
#column move to right side
if tmp_tmp_array[3] != '':
column += 1
if tmp_tmp_array[3] == '' and flag_previous_right_side == True:
column += 1
column += 1
row += 4
column = 2
## previsious down flag ##
pre_flag_down_wp = flag_down_wp
print(' -- master_folder_tuple <<POSITION_FOLDER>> -- ')
#print(master_folder_tuple)
'''bug fix 001, put 0.999 on empty cell(width)'''
master_folder_tuple[1, 1] = '<<POSITION_FOLDER>>'
bug_fix_master_folder_tuple = master_folder_tuple
tmp_add_tuple = {}
for tmp_bug_fix_master_folder_tuple in bug_fix_master_folder_tuple:
if tmp_bug_fix_master_folder_tuple[1] == 1 and (bug_fix_master_folder_tuple[tmp_bug_fix_master_folder_tuple] == '<<POSITION_FOLDER>>' or bug_fix_master_folder_tuple[tmp_bug_fix_master_folder_tuple] == '<SET_WIDTH>'):
#print(bug_fix_master_folder_tuple[tmp_bug_fix_master_folder_tuple])
tmp_num_max_bug_fix_column = 1
for tmp_tmp_bug_fix_master_folder_tuple in bug_fix_master_folder_tuple:
if tmp_tmp_bug_fix_master_folder_tuple[0] == tmp_bug_fix_master_folder_tuple[0]:
if tmp_num_max_bug_fix_column < tmp_tmp_bug_fix_master_folder_tuple[1]:
tmp_num_max_bug_fix_column = tmp_tmp_bug_fix_master_folder_tuple[1]
#print(tmp_num_max_bug_fix_column)
for tmp_num in range(2, tmp_num_max_bug_fix_column):
flag_tuple_exist = False
for tmp_tmp_bug_fix_master_folder_tuple in bug_fix_master_folder_tuple:
if tmp_tmp_bug_fix_master_folder_tuple[0] == tmp_bug_fix_master_folder_tuple[0] and tmp_tmp_bug_fix_master_folder_tuple[1] == tmp_num:
flag_tuple_exist = True
if flag_tuple_exist == False:
#print('### put 0.999 ###')
#print(tmp_bug_fix_master_folder_tuple[0],tmp_num)
tmp_add_tuple[tmp_bug_fix_master_folder_tuple[0],tmp_num] = 0.999
for tmp_tmp_add_tuple in tmp_add_tuple:
master_folder_tuple[tmp_tmp_add_tuple] = tmp_add_tuple[tmp_tmp_add_tuple]
### sort master_folder_tuple ###
sort_master_folder_tuple = sorted(master_folder_tuple)
#print('--- sort_master_folder_tuple --- \n',sort_master_folder_tuple)
i_master_folder_tuple = {}
flag_exist_2_1 = False
for tmp_sort_master_folder_tuple in sort_master_folder_tuple:
if master_folder_tuple[tmp_sort_master_folder_tuple] != '<<POSITION_FOLDER>>':
i_master_folder_tuple[tmp_sort_master_folder_tuple] = master_folder_tuple[tmp_sort_master_folder_tuple]
if tmp_sort_master_folder_tuple[0] == 2 and tmp_sort_master_folder_tuple[1] == 1:
flag_exist_2_1 = True
### kyusai bug fix 001 , add 10 to 2,1 in master_folder_tuple
if flag_exist_2_1 == False:
i_master_folder_tuple[2,1] = 10
#print('--- i_master_folder_tuple --- \n', i_master_folder_tuple)
### remove 0.999 in i_master_folder_tuple ###
tmp_change_column = 1
tmp_i_current_row = 1
flag_previous_three_nine = False
master_folder_tuple = {}
used_master_folder_tuple = {}
tmp_offset_column = 0
for tmp_i_master_folder_tuple in i_master_folder_tuple:
if tmp_i_master_folder_tuple[0] == 1 or i_master_folder_tuple[tmp_i_master_folder_tuple[0],1] == '<SET_WIDTH>':
if tmp_i_current_row != tmp_i_master_folder_tuple[0]:
tmp_change_column = 1
flag_previous_three_nine = False
tmp_offset_column = 0
tmp_i_current_row = tmp_i_master_folder_tuple[0]
flag_used_folder = False
for tmp_used_master_folder_tuple in used_master_folder_tuple:
if tmp_i_master_folder_tuple == tmp_used_master_folder_tuple:
flag_used_folder = True
if i_master_folder_tuple[tmp_i_master_folder_tuple] == 0.999 and flag_previous_three_nine == False:
tmp_change_column = tmp_i_master_folder_tuple[1]
flag_previous_three_nine = True
elif i_master_folder_tuple[tmp_i_master_folder_tuple] != 0.999 and flag_previous_three_nine == True and flag_used_folder == False:
master_folder_tuple[tmp_i_master_folder_tuple[0],tmp_change_column + tmp_offset_column] = i_master_folder_tuple[tmp_i_master_folder_tuple]
master_folder_tuple[tmp_i_master_folder_tuple[0] + 1, tmp_change_column + tmp_offset_column] = i_master_folder_tuple[tmp_i_master_folder_tuple[0] + 1 , tmp_i_master_folder_tuple[1]]
used_master_folder_tuple[tmp_i_master_folder_tuple] = i_master_folder_tuple[tmp_i_master_folder_tuple]
used_master_folder_tuple[tmp_i_master_folder_tuple[0] + 1,tmp_i_master_folder_tuple[1]] = i_master_folder_tuple[tmp_i_master_folder_tuple[0] + 1,tmp_i_master_folder_tuple[1]]
tmp_change_column = 1
flag_previous_three_nine = False
tmp_offset_column = tmp_offset_column - ( tmp_i_master_folder_tuple[1] - tmp_change_column)
#print(tmp_i_master_folder_tuple,used_master_folder_tuple)
elif flag_used_folder == False and i_master_folder_tuple[tmp_i_master_folder_tuple] != 0.999:
master_folder_tuple[tmp_i_master_folder_tuple[0] + tmp_offset_column ,tmp_i_master_folder_tuple[1]] = i_master_folder_tuple[tmp_i_master_folder_tuple]
flag_exist_plus_one_row = False
for tmp_ii_master_folder_tuple in i_master_folder_tuple:
if tmp_ii_master_folder_tuple[0] == tmp_i_master_folder_tuple[0] + 1 and tmp_ii_master_folder_tuple[1] == tmp_i_master_folder_tuple[1]:
flag_exist_plus_one_row = True
if flag_exist_plus_one_row == True:
master_folder_tuple[tmp_i_master_folder_tuple[0] + 1 + tmp_offset_column, tmp_i_master_folder_tuple[1]] = i_master_folder_tuple[tmp_i_master_folder_tuple[0] + 1,tmp_i_master_folder_tuple[1]]
### kyusai bug fix 001 , add 10 to 2,1 in master_folder_tuple
flag_exist_2_1_a = False
for iii_master_folder_tuple in master_folder_tuple:
if iii_master_folder_tuple[0] == 2 and iii_master_folder_tuple[1] == 1:
flag_exist_2_1_a = True
if flag_exist_2_1_a == False:
master_folder_tuple[2,1] = 10
print('--- master_folder_tuple <<POSITION_FOLDER>> -- ')
#print(master_folder_tuple)
'''For Debug, write excel meta'''
#write_to_section = '<<POSITION_FOLDER>>'
#ns_def.write_excel_meta(master_folder_tuple, self.excel_file_path, self.worksheet_name, write_to_section,offset_row, offset_column)
#exit()
'''
Write <<STYLE_FOLDER>>
'''
master_style_folder_meta = {} # After this process, write the style folder meta data to excel
style_folder_row = 1
for tmp_array in folder_array:
style_folder_row += 1
master_style_folder_meta[style_folder_row, 1] = tmp_array[0]
master_style_folder_meta[style_folder_row, 2] = 'YES'
master_style_folder_meta[style_folder_row, 3] = 'UP'
master_style_folder_meta[style_folder_row, 4] = '<AUTO>'
master_style_folder_meta[style_folder_row, 5] = '<AUTO>'
for meta in master_folder_tuple:
flag_wp_array = False
for tmp_wp in wp_array:
if master_folder_tuple[meta[0], meta[1]] == tmp_wp[1] + '_wp_':
flag_wp_array = True
if flag_wp_array == True:
style_folder_row += 1
master_style_folder_meta[style_folder_row, 1] = master_folder_tuple[meta[0], meta[1]]
master_style_folder_meta[style_folder_row, 2] = 'NO'
master_style_folder_meta[style_folder_row, 3] = 'NO'
master_style_folder_meta[style_folder_row, 4] = '<AUTO>'
master_style_folder_meta[style_folder_row, 5] = '<AUTO>'
print('---- master_style_folder_meta ----')
#print(master_style_folder_meta)
write_to_section = '<<STYLE_FOLDER>>'
offset_row = 2
ns_def.write_excel_meta(master_style_folder_meta, self.excel_file_path, self.worksheet_name, write_to_section, offset_row, offset_column)
offset_row = 0
'''
Write <<POSITION_SHAPE>>
'''
### GET Shapes of each Folder
start_row = 2
master_shape_tuple = {}
for each_folder_array in folder_array:
flag_target_folder = False
current_shape_array = []
for each_shape_array in shape_array:
if each_folder_array[0] == each_shape_array[0]:
flag_target_folder = True
current_shape_array.append(each_shape_array)
if flag_target_folder == True and (each_folder_array[0] != each_shape_array[0] or each_shape_array[1] == shape_array[-1][1]):
current_shape_tuple = ns_def.return_shape_tuple(current_shape_array,start_row)
for tmp_tuple in current_shape_tuple:
master_shape_tuple[tmp_tuple] = current_shape_tuple[tmp_tuple]
last_row_num = tmp_tuple[0]
start_row = last_row_num + 1
break
'''
Write <<POSITION_SHAPE>> for WayPoint
'''
print('---- folder_name_of_wp ----')
#print(folder_name_of_wp)
pre_folder_name_of_wp = []
for replace_folder_name_of_wp in folder_name_of_wp:
pre_folder_name_of_wp.append(replace_folder_name_of_wp.replace('_wp_', ''))
folder_name_of_wp = pre_folder_name_of_wp
### Check multiple WPs in a same folder
multi_wp = []
for tmp_wp in wp_array:
if tmp_wp[1] not in folder_name_of_wp and tmp_wp[1] not in str(multi_wp):
for tmp_tmp_wp in wp_array:
if tmp_wp[0] == tmp_tmp_wp[0] and tmp_wp[2] == tmp_tmp_wp[2] and tmp_wp[1] != tmp_tmp_wp[1]:
multi_wp.append([tmp_wp[1], tmp_wp[2],tmp_tmp_wp[1]])
print('---- multi_wp ----')
#print(multi_wp)
for tmp_folder_name_of_wp in folder_name_of_wp:
flag_multi_wp = False
tmp_sort_hight = [tmp_folder_name_of_wp]
for tmp_multi_wp in multi_wp:
if tmp_folder_name_of_wp == tmp_multi_wp[2]:
flag_multi_wp = True
tmp_sort_hight.append(tmp_multi_wp[0])
if flag_multi_wp == False:
master_shape_tuple[start_row, 1] = tmp_folder_name_of_wp + '_wp_'
master_shape_tuple[start_row, 2] = tmp_folder_name_of_wp
master_shape_tuple[start_row, 3] = '<END>'
elif flag_multi_wp == True:
master_shape_tuple[start_row, 1] = tmp_folder_name_of_wp + '_wp_'
#sort WPs with hight
tmp_hight_wp = []
tmp_sort_multi_wp = []
current_multi_wp_tuple = {}