powertrain-build 1.13.1__py3-none-any.whl → 1.13.3.dev3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- powertrain_build/__init__.py +40 -40
- powertrain_build/__main__.py +6 -6
- powertrain_build/a2l.py +582 -582
- powertrain_build/a2l_merge.py +650 -650
- powertrain_build/a2l_templates.py +717 -717
- powertrain_build/build.py +985 -985
- powertrain_build/build_defs.py +309 -309
- powertrain_build/build_proj_config.py +690 -690
- powertrain_build/check_interface.py +575 -575
- powertrain_build/cli.py +141 -141
- powertrain_build/config.py +542 -542
- powertrain_build/core.py +395 -395
- powertrain_build/core_dummy.py +343 -343
- powertrain_build/create_conversion_table.py +73 -73
- powertrain_build/dids.py +916 -916
- powertrain_build/dummy.py +157 -157
- powertrain_build/dummy_spm.py +252 -252
- powertrain_build/environmentcheck.py +52 -52
- powertrain_build/ext_dbg.py +255 -255
- powertrain_build/ext_var.py +327 -327
- powertrain_build/feature_configs.py +301 -301
- powertrain_build/gen_allsysteminfo.py +227 -227
- powertrain_build/gen_label_split.py +449 -449
- powertrain_build/handcode_replacer.py +124 -124
- powertrain_build/html_report.py +133 -133
- powertrain_build/interface/__init__.py +4 -4
- powertrain_build/interface/application.py +511 -511
- powertrain_build/interface/base.py +500 -500
- powertrain_build/interface/csp_api.py +490 -490
- powertrain_build/interface/device_proxy.py +677 -677
- powertrain_build/interface/ems.py +67 -67
- powertrain_build/interface/export_global_vars.py +121 -121
- powertrain_build/interface/generate_adapters.py +132 -132
- powertrain_build/interface/generate_hi_interface.py +87 -87
- powertrain_build/interface/generate_service.py +69 -69
- powertrain_build/interface/generate_wrappers.py +147 -147
- powertrain_build/interface/generation_utils.py +142 -142
- powertrain_build/interface/hal.py +194 -194
- powertrain_build/interface/model_yaml_verification.py +348 -348
- powertrain_build/interface/service.py +296 -296
- powertrain_build/interface/simulink.py +249 -249
- powertrain_build/interface/update_call_sources.py +180 -180
- powertrain_build/interface/update_model_yaml.py +186 -186
- powertrain_build/interface/zone_controller.py +362 -362
- powertrain_build/lib/__init__.py +4 -4
- powertrain_build/lib/helper_functions.py +127 -127
- powertrain_build/lib/logger.py +55 -55
- powertrain_build/matlab_scripts/CodeGen/BuildAutomationPyBuild.m +78 -78
- powertrain_build/matlab_scripts/CodeGen/Generate_A2L.m +154 -154
- powertrain_build/matlab_scripts/CodeGen/generateTLUnit.m +239 -239
- powertrain_build/matlab_scripts/CodeGen/getAsilClassification.m +28 -28
- powertrain_build/matlab_scripts/CodeGen/modelConfiguredForTL.m +28 -28
- powertrain_build/matlab_scripts/CodeGen/moveDefOutports.m +88 -88
- powertrain_build/matlab_scripts/CodeGen/parseCalMeasData.m +410 -410
- powertrain_build/matlab_scripts/CodeGen/parseCoreIdentifiers.m +139 -139
- powertrain_build/matlab_scripts/CodeGen/parseDIDs.m +141 -141
- powertrain_build/matlab_scripts/CodeGen/parseInPorts.m +106 -106
- powertrain_build/matlab_scripts/CodeGen/parseIncludeConfigs.m +25 -25
- powertrain_build/matlab_scripts/CodeGen/parseModelInfo.m +38 -38
- powertrain_build/matlab_scripts/CodeGen/parseNVM.m +81 -81
- powertrain_build/matlab_scripts/CodeGen/parseOutPorts.m +120 -120
- powertrain_build/matlab_scripts/CodeGen/parsePreProcBlks.m +23 -23
- powertrain_build/matlab_scripts/CodeGen/struct2JSON.m +128 -128
- powertrain_build/matlab_scripts/CodeGen/updateCodeSwConfig.m +31 -31
- powertrain_build/matlab_scripts/Init_PyBuild.m +91 -91
- powertrain_build/matlab_scripts/__init__.py +2 -2
- powertrain_build/matlab_scripts/helperFunctions/Get_Full_Name.m +46 -46
- powertrain_build/matlab_scripts/helperFunctions/Get_SrcLines.m +12 -12
- powertrain_build/matlab_scripts/helperFunctions/Init_Models.m +78 -78
- powertrain_build/matlab_scripts/helperFunctions/Init_Projects.m +67 -67
- powertrain_build/matlab_scripts/helperFunctions/Read_Units.m +34 -34
- powertrain_build/matlab_scripts/helperFunctions/SetProjectTimeSamples.m +26 -26
- powertrain_build/matlab_scripts/helperFunctions/Strip_Suffix.m +16 -16
- powertrain_build/matlab_scripts/helperFunctions/followLink.m +118 -118
- powertrain_build/matlab_scripts/helperFunctions/getCodeSwitches.m +50 -50
- powertrain_build/matlab_scripts/helperFunctions/getConsumerBlocks.m +30 -30
- powertrain_build/matlab_scripts/helperFunctions/getDefBlock.m +39 -39
- powertrain_build/matlab_scripts/helperFunctions/getDefOutport.m +58 -58
- powertrain_build/matlab_scripts/helperFunctions/getDstBlocks.m +19 -19
- powertrain_build/matlab_scripts/helperFunctions/getDstLines.m +13 -13
- powertrain_build/matlab_scripts/helperFunctions/getInterfaceSignals.m +37 -37
- powertrain_build/matlab_scripts/helperFunctions/getName.m +37 -37
- powertrain_build/matlab_scripts/helperFunctions/getPath.m +6 -6
- powertrain_build/matlab_scripts/helperFunctions/getProperValue.m +21 -21
- powertrain_build/matlab_scripts/helperFunctions/getSrcBlocks.m +19 -19
- powertrain_build/matlab_scripts/helperFunctions/getSrcLines.m +13 -13
- powertrain_build/matlab_scripts/helperFunctions/loadLibraries.m +10 -10
- powertrain_build/matlab_scripts/helperFunctions/loadjson.m +6 -6
- powertrain_build/matlab_scripts/helperFunctions/modifyEnumStructField.m +21 -21
- powertrain_build/matlab_scripts/helperFunctions/removeConfigDuplicates.m +31 -31
- powertrain_build/matlab_scripts/helperFunctions/sortSystemByClass.m +26 -26
- powertrain_build/matlab_scripts/helperFunctions/tl_getfast.m +89 -89
- powertrain_build/matlab_scripts/helperFunctions/topLevelSystem.m +20 -20
- powertrain_build/matlab_scripts/helperFunctions/updateModels.m +131 -131
- powertrain_build/memory_section.py +224 -224
- powertrain_build/nvm_def.py +729 -729
- powertrain_build/problem_logger.py +86 -86
- powertrain_build/pt_matlab.py +430 -430
- powertrain_build/pt_win32.py +144 -144
- powertrain_build/replace_compu_tab_ref.py +105 -105
- powertrain_build/rte_dummy.py +254 -254
- powertrain_build/sched_funcs.py +209 -207
- powertrain_build/signal.py +7 -7
- powertrain_build/signal_if_html_rep.py +221 -221
- powertrain_build/signal_if_html_rep_all.py +302 -302
- powertrain_build/signal_incons_html_rep.py +180 -180
- powertrain_build/signal_incons_html_rep_all.py +366 -366
- powertrain_build/signal_incons_html_rep_base.py +168 -168
- powertrain_build/signal_inconsistency_check.py +641 -641
- powertrain_build/signal_interfaces.py +864 -864
- powertrain_build/templates/Index_SigCheck_All.html +22 -22
- powertrain_build/templates/Index_SigIf_All.html +19 -19
- powertrain_build/types.py +218 -218
- powertrain_build/unit_configs.py +419 -419
- powertrain_build/user_defined_types.py +660 -660
- powertrain_build/versioncheck.py +66 -66
- powertrain_build/wrapper.py +512 -512
- powertrain_build/xlrd_csv.py +87 -87
- powertrain_build/zone_controller/__init__.py +4 -4
- powertrain_build/zone_controller/calibration.py +176 -176
- powertrain_build/zone_controller/composition_yaml.py +880 -878
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/METADATA +100 -100
- powertrain_build-1.13.3.dev3.dist-info/RECORD +130 -0
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/WHEEL +1 -1
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/LICENSE +202 -202
- powertrain_build-1.13.3.dev3.dist-info/pbr.json +1 -0
- powertrain_build-1.13.1.dist-info/RECORD +0 -130
- powertrain_build-1.13.1.dist-info/pbr.json +0 -1
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/entry_points.txt +0 -0
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/AUTHORS +0 -0
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/licenses/NOTICE +0 -0
- {powertrain_build-1.13.1.dist-info → powertrain_build-1.13.3.dev3.dist-info}/top_level.txt +0 -0
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
# Copyright 2024 Volvo Car Corporation
|
|
2
|
-
# Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
"""Script to replace pragmas in hand written c-code."""
|
|
5
|
-
|
|
6
|
-
import re
|
|
7
|
-
import os
|
|
8
|
-
import sys
|
|
9
|
-
import shutil
|
|
10
|
-
|
|
11
|
-
REPO_ROOT = os.path.join(os.path.dirname(__file__), '..', '..')
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class CodeReplacer:
|
|
15
|
-
"""Class to replace code in hand written c-code."""
|
|
16
|
-
|
|
17
|
-
def replace_line(self, line):
|
|
18
|
-
"""Replace line."""
|
|
19
|
-
raise NotImplementedError
|
|
20
|
-
|
|
21
|
-
def replace_file(self, file_name):
|
|
22
|
-
"""Go through all lines in the file and replace pragmas."""
|
|
23
|
-
tmp_file = file_name + '.tmp'
|
|
24
|
-
with open(file_name, 'r', encoding='ascii', errors='ignore') as old_file:
|
|
25
|
-
with open(tmp_file, 'w', encoding='ascii', errors='ignore') as new_file:
|
|
26
|
-
for line in old_file.readlines():
|
|
27
|
-
line = self.replace_line(line)
|
|
28
|
-
new_file.write(line)
|
|
29
|
-
shutil.move(tmp_file, file_name)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class PragmaReplacer(CodeReplacer):
|
|
33
|
-
"""Class to replace pragmas in hand written c-code."""
|
|
34
|
-
|
|
35
|
-
def __init__(self):
|
|
36
|
-
"""Init."""
|
|
37
|
-
self.cvc_started = False
|
|
38
|
-
self.cvc = None
|
|
39
|
-
self.regex = re.compile(r'^\s*#pragma section\s*(CVC(?P<cvc>[a-zA-Z0-9_]*))*\s*$')
|
|
40
|
-
self.template = '#include "CVC_{cvc}_{start_or_end}.h"\n'
|
|
41
|
-
|
|
42
|
-
def replace_line(self, line):
|
|
43
|
-
"""Replace line (if it has a pragma)."""
|
|
44
|
-
match = self.regex.match(line)
|
|
45
|
-
if match:
|
|
46
|
-
if self.cvc_started:
|
|
47
|
-
line = self.template.format(cvc=self.cvc,
|
|
48
|
-
start_or_end='END')
|
|
49
|
-
self.cvc = None
|
|
50
|
-
else:
|
|
51
|
-
self.cvc = match.group('cvc') or 'CODE'
|
|
52
|
-
line = self.template.format(cvc=self.cvc,
|
|
53
|
-
start_or_end='START')
|
|
54
|
-
self.cvc_started = not self.cvc_started
|
|
55
|
-
return line
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class CodeSwitchReplacer(CodeReplacer):
|
|
59
|
-
"""Class to replace code switch includes in hand written c-code."""
|
|
60
|
-
|
|
61
|
-
def __init__(self):
|
|
62
|
-
"""Init."""
|
|
63
|
-
self.regex = re.compile(r'(.*)SPM_Codeswitch_Setup(_PVC)?(.*)')
|
|
64
|
-
self.template = '{}VcCodeSwDefines{}\n'
|
|
65
|
-
|
|
66
|
-
def replace_line(self, line):
|
|
67
|
-
"""Replace include code switch file."""
|
|
68
|
-
match = self.regex.match(line)
|
|
69
|
-
if match:
|
|
70
|
-
return self.template.format(match.group(1), match.group(3))
|
|
71
|
-
return line
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def update_files(files):
|
|
75
|
-
"""Replace code in handwritten file."""
|
|
76
|
-
for file_path in files:
|
|
77
|
-
PragmaReplacer().replace_file(file_path)
|
|
78
|
-
CodeSwitchReplacer().replace_file(file_path)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def update_test_files(files):
|
|
82
|
-
"""Replace code in handwritten file."""
|
|
83
|
-
for file_path in files:
|
|
84
|
-
CodeSwitchReplacer().replace_file(file_path)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def get_files_to_update(source_dir_name):
|
|
88
|
-
"""Get files to update."""
|
|
89
|
-
files = [os.path.join('./Models/SSPCECD/VcTqReq__DIESEL', source_dir_name, 'invTab2_UInt16_func.c'),
|
|
90
|
-
os.path.join('./Models/SSPCECD/VcCmbNOx__DIESEL', source_dir_name, 'NNEval15x8_func.c'),
|
|
91
|
-
os.path.join('./Models/SSPCECD/VcTqEff__DIESEL', source_dir_name, 'NNEval15x8_func.c')]
|
|
92
|
-
for path, _, filenames in os.walk(os.path.join(REPO_ROOT, 'Models', 'SSPDL')):
|
|
93
|
-
if path.endswith(os.path.join('Mdl', source_dir_name)) or\
|
|
94
|
-
path.endswith(os.path.join('Mdl__denso', source_dir_name)):
|
|
95
|
-
for filename in filenames:
|
|
96
|
-
if (filename.endswith('.c') and not filename.endswith('Mdl.c')) or \
|
|
97
|
-
(filename.endswith('.h') and not filename.endswith('Mdl.h')):
|
|
98
|
-
file_path = os.path.relpath(os.path.join(path, filename))
|
|
99
|
-
files.append(file_path)
|
|
100
|
-
return files
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def get_test_files_to_update():
|
|
104
|
-
"""Get files to update."""
|
|
105
|
-
files = []
|
|
106
|
-
for path, _, filenames in os.walk(os.path.join(REPO_ROOT, 'Models')):
|
|
107
|
-
for filename in filenames:
|
|
108
|
-
if filename.endswith('.py'):
|
|
109
|
-
file_path = os.path.relpath(os.path.join(path, filename))
|
|
110
|
-
files.append(file_path)
|
|
111
|
-
return files
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def main():
|
|
115
|
-
"""Replace incorrect pragmas in handwritten c-code."""
|
|
116
|
-
files_to_update = get_files_to_update('pybuild_src')
|
|
117
|
-
update_files(files_to_update)
|
|
118
|
-
test_files_to_update = get_test_files_to_update()
|
|
119
|
-
update_test_files(test_files_to_update)
|
|
120
|
-
return 0
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if __name__ == '__main__':
|
|
124
|
-
sys.exit(main())
|
|
1
|
+
# Copyright 2024 Volvo Car Corporation
|
|
2
|
+
# Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
"""Script to replace pragmas in hand written c-code."""
|
|
5
|
+
|
|
6
|
+
import re
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import shutil
|
|
10
|
+
|
|
11
|
+
REPO_ROOT = os.path.join(os.path.dirname(__file__), '..', '..')
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CodeReplacer:
|
|
15
|
+
"""Class to replace code in hand written c-code."""
|
|
16
|
+
|
|
17
|
+
def replace_line(self, line):
|
|
18
|
+
"""Replace line."""
|
|
19
|
+
raise NotImplementedError
|
|
20
|
+
|
|
21
|
+
def replace_file(self, file_name):
|
|
22
|
+
"""Go through all lines in the file and replace pragmas."""
|
|
23
|
+
tmp_file = file_name + '.tmp'
|
|
24
|
+
with open(file_name, 'r', encoding='ascii', errors='ignore') as old_file:
|
|
25
|
+
with open(tmp_file, 'w', encoding='ascii', errors='ignore') as new_file:
|
|
26
|
+
for line in old_file.readlines():
|
|
27
|
+
line = self.replace_line(line)
|
|
28
|
+
new_file.write(line)
|
|
29
|
+
shutil.move(tmp_file, file_name)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class PragmaReplacer(CodeReplacer):
|
|
33
|
+
"""Class to replace pragmas in hand written c-code."""
|
|
34
|
+
|
|
35
|
+
def __init__(self):
|
|
36
|
+
"""Init."""
|
|
37
|
+
self.cvc_started = False
|
|
38
|
+
self.cvc = None
|
|
39
|
+
self.regex = re.compile(r'^\s*#pragma section\s*(CVC(?P<cvc>[a-zA-Z0-9_]*))*\s*$')
|
|
40
|
+
self.template = '#include "CVC_{cvc}_{start_or_end}.h"\n'
|
|
41
|
+
|
|
42
|
+
def replace_line(self, line):
|
|
43
|
+
"""Replace line (if it has a pragma)."""
|
|
44
|
+
match = self.regex.match(line)
|
|
45
|
+
if match:
|
|
46
|
+
if self.cvc_started:
|
|
47
|
+
line = self.template.format(cvc=self.cvc,
|
|
48
|
+
start_or_end='END')
|
|
49
|
+
self.cvc = None
|
|
50
|
+
else:
|
|
51
|
+
self.cvc = match.group('cvc') or 'CODE'
|
|
52
|
+
line = self.template.format(cvc=self.cvc,
|
|
53
|
+
start_or_end='START')
|
|
54
|
+
self.cvc_started = not self.cvc_started
|
|
55
|
+
return line
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class CodeSwitchReplacer(CodeReplacer):
|
|
59
|
+
"""Class to replace code switch includes in hand written c-code."""
|
|
60
|
+
|
|
61
|
+
def __init__(self):
|
|
62
|
+
"""Init."""
|
|
63
|
+
self.regex = re.compile(r'(.*)SPM_Codeswitch_Setup(_PVC)?(.*)')
|
|
64
|
+
self.template = '{}VcCodeSwDefines{}\n'
|
|
65
|
+
|
|
66
|
+
def replace_line(self, line):
|
|
67
|
+
"""Replace include code switch file."""
|
|
68
|
+
match = self.regex.match(line)
|
|
69
|
+
if match:
|
|
70
|
+
return self.template.format(match.group(1), match.group(3))
|
|
71
|
+
return line
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def update_files(files):
|
|
75
|
+
"""Replace code in handwritten file."""
|
|
76
|
+
for file_path in files:
|
|
77
|
+
PragmaReplacer().replace_file(file_path)
|
|
78
|
+
CodeSwitchReplacer().replace_file(file_path)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def update_test_files(files):
|
|
82
|
+
"""Replace code in handwritten file."""
|
|
83
|
+
for file_path in files:
|
|
84
|
+
CodeSwitchReplacer().replace_file(file_path)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def get_files_to_update(source_dir_name):
|
|
88
|
+
"""Get files to update."""
|
|
89
|
+
files = [os.path.join('./Models/SSPCECD/VcTqReq__DIESEL', source_dir_name, 'invTab2_UInt16_func.c'),
|
|
90
|
+
os.path.join('./Models/SSPCECD/VcCmbNOx__DIESEL', source_dir_name, 'NNEval15x8_func.c'),
|
|
91
|
+
os.path.join('./Models/SSPCECD/VcTqEff__DIESEL', source_dir_name, 'NNEval15x8_func.c')]
|
|
92
|
+
for path, _, filenames in os.walk(os.path.join(REPO_ROOT, 'Models', 'SSPDL')):
|
|
93
|
+
if path.endswith(os.path.join('Mdl', source_dir_name)) or\
|
|
94
|
+
path.endswith(os.path.join('Mdl__denso', source_dir_name)):
|
|
95
|
+
for filename in filenames:
|
|
96
|
+
if (filename.endswith('.c') and not filename.endswith('Mdl.c')) or \
|
|
97
|
+
(filename.endswith('.h') and not filename.endswith('Mdl.h')):
|
|
98
|
+
file_path = os.path.relpath(os.path.join(path, filename))
|
|
99
|
+
files.append(file_path)
|
|
100
|
+
return files
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def get_test_files_to_update():
|
|
104
|
+
"""Get files to update."""
|
|
105
|
+
files = []
|
|
106
|
+
for path, _, filenames in os.walk(os.path.join(REPO_ROOT, 'Models')):
|
|
107
|
+
for filename in filenames:
|
|
108
|
+
if filename.endswith('.py'):
|
|
109
|
+
file_path = os.path.relpath(os.path.join(path, filename))
|
|
110
|
+
files.append(file_path)
|
|
111
|
+
return files
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def main():
|
|
115
|
+
"""Replace incorrect pragmas in handwritten c-code."""
|
|
116
|
+
files_to_update = get_files_to_update('pybuild_src')
|
|
117
|
+
update_files(files_to_update)
|
|
118
|
+
test_files_to_update = get_test_files_to_update()
|
|
119
|
+
update_test_files(test_files_to_update)
|
|
120
|
+
return 0
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == '__main__':
|
|
124
|
+
sys.exit(main())
|
powertrain_build/html_report.py
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
# Copyright 2024 Volvo Car Corporation
|
|
2
|
-
# Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
"""Module for html report generation."""
|
|
5
|
-
from string import Template
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class HtmlReport:
|
|
9
|
-
"""Generate template html report. Extend this class to add content.
|
|
10
|
-
|
|
11
|
-
TODO: Refactor common parts from derived report classes to this class.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
__html_head = """<!DOCTYPE html>
|
|
15
|
-
<html>
|
|
16
|
-
<head>
|
|
17
|
-
<meta charset="UTF-8">
|
|
18
|
-
<style>
|
|
19
|
-
body {
|
|
20
|
-
counter-reset: h2;
|
|
21
|
-
font-family:"Segoe UI","Segoe",Tahoma,Helvetica,Arial,sans-serif;
|
|
22
|
-
}
|
|
23
|
-
h1 {text-align: center}
|
|
24
|
-
h2 {counter-reset: h3}
|
|
25
|
-
h3 {counter-reset: h4}
|
|
26
|
-
h4 {counter-reset: h5}
|
|
27
|
-
h5 {counter-reset: h6}
|
|
28
|
-
h2:before {counter-increment: h2; content: counter(h2) ". "}
|
|
29
|
-
h3:before {counter-increment: h3; content: counter(h2) "." counter(h3) ". "}
|
|
30
|
-
h4:before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ". "}
|
|
31
|
-
h5:before {counter-increment: h5; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". "}
|
|
32
|
-
h6:before {
|
|
33
|
-
counter-increment: h6; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". "
|
|
34
|
-
}
|
|
35
|
-
h2.nocount:before, h3.nocount:before, h4.nocount:before, h5.nocount:before, h6.nocount:before {
|
|
36
|
-
content: ""; counter-increment: none
|
|
37
|
-
}
|
|
38
|
-
p {
|
|
39
|
-
padding-left:5mm;
|
|
40
|
-
}
|
|
41
|
-
table {
|
|
42
|
-
width:95%;
|
|
43
|
-
margin-left:5mm
|
|
44
|
-
}
|
|
45
|
-
table, th, td {
|
|
46
|
-
border: 1px solid black;
|
|
47
|
-
border-collapse: collapse;
|
|
48
|
-
}
|
|
49
|
-
th, td {
|
|
50
|
-
padding: 5px;
|
|
51
|
-
text-align: left;
|
|
52
|
-
}
|
|
53
|
-
table tr:nth-child(even) {
|
|
54
|
-
background-color: #eee;
|
|
55
|
-
}
|
|
56
|
-
table tr:nth-child(odd) {
|
|
57
|
-
background-color:#fff;
|
|
58
|
-
}
|
|
59
|
-
table th {
|
|
60
|
-
background-color: black;
|
|
61
|
-
color: white;
|
|
62
|
-
}
|
|
63
|
-
ol {
|
|
64
|
-
list-style-type: none;
|
|
65
|
-
counter-reset: item;
|
|
66
|
-
margin: 0;
|
|
67
|
-
padding-left:5mm;
|
|
68
|
-
}
|
|
69
|
-
ol > li {
|
|
70
|
-
display: table;
|
|
71
|
-
counter-increment: item;
|
|
72
|
-
margin-bottom: 0.6em;
|
|
73
|
-
}
|
|
74
|
-
ol > li:before {
|
|
75
|
-
content: counters(item, ".") ". ";
|
|
76
|
-
display: table-cell;
|
|
77
|
-
padding-right: 0.6em;
|
|
78
|
-
}
|
|
79
|
-
li ol > li {
|
|
80
|
-
margin: 0;
|
|
81
|
-
}
|
|
82
|
-
li ol > li:before {
|
|
83
|
-
content: counters(item, ".") " ";
|
|
84
|
-
}
|
|
85
|
-
</style>
|
|
86
|
-
<title>$title</title>
|
|
87
|
-
</head>
|
|
88
|
-
<body>
|
|
89
|
-
<h1>$title</h1>
|
|
90
|
-
"""
|
|
91
|
-
|
|
92
|
-
__html_end = """</body>
|
|
93
|
-
</html>
|
|
94
|
-
"""
|
|
95
|
-
|
|
96
|
-
def __init__(self, title):
|
|
97
|
-
"""Initialize report title.
|
|
98
|
-
|
|
99
|
-
Args:
|
|
100
|
-
title (str): The report title
|
|
101
|
-
"""
|
|
102
|
-
super().__init__()
|
|
103
|
-
self._title = title
|
|
104
|
-
|
|
105
|
-
def _gen_header(self):
|
|
106
|
-
"""Generate html header."""
|
|
107
|
-
return Template(self.__html_head).substitute(title=self._title)
|
|
108
|
-
|
|
109
|
-
@staticmethod
|
|
110
|
-
def gen_contents():
|
|
111
|
-
"""Generate report contents.
|
|
112
|
-
|
|
113
|
-
Override this method to add report contents.
|
|
114
|
-
Contents should start with a <h2> header.
|
|
115
|
-
"""
|
|
116
|
-
return '<h2>Template report</h2>'
|
|
117
|
-
|
|
118
|
-
def _gen_end(self):
|
|
119
|
-
"""Generate the end of the body and html document."""
|
|
120
|
-
return self.__html_end
|
|
121
|
-
|
|
122
|
-
def generate_report_string(self):
|
|
123
|
-
"""Generate a html report as string."""
|
|
124
|
-
html = []
|
|
125
|
-
html += self._gen_header()
|
|
126
|
-
html += self.gen_contents()
|
|
127
|
-
html += self._gen_end()
|
|
128
|
-
return ''.join(html)
|
|
129
|
-
|
|
130
|
-
def generate_report_file(self, filename):
|
|
131
|
-
"""Generate a html report and save to file."""
|
|
132
|
-
with open(filename, 'w', encoding="utf-8") as fhndl:
|
|
133
|
-
fhndl.write(self.generate_report_string())
|
|
1
|
+
# Copyright 2024 Volvo Car Corporation
|
|
2
|
+
# Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
"""Module for html report generation."""
|
|
5
|
+
from string import Template
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class HtmlReport:
|
|
9
|
+
"""Generate template html report. Extend this class to add content.
|
|
10
|
+
|
|
11
|
+
TODO: Refactor common parts from derived report classes to this class.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
__html_head = """<!DOCTYPE html>
|
|
15
|
+
<html>
|
|
16
|
+
<head>
|
|
17
|
+
<meta charset="UTF-8">
|
|
18
|
+
<style>
|
|
19
|
+
body {
|
|
20
|
+
counter-reset: h2;
|
|
21
|
+
font-family:"Segoe UI","Segoe",Tahoma,Helvetica,Arial,sans-serif;
|
|
22
|
+
}
|
|
23
|
+
h1 {text-align: center}
|
|
24
|
+
h2 {counter-reset: h3}
|
|
25
|
+
h3 {counter-reset: h4}
|
|
26
|
+
h4 {counter-reset: h5}
|
|
27
|
+
h5 {counter-reset: h6}
|
|
28
|
+
h2:before {counter-increment: h2; content: counter(h2) ". "}
|
|
29
|
+
h3:before {counter-increment: h3; content: counter(h2) "." counter(h3) ". "}
|
|
30
|
+
h4:before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ". "}
|
|
31
|
+
h5:before {counter-increment: h5; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". "}
|
|
32
|
+
h6:before {
|
|
33
|
+
counter-increment: h6; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". "
|
|
34
|
+
}
|
|
35
|
+
h2.nocount:before, h3.nocount:before, h4.nocount:before, h5.nocount:before, h6.nocount:before {
|
|
36
|
+
content: ""; counter-increment: none
|
|
37
|
+
}
|
|
38
|
+
p {
|
|
39
|
+
padding-left:5mm;
|
|
40
|
+
}
|
|
41
|
+
table {
|
|
42
|
+
width:95%;
|
|
43
|
+
margin-left:5mm
|
|
44
|
+
}
|
|
45
|
+
table, th, td {
|
|
46
|
+
border: 1px solid black;
|
|
47
|
+
border-collapse: collapse;
|
|
48
|
+
}
|
|
49
|
+
th, td {
|
|
50
|
+
padding: 5px;
|
|
51
|
+
text-align: left;
|
|
52
|
+
}
|
|
53
|
+
table tr:nth-child(even) {
|
|
54
|
+
background-color: #eee;
|
|
55
|
+
}
|
|
56
|
+
table tr:nth-child(odd) {
|
|
57
|
+
background-color:#fff;
|
|
58
|
+
}
|
|
59
|
+
table th {
|
|
60
|
+
background-color: black;
|
|
61
|
+
color: white;
|
|
62
|
+
}
|
|
63
|
+
ol {
|
|
64
|
+
list-style-type: none;
|
|
65
|
+
counter-reset: item;
|
|
66
|
+
margin: 0;
|
|
67
|
+
padding-left:5mm;
|
|
68
|
+
}
|
|
69
|
+
ol > li {
|
|
70
|
+
display: table;
|
|
71
|
+
counter-increment: item;
|
|
72
|
+
margin-bottom: 0.6em;
|
|
73
|
+
}
|
|
74
|
+
ol > li:before {
|
|
75
|
+
content: counters(item, ".") ". ";
|
|
76
|
+
display: table-cell;
|
|
77
|
+
padding-right: 0.6em;
|
|
78
|
+
}
|
|
79
|
+
li ol > li {
|
|
80
|
+
margin: 0;
|
|
81
|
+
}
|
|
82
|
+
li ol > li:before {
|
|
83
|
+
content: counters(item, ".") " ";
|
|
84
|
+
}
|
|
85
|
+
</style>
|
|
86
|
+
<title>$title</title>
|
|
87
|
+
</head>
|
|
88
|
+
<body>
|
|
89
|
+
<h1>$title</h1>
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
__html_end = """</body>
|
|
93
|
+
</html>
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
def __init__(self, title):
|
|
97
|
+
"""Initialize report title.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
title (str): The report title
|
|
101
|
+
"""
|
|
102
|
+
super().__init__()
|
|
103
|
+
self._title = title
|
|
104
|
+
|
|
105
|
+
def _gen_header(self):
|
|
106
|
+
"""Generate html header."""
|
|
107
|
+
return Template(self.__html_head).substitute(title=self._title)
|
|
108
|
+
|
|
109
|
+
@staticmethod
|
|
110
|
+
def gen_contents():
|
|
111
|
+
"""Generate report contents.
|
|
112
|
+
|
|
113
|
+
Override this method to add report contents.
|
|
114
|
+
Contents should start with a <h2> header.
|
|
115
|
+
"""
|
|
116
|
+
return '<h2>Template report</h2>'
|
|
117
|
+
|
|
118
|
+
def _gen_end(self):
|
|
119
|
+
"""Generate the end of the body and html document."""
|
|
120
|
+
return self.__html_end
|
|
121
|
+
|
|
122
|
+
def generate_report_string(self):
|
|
123
|
+
"""Generate a html report as string."""
|
|
124
|
+
html = []
|
|
125
|
+
html += self._gen_header()
|
|
126
|
+
html += self.gen_contents()
|
|
127
|
+
html += self._gen_end()
|
|
128
|
+
return ''.join(html)
|
|
129
|
+
|
|
130
|
+
def generate_report_file(self, filename):
|
|
131
|
+
"""Generate a html report and save to file."""
|
|
132
|
+
with open(filename, 'w', encoding="utf-8") as fhndl:
|
|
133
|
+
fhndl.write(self.generate_report_string())
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 Volvo Car Corporation
|
|
2
|
-
# Licensed under Apache 2.0.
|
|
3
|
-
|
|
4
|
-
"""powertrain_build.interface."""
|
|
1
|
+
# Copyright 2024 Volvo Car Corporation
|
|
2
|
+
# Licensed under Apache 2.0.
|
|
3
|
+
|
|
4
|
+
"""powertrain_build.interface."""
|