-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconvert_manage.py
More file actions
6867 lines (4570 loc) · 231 KB
/
convert_manage.py
File metadata and controls
6867 lines (4570 loc) · 231 KB
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
#!/usr/bin/python3
# -*- coding: utf-8 -*
import json
import os.path
import shutil
import sqlite3
import time
import zipfile
from typing import Union
import dbf
import openpyxl
from lxml import etree
from openpyxl import Workbook
from allplan_manage import AllplanDatas, Creation, AttributeDatas
from hierarchy import *
from tools import afficher_message as msg, find_new_title, read_file_to_list, qm_check, excel_load_workbook
from tools import convertir_bytes, find_folder_path, get_value_is_valid, xml_load_root, application_title
from tools import open_file, find_filename, convertir_nom_fichier_correct, settings_save_value
from translation_manage import *
def a___________________detection______():
pass
class BddTypeDetection(QObject):
def __init__(self):
super().__init__()
self.error_message = ""
self.bdd_type = ""
self.bdd_title = ""
self.file_path = ""
def search_bdd_type(self, file_path: str):
error_txt = self.tr("Erreur")
bible_txt = self.tr("Bible externe")
if file_path == "":
error_message = self.tr("Aucun chemin défini.")
self.error_message = f"{error_txt} -- {error_message}"
return False
if file_path.lower().endswith(".txt"):
part1 = self.tr("Ce format de fichier n'est pas pris en charge.")
part2 = self.tr("Si ce fichier est un fichier csv, il est nécessaire de changer l'extention.")
error_message = f"{part1}\n {part2}"
self.error_message = f"{error_txt} -- {error_message}"
return False
# ---------------------------------------
# HTTPS
# ---------------------------------------
if file_path.startswith("https"):
self.file_path = file_path
# ---------------------------------------
# SYNERMI
# ---------------------------------------
if bdd_type_synermi.lower() in file_path.lower():
self.bdd_type = bdd_type_synermi
self.bdd_title = "Synermi"
return True
# ---------------------------------------
# CAPMI
# ---------------------------------------
if bdd_type_capmi.lower() in file_path.lower():
self.bdd_type = bdd_type_capmi
self.bdd_title = "Capmi"
return True
# ---------------------------------------
# PROGEMI
# ---------------------------------------
if bdd_type_progemi.lower() in file_path.lower():
self.bdd_type = bdd_type_progemi
self.bdd_title = "Progemi"
return True
# ---------------------------------------
# Excel
# ---------------------------------------
if ".xlsx" in file_path.lower() and "/" in file_path:
if self.excel_file():
return True
self.bdd_type = bdd_type_extern
self.bdd_title = bible_txt
return True
# ---------------------------------------
title = find_filename(file_path).title()
if title == "":
error_message = self.tr("Une erreur est survenue.")
self.error_message = f"{error_txt} -- {error_message}"
return False
temp = file_path.upper()
self.file_path = file_path
error_message = self.tr("Cette base de données n'a pas été reconnue.")
# ---------------------------------------
# KUKAT
# ---------------------------------------
if temp.endswith(".KAT"):
self.bdd_type = bdd_type_kukat
self.bdd_title = f"{bible_txt} - Kukat"
return True
# ---------------------------------------
# EXCEL
# ---------------------------------------
if temp.endswith(".XLSX"):
if self.excel_file():
return True
# ---------------------------------------
# CSV
# ---------------------------------------
if temp.endswith(".CSV"):
self.bdd_type = bdd_type_excel
self.bdd_title = title
return True
# ---------------------------------------
# MXDB
# ---------------------------------------
if temp.endswith(".MXDB"):
self.bdd_type = bdd_type_mxdb
self.bdd_title = title
return True
# ---------------------------------------
# EXCEL / CSV
# ---------------------------------------
if temp.endswith(".XPWE"):
self.bdd_type = bdd_type_xpwe
self.bdd_title = title
return True
# ---------------------------------------
# XML
# ---------------------------------------
if temp.endswith(".XML"):
try:
root = xml_load_root(file_path=file_path)
if not isinstance(root, etree._Element):
return False
brand_txt = root.tag
# ---------------------------------------
# Nevaris
# ---------------------------------------
if brand_txt == "{six.xsd}Documento":
self.bdd_type = bdd_type_team_system_xml
self.bdd_title = title
return True
# ---------------------------------------
# Nevaris
# ---------------------------------------
if brand_txt == '{urn:schemas-microsoft-com:office:spreadsheet}Workbook':
try:
first_row = root.find(path='.//ss:Row[2]',
namespaces={'ss': 'urn:schemas-microsoft-com:office:spreadsheet'})
if first_row is None:
self.error_message = f"{error_txt} -- {error_message}"
return False
style_id = first_row.attrib.get('{urn:schemas-microsoft-com:office:spreadsheet}StyleID', '')
if not isinstance(style_id, str):
self.error_message = f"{error_txt} -- {error_message}"
return False
if 'NEVARIS_STYLE_H1' != style_id:
self.error_message = f"{error_txt} -- {error_message}"
return False
datas = first_row.findall(path=".//ss:Data",
namespaces={'ss': 'urn:schemas-microsoft-com:office:spreadsheet'})
if len(datas) < 2:
self.error_message = f"{error_txt} -- {error_message}"
return False
bdd_type = datas[0].text
if bdd_type != "Raumelement":
self.error_message = f"{error_txt} -- {error_message}"
return False
title = datas[1].text
if not isinstance(title, str):
self.error_message = f"{error_txt} -- {error_message}"
return False
except Exception:
self.error_message = f"{error_txt} -- {error_message}"
return False
self.bdd_type = bdd_type_nevaris
self.bdd_title = title
return True
# ---------------------------------------
# SMARTCATALOG
# ---------------------------------------
if brand_txt == "AllplanCatalog":
check_version = root.find("Node")
if check_version is None:
self.error_message = f"{error_txt} -- {error_message}"
return False
self.bdd_type = bdd_type_xml
self.bdd_title = title
return True
# ---------------------------------------
# SMARTCATALOG
# ---------------------------------------
check_version = root.find("Folder")
if check_version is not None:
if brand_txt not in bdd_icons_dict:
self.bdd_type = bdd_type_extern
else:
self.bdd_type = brand_txt
self.bdd_title = brand_txt.title()
return True
# ---------------------------------------
# SMARTCATALOG - Extern
# ---------------------------------------
check_version = root.find("Dossier")
if check_version is not None:
# ---------------------------------------
# GIMI
# --------------------------------------
if brand_txt.upper() == "GIMI":
self.bdd_type = bdd_type_gimi
self.bdd_title = "Gimi"
return True
# ---------------------------------------
# Other
# --------------------------------------
if brand_txt not in bdd_icons_dict:
self.bdd_type = bdd_type_extern
else:
self.bdd_type = brand_txt
self.bdd_title = brand_txt.title()
return True
# ---------------------------------------
# SMARTCATALOG - Extern - Old
# ---------------------------------------
check_version = root.find("Dossier")
if check_version is not None:
if brand_txt not in bdd_icons_dict:
self.bdd_type = bdd_type_extern
else:
self.bdd_type = brand_txt
self.bdd_title = brand_txt
return True
self.error_message = f"{error_txt} -- {error_message}"
return False
except Exception:
self.error_message = f"{error_txt} -- {error_message}"
return False
# ---------------------------------------
# ARA
# ---------------------------------------
if temp.endswith(".ARA"):
file_path = unpack_ara_file(file_path=file_path)
if file_path == "":
return False
self.file_path = file_path
temp = file_path.upper()
# ---------------------------------------
# DBF
# ---------------------------------------
if temp.endswith(".DBF"):
try:
with dbf.Table(filename=file_path) as table:
if len(table) == 0:
self.error_message = f"{error_txt} -- {error_message}"
return False
liste_colonnes = table.field_names
if "VWKTX" not in liste_colonnes:
self.error_message = f"{error_txt} -- {error_message}"
return False
record = table.first_record
item_type: str = convertir_bytes(record.VWTPU)
code_item_type: str = convertir_bytes(record.VWTYP)
title = convertir_bytes(record.VWKTX)
title = convertir_nom_fichier_correct(title).title()
if code_item_type != "X":
self.error_message = f"{error_txt} -- {error_message}"
return False
# ---------------------------------------
# ALLMETRE - EURICIEL
# ---------------------------------------
if item_type == "Projekt":
self.bdd_type = bdd_type_allmetre_e
self.bdd_title = title
return True
# ---------------------------------------
# ALLMETRE - AJSOFT
# ---------------------------------------
if item_type == "Pos.":
self.bdd_type = bdd_type_allmetre_a
self.bdd_title = title
return True
for record in table:
if dbf.is_deleted(record):
continue
code_item_type: str = convertir_bytes(record.VWTYP)
# ---------------------------------------
# BCM - MATERIAL
# ---------------------------------------
if code_item_type == "E" or code_item_type == "T":
self.bdd_type = bdd_type_bcm
self.bdd_title = title
return True
# ---------------------------------------
# BCM - COMPONENT
# ---------------------------------------
if code_item_type == "L":
self.bdd_type = bdd_type_bcm_c
self.bdd_title = title
return True
except Exception as error:
print(f"convert_manage -- search_bdd_type -- error : {error}")
pass
self.error_message = f"{error_txt} -- {error_message}"
return False
if temp.endswith(".FIC") or temp.endswith(".NDX") or temp.endswith(".MMO"):
if title.upper() in ["CM", "ST", "ARTICLES", "PARA"]:
path_gimi = os.path.dirname(file_path)
path_gimi = path_gimi.replace("/", "\\")
if not path_gimi.endswith("\\"):
path_gimi += "\\"
settings_save_value(library_setting_file, "path_gimi", path_gimi)
# ---------------------------------------
# GIMI
# ---------------------------------------
self.bdd_type = bdd_type_gimi
self.bdd_title = f"{bible_txt} - {bdd_type_gimi}"
return True
return False
dict_favoris_allplan = get_favorites_allplan_dict()
for extension, nom_favoris in dict_favoris_allplan.items():
if file_path.endswith(extension):
self.bdd_type = bdd_type_fav
self.bdd_title = title
return True
self.error_message = f"{error_txt} -- {error_message}"
return False
def excel_file(self) -> bool:
try:
workbook = excel_load_workbook(file_path=self.file_path)
if not isinstance(workbook, openpyxl.Workbook):
return False
sheet = workbook.active
test_1 = sheet.cell(1, 7).value
if isinstance(test_1, str):
if 'INCIDENZA CATEGORIE\n(%)' in test_1:
self.bdd_type = bdd_type_team_system_xlsx
self.bdd_title = workbook.sheetnames[0]
return True
# -------------
test_2 = sheet.cell(1, 1).value
if isinstance(test_2, str):
if test_2 == "Teilleistungsnummer":
self.bdd_type = bdd_type_nevaris_xlsx
self.bdd_title = workbook.sheetnames[0]
return True
# -------------
self.bdd_type = bdd_type_excel
if self.file_path.startswith("https"):
path_split = self.file_path.split("/")
for part in path_split:
part = part.lower()
if ".xlsx" not in part:
continue
title = part.replace(".xlsx", "").strip()
self.bdd_title = title.title()
return True
else:
self.bdd_title = find_filename(file_path=self.file_path).title()
return True
self.bdd_title = workbook.sheetnames[0]
return True
except Exception as error:
print(f"convert_manage -- BddTypeDetection -- excel_file -- error: {error}")
pass
return False
def unpack_ara_file(file_path: str) -> str:
# -------------------------
# Verification file exists
# -------------------------
if not isinstance(file_path, str):
print(f"conver_manage -- unpack_ara_file -- not isinstance(file_path, str)")
return ""
if not os.path.exists(file_path):
print(f"conver_manage -- unpack_ara_file -- not os.path.exists(file_path)")
return ""
# -------------------------
# search folder path
# -------------------------
folder_path = find_folder_path(file_path)
if folder_path == "":
print(f"conver_manage -- unpack_ara_file -- folder_path == empty")
return ""
# -------------------------
# search filename
# -------------------------
file_name = find_filename(file_path=file_path)
file_name = file_name.strip()
if file_name == "":
print(f"conver_manage -- unpack_ara_file -- file_name == empty")
return ""
# -------------------------
# define others paths
# -------------------------
export_path = f"{asc_export_path}{file_name}\\"
json_file_path = f"{export_path}{file_name}.ini"
export_path_bak = f"{asc_export_path}{file_name}_bak"
dbf_path = f"{export_path}VW1.DBF"
# -------------------------
# search size ARA file
# -------------------------
try:
file_size = os.path.getsize(file_path)
except OSError as error:
print(f"conver_manage -- unpack_ara_file -- error delete : {error}")
return ""
# -------------------------
# search old size
# -------------------------
file_size_old = 0
if os.path.exists(json_file_path):
try:
with open(json_file_path, 'r', encoding="Utf-8") as file:
file_size_old = json.load(file)
except Exception as error:
print(f"conver_manage -- unpack_ara_file -- error json read : {error}")
file_size_old = 0
pass
# -------------------------
# current ARA file and old ARA file are same
# -------------------------
if file_size == file_size_old and os.path.exists(dbf_path):
return dbf_path
# -------------------------
# Delete backup folder
# -------------------------
if os.path.exists(export_path_bak):
try:
shutil.rmtree(export_path_bak)
except Exception as error:
print(f"conver_manage -- unpack_ara_file -- error delete : {error}")
return ""
# -------------------------
# Rename current folder to backup folder
# -------------------------
if os.path.exists(export_path):
try:
os.rename(export_path, export_path_bak)
except Exception as error:
print(f"conver_manage -- unpack_ara_file -- error rename : {error}")
return ""
# -------------------------
# Create new folder
# -------------------------
try:
os.makedirs(export_path)
except Exception as error:
print(f"conver_manage -- unpack_ara_file -- error make dir : {error}")
return ""
# -------------------------
# Unzip
# -------------------------
try:
with zipfile.ZipFile(file_path, 'r') as zip_ref:
zip_ref.extractall(export_path)
except Exception as error:
print(f"conver_manage -- unpack_ara_file -- error zip : {error}")
return ""
# -------------------------
# search dbf file
# -------------------------
if not os.path.exists(dbf_path):
print(f"conver_manage -- unpack_ara_file -- not os.path.exists(dbf_path)")
return ""
# -------------------------
# Write json file
# -------------------------
try:
with open(json_file_path, 'w', encoding="Utf-8") as file:
json.dump(file_size, file, ensure_ascii=False, indent=2)
except Exception as error:
print(f"conver_manage -- unpack_ara_file -- error json write : {error}")
return "False"
# -------------------------
# Unpack is ok
# -------------------------
return dbf_path
class ConvertTemplate(QObject):
loading_completed = pyqtSignal(QStandardItemModel, list, list, list)
number_error_signal = pyqtSignal(list)
errors_signal = pyqtSignal(list)
def __init__(self, allplan: AllplanDatas, file_path: str, bdd_title: str, conversion=False):
super().__init__()
# --------------
# Allplan
# --------------
self.allplan: AllplanDatas = allplan
self.creation: Creation = self.allplan.creation
if conversion:
self.allplan.creation.attributes_datas.clear()
# --------------
# Model
# --------------
self.cat_model = QStandardItemModel()
self.cat_model.setHorizontalHeaderLabels([bdd_title, self.tr("Description")])
self.qs_root = self.cat_model.invisibleRootItem()
self.qs_root.setData(folder_code, user_data_type)
# --------------
self.material_list = list()
self.material_upper_list = list()
self.link_list = list()
self.material_with_link_list = list()
# --------------
# Variables BDD
# --------------
self.file_path = file_path
self.bdd_title = bdd_title
self.conversion = conversion
# ----
self.expanded_list = list()
self.selected_list = list()
self.errors_list = list()
self.number_error_list = list()
# ----
self.counter = time.perf_counter()
def start_loading(self):
self.cat_model.beginResetModel()
print(f"convert_manage -- {type(self)} -- read {self.file_path} ---------- ")
def end_loading(self):
self.cat_model.endResetModel()
self.loading_completed.emit(self.cat_model, self.expanded_list, self.selected_list, self.number_error_list)
print(f"DB loaded in : {time.perf_counter() - self.counter} ms")
# -----------------
if len(self.errors_list) != 0:
self.errors_signal.emit(self.errors_list)
# -----------------
if len(self.number_error_list) != 0:
self.number_error_signal.emit(self.number_error_list)
def a___________________bcm_component______():
pass
class BcmArticleComponent:
def __init__(self, type_ele: str, cid_index: str, pid_index: str, srt_index: int, code: str, desc: str):
super().__init__()
# ---------
# Required
# ---------
self.type_ele = type_ele
self.cid_index = cid_index
self.pid_index = pid_index
self.srt_index = srt_index
self.code = code
self.desc = desc
# ---------
# Optional
# ---------
self.full_text = ""
self.unit_value = ""
self.trade_value = ""
self.price = ""
self.formula = ""
self.materiaux_dyn = ""
self.formula_obj = ""
self.quantity = ""
class ConvertBcmComposants(ConvertTemplate):
def __init__(self, allplan: AllplanDatas, file_path: str, bdd_title: str, conversion=False):
super().__init__(allplan, file_path, bdd_title, conversion)
# --------------
# Variables
# --------------
self.root_code = "Root"
self.keys_convert = {"X": self.root_code,
"E": folder_code,
"T": folder_code,
"O": folder_code,
"L": folder_code,
"P": component_code}
# --------------
# Variables datas
# --------------
self.prices_dict = dict()
self.pid_dict = dict()
self.cid_root = ""
# --------------
def run(self):
self.start_loading()
# ----------------------
self.get_all_prices()
# ----------------------
# Read DB
# ----------------------
try:
with dbf.Table(filename=self.file_path) as table:
for record in table:
if dbf.is_deleted(record):
continue
self.bcm_load_record_datas(record=record)
except Exception as error:
print(f"convert_manage -- ConvertBcmComposants -- run -- erreur : {error}")
self.errors_list.append(f"run -- {error}")
self.end_loading()
return False
# ----------------------
# Load DB
# ----------------------
if self.cid_root == "":
print(f"convert_manage -- ConvertBcmComposants -- run -- self.cid_root is empty")
self.errors_list.append(f"run -- cid_root is empty")
self.end_loading()
return False
if self.cid_root not in self.pid_dict:
print(f"convert_manage -- ConvertBcmComposants -- run -- self.cid_root not in self.pid_dict")
self.errors_list.append(f"run -- cid_root not in self.pid_dict")
self.end_loading()
return False
children_articles = self.pid_dict.get(self.cid_root)
if not isinstance(children_articles, list):
print(f"convert_manage -- ConvertBcmComposants -- run -- ot isinstance(children_articles, list)")
self.errors_list.append(f"run -- not isinstance(children_articles, list)")
self.end_loading()
return False
self.bcm_load_hierarchy(children_articles=children_articles, qs_parent=self.qs_root)
self.end_loading()
return True
def bcm_load_record_datas(self, record) -> None:
# ----------------------
# Type - Required
# ----------------------
key_type = convertir_bytes(record.VWTYP)
if not isinstance(key_type, str):
print("convert_manage -- ConvertBcmComposants -- bcm_load_record_datas -- not isinstance(key_type, str)")
self.errors_list.append(f"bcm_load_record_datas -- not isinstance(key_type, str)")
return
type_ele = self.keys_convert.get(key_type, "")
if type_ele == "":
return
# ----------------------
# CID - Required
# ----------------------
cid_index = convertir_bytes(record.VWCID)
if not isinstance(cid_index, str):
print("convert_manage -- ConvertBcmComposants -- bcm_load_record_datas -- not isinstance(cid_index, str)")
self.errors_list.append(f"bcm_load_record_datas -- not isinstance(cid_index, str)")
return
if cid_index == "":
print("convert_manage -- ConvertBcmComposants -- bcm_load_record_datas -- cid_index is empty")
self.errors_list.append(f"bcm_load_record_datas -- cid_index is empty")
return
if type_ele == self.root_code:
self.cid_root = cid_index
return
# ----------------------
# PID - Required
# ----------------------
pid_index = convertir_bytes(record.VWPID)
if not isinstance(pid_index, str):
print("convert_manage -- ConvertBcmComposants -- bcm_load_record_datas -- not isinstance(pid_index, str)")
self.errors_list.append(f"bcm_load_record_datas -- not isinstance(pid_index, str)")
return
if pid_index == "" and type_ele != self.root_code:
pid_index = self.cid_root
# ----------------------
# SRT - Required
# ----------------------
srt_index = convertir_bytes(record.VWSRT)
if not isinstance(srt_index, int):
print("convert_manage -- ConvertBcmComposants -- bcm_load_record_datas -- not isinstance(srt_index, str)")
self.errors_list.append(f"bcm_load_record_datas -- not isinstance(srt_index, str)")
return
if srt_index == -1:
print("convert_manage -- ConvertBcmComposants -- bcm_load_record_datas -- srt_index == -1")
self.errors_list.append(f"bcm_load_record_datas -- srt_index == -1")
return
try:
srt_index = f"{srt_index:010d}"
except Exception as error:
print(f"convert_manage -- ConvertBcmComposants -- bcm_load_record_datas -- error : {error}")
self.errors_list.append(f"bcm_load_record_datas -- format srt index : {error}")
return
# ----------------------
# Code element - Required
# ----------------------
code = convertir_bytes(record.VWPNR)
if not isinstance(code, str):
code = ""
# ----------------------
# Description - Required
# ----------------------
desc = convertir_bytes(record.VWKTX)
if not isinstance(desc, str):
print("convert_manage -- ConvertBcmComposants -- bcm_load_record_datas -- not isinstance(desc, str)")
self.errors_list.append(f"bcm_load_record_datas -- not isinstance(desc, str)")
return
if code == "" and desc != "":
code = desc
# ----------------------
# Article creation
# ----------------------