sbdl 1.20.2__tar.gz → 1.20.3__tar.gz
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.
- {sbdl-1.20.2 → sbdl-1.20.3}/PKG-INFO +1 -1
- {sbdl-1.20.2 → sbdl-1.20.3}/sbdl.egg-info/PKG-INFO +1 -1
- {sbdl-1.20.2 → sbdl-1.20.3}/sbdl.py +253 -252
- {sbdl-1.20.2 → sbdl-1.20.3}/setup.py +1 -1
- {sbdl-1.20.2 → sbdl-1.20.3}/csv-to-sbdl.py +0 -0
- {sbdl-1.20.2 → sbdl-1.20.3}/pyproject.toml +0 -0
- {sbdl-1.20.2 → sbdl-1.20.3}/sbdl.egg-info/SOURCES.txt +0 -0
- {sbdl-1.20.2 → sbdl-1.20.3}/sbdl.egg-info/dependency_links.txt +0 -0
- {sbdl-1.20.2 → sbdl-1.20.3}/sbdl.egg-info/entry_points.txt +0 -0
- {sbdl-1.20.2 → sbdl-1.20.3}/sbdl.egg-info/requires.txt +0 -0
- {sbdl-1.20.2 → sbdl-1.20.3}/sbdl.egg-info/top_level.txt +0 -0
- {sbdl-1.20.2 → sbdl-1.20.3}/sbdl_server.py +0 -0
- {sbdl-1.20.2 → sbdl-1.20.3}/setup.cfg +0 -0
|
@@ -1,162 +1,163 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
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
|
-
|
|
2
|
+
_Dk='SteeringFirmware::correctCourse'
|
|
3
|
+
_Dj='rocket_in_motion'
|
|
4
|
+
_Di='rocket_ready'
|
|
5
|
+
_Dh='correct_course'
|
|
6
|
+
_Dg='fire_booster'
|
|
7
|
+
_Df='steering_requirement_1'
|
|
8
|
+
_De='booster_requirement_1'
|
|
9
|
+
_Dd='steering_firmware'
|
|
10
|
+
_Dc='test/macro.py'
|
|
11
|
+
_Db='--custom-mode'
|
|
12
|
+
_Da='--custom-directive'
|
|
13
|
+
_DZ='template-fill'
|
|
14
|
+
_DY='openfmea-csv'
|
|
15
|
+
_DX='skinparam linetype ortho\n'
|
|
16
|
+
_DW='{} .{}.{} {}{}\n'
|
|
17
|
+
_DV='\n{}{} "{}" as {} {}{}'
|
|
18
|
+
_DU='Not a file: {}'
|
|
19
|
+
_DT='Reading: {}'
|
|
20
|
+
_DS='class_type_name'
|
|
21
|
+
_DR='[^a-zA-Z0-9.:_ ]+|(?<=.)\\.$'
|
|
22
|
+
_DQ='verification'
|
|
23
|
+
_DP='validation'
|
|
24
|
+
_DO='uncertainty'
|
|
25
|
+
_DN='transient'
|
|
26
|
+
_DM='temperature'
|
|
27
|
+
_DL='subsystem'
|
|
28
|
+
_DK='structure'
|
|
29
|
+
_DJ='stability'
|
|
30
|
+
_DI='specification'
|
|
31
|
+
_DH='simulation'
|
|
32
|
+
_DG='resistance'
|
|
33
|
+
_DF='resolution'
|
|
34
|
+
_DE='reliability'
|
|
35
|
+
_DD='redundancy'
|
|
36
|
+
_DC='radiation'
|
|
37
|
+
_DB='quality assurance'
|
|
38
|
+
_DA='proportional-integral-derivative'
|
|
39
|
+
_D9='performance'
|
|
40
|
+
_D8='parameter'
|
|
41
|
+
_D7='optimization'
|
|
42
|
+
_D6='operating system'
|
|
43
|
+
_D5='mechanism'
|
|
44
|
+
_D4='measurement'
|
|
45
|
+
_D3='manufacturing'
|
|
46
|
+
_D2='management'
|
|
47
|
+
_D1='maintenance'
|
|
48
|
+
_D0='iteration'
|
|
49
|
+
_C_='integration'
|
|
50
|
+
_Cz='instrumentation'
|
|
51
|
+
_Cy='inspection'
|
|
52
|
+
_Cx='implementation'
|
|
53
|
+
_Cw='identification'
|
|
54
|
+
_Cv='high voltage'
|
|
55
|
+
_Cu='heat transfer'
|
|
56
|
+
_Ct='frequency'
|
|
57
|
+
_Cs='failure mode and effects analysis'
|
|
58
|
+
_Cr='evaluation'
|
|
59
|
+
_Cq='electromagnetic'
|
|
60
|
+
_Cp='electrical'
|
|
61
|
+
_Co='efficiency'
|
|
62
|
+
_Cn='dimension'
|
|
63
|
+
_Cm='development'
|
|
64
|
+
_Cl='degrees of freedom'
|
|
65
|
+
_Ck='data acquisition'
|
|
66
|
+
_Cj='correction'
|
|
67
|
+
_Ci='coordinate'
|
|
68
|
+
_Ch='controller'
|
|
69
|
+
_Cg='configuration'
|
|
70
|
+
_Cf='configure'
|
|
71
|
+
_Ce='coefficient'
|
|
72
|
+
_Cd='center of mass'
|
|
73
|
+
_Cc='center of gravity'
|
|
74
|
+
_Cb='calculation'
|
|
75
|
+
_Ca='auxiliary'
|
|
76
|
+
_CZ='architecture'
|
|
77
|
+
_CY='approximate'
|
|
78
|
+
_CX='aerodynamics'
|
|
79
|
+
_CW='acceleration'
|
|
80
|
+
_CV='unicode_escape'
|
|
81
|
+
_CU='^\\s*{}\\s*{}.*?{}\\s*$'
|
|
82
|
+
_CT='customtype'
|
|
83
|
+
_CS='arguments'
|
|
84
|
+
_CR='skinparam NoteBackgroundColor LightSteelBlue\nskinparam ParticipantBackgroundColor LightGrey\nskinparam backgroundColor transparent'
|
|
85
|
+
_CQ='multipartite'
|
|
86
|
+
_CP='sbdl_unique_identifier_gen_alphabet'
|
|
87
|
+
_CO='sbdl_unique_identifier_gen_length'
|
|
88
|
+
_CN='profile_output'
|
|
89
|
+
_CM='fmea_cause_extension'
|
|
90
|
+
_CL='openfmea_complex_aspect'
|
|
91
|
+
_CK='openfmea_bidirectional_import_relations'
|
|
92
|
+
_CJ='openfmea_include_in_template'
|
|
93
|
+
_CI='openfmea_fmeadev_url'
|
|
94
|
+
_CH='openfmea_content_based_keys'
|
|
95
|
+
_CG='openfmea_include_cme_unlinked'
|
|
96
|
+
_CF='openfmea_include_cme_orphans'
|
|
97
|
+
_CE='openfmea_expand_compoundfields'
|
|
98
|
+
_CD='remote_procedure_call_api_endpoint'
|
|
99
|
+
_CC='remote_procedure_call_api_key'
|
|
100
|
+
_CB='remote_procedure_call_enable'
|
|
101
|
+
_CA='remote_resouce_fetch_enable'
|
|
102
|
+
_C9='sbdl_disable_pretty_print'
|
|
103
|
+
_C8='sbdl_disable_pretty_print_environ'
|
|
104
|
+
_C7='manual_command'
|
|
105
|
+
_C6='add_description_bsci_property'
|
|
106
|
+
_C5='elision_placeholder'
|
|
107
|
+
_C4='reference_maximum_length'
|
|
108
|
+
_C3='usecase_diagram_style'
|
|
109
|
+
_C2='state_diagram_descriptions'
|
|
110
|
+
_C1='state_diagram_style'
|
|
111
|
+
_C0='uml_text_block_wrap_element'
|
|
112
|
+
_B_='process_diagram_descriptions'
|
|
113
|
+
_Bz='function_diagram_aspect'
|
|
114
|
+
_By='function_diagram_descriptions'
|
|
115
|
+
_Bx='aspect_diagram_descriptions'
|
|
116
|
+
_Bw='aspect_diagram_element'
|
|
117
|
+
_Bv='aspect_diagram_aspect'
|
|
118
|
+
_Bu='requirement_diagram_legend'
|
|
119
|
+
_Bt='requirement_diagram_style'
|
|
120
|
+
_Bs='requirement_diagram_title_node_always'
|
|
121
|
+
_Br='requirement_diagram_toplevel_depth'
|
|
122
|
+
_Bq='requirement_diagram_aspect_groups'
|
|
123
|
+
_Bp='network_diagram_hide_types'
|
|
124
|
+
_Bo='network_diagram_dpi'
|
|
125
|
+
_Bn='network_diagram_layout'
|
|
126
|
+
_Bm='network_diagram_labels'
|
|
127
|
+
_Bl='network_diagram_descriptions'
|
|
128
|
+
_Bk='network_diagram_height'
|
|
129
|
+
_Bj='network_diagram_width'
|
|
130
|
+
_Bi='parser_allow_load_config'
|
|
131
|
+
_Bh='parser_allow_custom_directive_import'
|
|
132
|
+
_Bg='parser_custom_attributes'
|
|
133
|
+
_Bf='parser_allow_preparse_directives'
|
|
134
|
+
_Be='plantuml_generate_footer'
|
|
135
|
+
_Bd='plantuml_output_type'
|
|
136
|
+
_Bc='plantuml_limit_size'
|
|
137
|
+
_Bb='plantuml_command'
|
|
138
|
+
_Ba='wsl_auto_correct_paths'
|
|
139
|
+
_BZ='sbdl_reference_prefix_strip'
|
|
140
|
+
_BY='sbdl_caching_suffix'
|
|
141
|
+
_BX='sbdl_caching_enabled'
|
|
142
|
+
_BW='sbdl_import_allows_recurse'
|
|
143
|
+
_BV='sbdl_warn_new_config'
|
|
144
|
+
_BU='sbdl_update_package'
|
|
145
|
+
_BT='sbdl_hash_check'
|
|
146
|
+
_BS='sbdl_hash_length'
|
|
147
|
+
_BR='sbdl_ast_pre_hooks'
|
|
148
|
+
_BQ='sbdl_attribute_passthrough'
|
|
149
|
+
_BP='sbdl_file_extension'
|
|
150
|
+
_BO='sbdl_output_reference'
|
|
151
|
+
_BN='sbdl_element_color_map'
|
|
152
|
+
_BM='sbdl_grammar_write_statement_separator'
|
|
153
|
+
_BL='sbdl_grammar_write_attribute_separator'
|
|
154
|
+
_BK='sbdl_grammar_custom_comment'
|
|
155
|
+
_BJ='sbdl_grammar_custom_noop'
|
|
156
|
+
_BI='sbdl_grammar_custom_end'
|
|
157
|
+
_BH='sbdl_grammar_custom_begin'
|
|
158
|
+
_BG='sbdl_grammar_custom_suffix'
|
|
159
|
+
_BF='sbdl_grammar_custom_prefix'
|
|
160
|
+
_BE='tracemalloc'
|
|
160
161
|
_BD='rocket_launch'
|
|
161
162
|
_BC='launch_protocol'
|
|
162
163
|
_BB='system_requirement_1'
|
|
@@ -286,18 +287,18 @@ _D='-o'
|
|
|
286
287
|
_C=False
|
|
287
288
|
_B=None
|
|
288
289
|
_A=True
|
|
289
|
-
import argparse,base64,datetime,csv,functools,getpass,hashlib,importlib,io,json,os,pathlib,pickle,platform,re,shlex,string,subprocess,sys,tarfile,tempfile,textwrap,threading,time,traceback,
|
|
290
|
+
import argparse,base64,datetime,csv,functools,getpass,hashlib,importlib,io,json,os,pathlib,pickle,platform,re,shlex,string,subprocess,sys,tarfile,tempfile,textwrap,threading,time,traceback,types,unittest,urllib.request,urllib.parse,warnings,zlib,zipfile
|
|
290
291
|
warnings.filterwarnings(_A6,category=DeprecationWarning)
|
|
291
292
|
__NAME=_b
|
|
292
|
-
__VERSION='1.20.
|
|
293
|
-
__VERSION_DEV='
|
|
293
|
+
__VERSION='1.20.3'
|
|
294
|
+
__VERSION_DEV='a1685b1'
|
|
294
295
|
__VERSION_DSL='25.6'
|
|
295
296
|
__VERSION_REST_API='1.1.0'
|
|
296
297
|
__AUTHOR='contact@sbdl.dev'
|
|
297
298
|
__URL='https://sbdl.dev'
|
|
298
299
|
__LOGO=''
|
|
299
300
|
__HELP_TEXT=''
|
|
300
|
-
_CONFIG_DATA={
|
|
301
|
+
_CONFIG_DATA={_BF:'_sbdl\\s?\\(',_BG:'\\)$',_BH:'_sbdl_block_begin',_BI:'_sbdl_block_end',_BJ:'^\\.\\.\\.$',_BK:_B,_BL:_A,_BM:_C,_s:_A,_BN:{},_W:_C,_BO:_A,_BP:'.sbdl',_BQ:_P,_BR:[],_m:[],_BS:5,_BT:_A,_BU:'sbdl-package.tar.gz',_AR:_C,_A7:_C,_A8:_C,_BV:_A,_BW:_A,_BX:_C,_BY:'.sbdlc',_AS:{},_BZ:'',_Ba:_A,_n:_A,_A9:_C,_AT:_B,_AU:_C,_Bb:'plantuml',_Bc:65536,_Bd:'png',_Be:_A,_AV:_C,_AW:_C,_AA:_A,_Bf:_A,_AX:_A,_AY:_A,_T:{},_Bg:_A,_Bh:_A,_Bi:_A,_Bj:38,_Bk:22,_Bl:_C,_Bm:_A,_AZ:20000,_Bn:_CQ,_Bo:200,_Bp:'',_Bq:_C,_Br:2,_Bs:_C,_X:"!pragma layout newlayouter\nskinparam dpi 200\nskinparam backgroundColor transparent\n'skinparam monochrome reverse\n\n",_Bt:'\n<style>\n node {\n HorizontalAlignment center\n MaximumWidth 150\n }\n wbsDiagram {\n Linecolor black\n arrow {\n LineColor black\n }\n .toplevel {\n }\n .source {\n LineStyle 2\n RoundCorner 10\n }\n .aspect {\n LineStyle 8.0;3.0\n LineColor lightgray\n BackgroundColor lightgray\n LineThickness 1.0\n RoundCorner 0\n Shadowing 0.0\n }\n }\n</style>',_Bu:_B,_Aa:'hide circle',_Bv:'frame',_Bw:'class',_Bx:_C,_Ab:_CR,_By:_C,_Bz:'participant','process_diagram_style':_CR,_B_:_C,_t:_C,_c:15,_C0:40,_C1:'',_C2:_C,_C3:'',_Ac:_C,_C4:0,_C5:'[...]',_C6:_C,_C7:'less -R'if os.name=='posix'else'',_C8:'SBDL_NO_PRETTY',_C9:_C,_CA:_A,_CB:_C,_CC:'1879da28-0fc2-4f1d-8ff1-407f4c070c44',_CD:'{base}/{endp}'.format(base=__URL,endp='rest.api'),_Ad:'; ',_CE:'',_CF:_A,_CG:_A,_CH:_C,_CI:'https://fmea.dev',_CJ:_A,_CK:_C,_CL:_C,_CM:_U,_CN:_B,_u:_B,_v:{},_CO:8,_CP:'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'}
|
|
301
302
|
def name():return __NAME
|
|
302
303
|
def version():return __VERSION
|
|
303
304
|
def version_dev():return __VERSION_DEV
|
|
@@ -305,7 +306,7 @@ def version_dsl():return __VERSION_DSL
|
|
|
305
306
|
def version_rest_api():return __VERSION_REST_API
|
|
306
307
|
def author():return __AUTHOR
|
|
307
308
|
def url():return __URL
|
|
308
|
-
def allow_pretty_print():return not get_config_value(
|
|
309
|
+
def allow_pretty_print():return not get_config_value(_C8)in os.environ and not get_config_value(_C9,number=_A)
|
|
309
310
|
def logo():return __LOGO if allow_pretty_print()else''
|
|
310
311
|
def help_text():return __HELP_TEXT
|
|
311
312
|
def current_os():
|
|
@@ -332,7 +333,7 @@ def lock_config_key(key):
|
|
|
332
333
|
add_to_config_value(lock_key,{key:_A})
|
|
333
334
|
def set_config_value(key,data,warn_on_new=_A):
|
|
334
335
|
if not config_key_locked(key):
|
|
335
|
-
if not key in _CONFIG_DATA and get_config_value(
|
|
336
|
+
if not key in _CONFIG_DATA and get_config_value(_BV,number=_A)and warn_on_new:f_print('WARNING: adding new key ({}) to config registry'.format(key),warning=_A)
|
|
336
337
|
_CONFIG_DATA[key]=data
|
|
337
338
|
else:debug_out(f'Trying to set locked config key:: "{key}"')
|
|
338
339
|
def use_config_data(new_config_data,skip_keys=_B):
|
|
@@ -378,16 +379,16 @@ def lazy_import(package_name,custom_message=_B):
|
|
|
378
379
|
return imported_package
|
|
379
380
|
def fix_wsl_path(path):
|
|
380
381
|
result=path
|
|
381
|
-
if get_config_value(
|
|
382
|
+
if get_config_value(_Ba,number=_A):
|
|
382
383
|
if result.startswith(_Y)and not result.startswith('\\\\'):result='\\\\wsl$'+result;result=str(pathlib.Path(result))
|
|
383
384
|
return result
|
|
384
385
|
def rest_api_call(function_name,arguments_dict,print_l=print_null):
|
|
385
|
-
D='result';C='api_version';B='errors';A='api_name';API_END_POINT=get_config_value(
|
|
386
|
-
def create_rest_object(command,arguments_dict):return{A:name(),C:version_rest_api(),'api_key':get_config_value(
|
|
386
|
+
D='result';C='api_version';B='errors';A='api_name';API_END_POINT=get_config_value(_CD);result_data={}
|
|
387
|
+
def create_rest_object(command,arguments_dict):return{A:name(),C:version_rest_api(),'api_key':get_config_value(_CC),_AB:command,_CS:{**arguments_dict}}
|
|
387
388
|
def report_errors(response_struct):
|
|
388
389
|
print_l('REST_API_CALL:: {} <-- {}'.format(API_END_POINT,response_struct),debug=_A)
|
|
389
390
|
if B in response_struct and isinstance(response_struct[B],list)and len(response_struct[B])>0:print_l('REST_API_CALL:: Response errors: \n {}'.format(_F.join(response_struct[B])),error=_A)
|
|
390
|
-
if get_config_value(
|
|
391
|
+
if get_config_value(_CB,number=_A):
|
|
391
392
|
rest_object=create_rest_object(function_name,arguments_dict);print_l('REST_API_CALL:: {} --> {}'.format(API_END_POINT,rest_object),debug=_A);request_point=urllib.request.Request(API_END_POINT);request_point.add_header('Content-Type','application/json; charset=utf-8');request_data=json.dumps(rest_object).encode(_o);request_point.add_header('Content-Length',len(request_data))
|
|
392
393
|
try:rest_response=urllib.request.urlopen(request_point,request_data)
|
|
393
394
|
except(urllib.error.HTTPError,urllib.error.URLError)as e:print_l('REST_API_CALL:: Error: {}'.format(e),error=_A);rest_response=e
|
|
@@ -573,9 +574,9 @@ def lsp_start(_,__,___,arguments,print_l):
|
|
|
573
574
|
return Hover(contents=MarkupContent(kind=MarkupKind.Markdown,value=lsp_element_info(symbol,element_cache[uri],print_l)))
|
|
574
575
|
sbdl_lsp.start_io();return 0
|
|
575
576
|
class SBDL_Parser:
|
|
576
|
-
class Statements:declaration='declaration';using='using';scope='scope';operator='operator';customtype=
|
|
577
|
+
class Statements:declaration='declaration';using='using';scope='scope';operator='operator';customtype=_CT
|
|
577
578
|
class Types:aspect=_e;requirement=_V;mode='fmea:mode';effect='fmea:effect';cause='fmea:cause';current_control='fmea:control';current_detection='fmea:detection';action_control='fmea:action-control';action_detection='fmea:action-detection';test='test';definition='definition';realisation='realisation';function=_AB;event='event';state='state';transition='transition';usecase='usecase';interface=_w;trace='trace';group='group'
|
|
578
|
-
class Tokens:declaration='is';declaration_group_delimeters=['{','}'];declaration_attribute_assign=' {} '.format(declaration);declaration_attribute_delimeter='"';general_separator=';';raw_content_delimiters=['[[[',']]]'];declaration_attribute_separator=general_separator;statement_separator=general_separator;hashbang='#!sbdl';prefix='@sbdl\\s';prefix_block_start='@sbdl\\-begin';prefix_block_end='@sbdl\\-end';comment='#';using='using';scope='scope';customtype=
|
|
579
|
+
class Tokens:declaration='is';declaration_group_delimeters=['{','}'];declaration_attribute_assign=' {} '.format(declaration);declaration_attribute_delimeter='"';general_separator=';';raw_content_delimiters=['[[[',']]]'];declaration_attribute_separator=general_separator;statement_separator=general_separator;hashbang='#!sbdl';prefix='@sbdl\\s';prefix_block_start='@sbdl\\-begin';prefix_block_end='@sbdl\\-end';comment='#';using='using';scope='scope';customtype=_CT;line_continuation=_Y;replacement_string_default='';replacement_map={_S:',',';':';'};declaration_token_rule='\\s+{}\\s+'.format(declaration);declaration_rule='^.+?{}\\S+\\s*{}.*?{}\\s*$'.format(declaration_token_rule,declaration_group_delimeters[0],declaration_group_delimeters[1]);using_rule=_CU.format(using,declaration_group_delimeters[0],declaration_group_delimeters[1]);scope_rule=_CU.format(scope,declaration_group_delimeters[0],declaration_group_delimeters[1]);customtype_rule='^\\s*{}\\s+{}'.format(customtype,declaration_rule.replace('^',''));macro_delimeters=[_f,']'];macro_variable='@';macro_defer='%';macro_rule='\\{}{}(?:[^\\]\\\\]|\\\\.)*\\{}'.format(macro_delimeters[0],macro_variable,macro_delimeters[1]);macro_index_separator=':';whitespace_list=list(string.whitespace);escape=_Y;stereotype_separator='^';link_operator='||';source_link_operator='~|';operator_rule='\\s*({}|{})\\s*'.format(_Y+_Y.join(link_operator),_Y+_Y.join(source_link_operator));inherit='inherit';compose='compose';hash_separator='~';scope_prefix=_d;stdio_name='-';nested_elements_depth_pop='nest_elems_end'
|
|
579
580
|
class Attributes:description=_N;detectability=_x;detectability_post=_AC;severity=_y;occurrence=_z;occurrence_post=_AD;separator=_S;parent='parent';child='child';related='related';pragma='pragma';remark='remark';reference=_Ah;identifier=_Ai;type=_K;types=_Z;stereotype='stereotype';actor=_Aj;tag='tag';description_bsci='description_bsci';precondition='precondition';postcondition='postcondition';invariant='invariant';output=_Ak;input=_Al;custom_prefix='custom:';condition='condition';condition_alternative='alternative';custom_required_attr='required_property';custom_optional_attr='optional_property';custom_link_types='relation_type';color='color';control_only='control_only';return_control='return_control';raw_content='raw_content';loop_name='loop';parallel_name='parallel';port_name='port'
|
|
580
581
|
class Macros:self_element='SELF';self_reference='SELF_ID';self_reference_attr='SELF_PROP';abort='ABORT';message='MESSAGE';msg='MSG';date='DATE';user='USER';add='ADD';sub='SUB';equal='EQUAL';concat='CONCAT';instli='INSTLI';showall='SHOW_ALL';rmcom='RMCOM';mkid='MKID';dfp='DFP';requiredsl='REQUIRE_DSL_VERSION';requirecompiler='REQUIRE_COMPILER_VERSION';requiredsl_exact='REQUIRE_DSL_VERSION_EXACT';path='PATH';file_name='FILE';directory='DIR';context='CONTEXT';curline='=LINE';preline='-LINE';sucline='+LINE';line='LINE';import_sbdl='IMPORT';import_directive='IMPORT_DIRECTIVE';load_config='LOAD_CONFIG';git_commit_hash='GIT_COMMIT_HASH';define='DEFINE';define_append='DEFINE_APPEND';define_from_func='DEFUNC';define_from_index='DEFIND';define_from_file='DEFINEF';define_from_file_hash='DEFINEFH';expand_define='EXPAND';parsed_elements='PARSED_ELEMENTS';generated_elements='GENERATED_ELEMENTS';synthetic_element='SYNTHETIC_ELEMENT';cross_reference_available='CROSS_REFS_AVAILABLE';extend_cause='EXTEND_CAUSE';cpp_class='CPPCLASS';py_class='PYCLASS';c_func='CFUNC';py_func='PYFUNC';prolog_startup='PL_START';prolog_assert='PL_ASSERT';prolog_assert_n='PL_ASSERT!';prolog_cmd='PL_COMMAND';prolog_trace_file='PL_TRACE_FILE';prolog_result_output='PL_RESULT_OUTPUT';id_from_prop='ID_FROM_PROP'
|
|
581
582
|
class Parser_Hints:
|
|
@@ -629,8 +630,8 @@ class SBDL_Parser:
|
|
|
629
630
|
def copy(self):return SBDL_Parser.Parser_Element(self.content(),self.source(),self.indexes(),self.context())
|
|
630
631
|
@classmethod
|
|
631
632
|
def shorten_reference(self,reference):
|
|
632
|
-
reference_result=reference.removeprefix(get_config_value(
|
|
633
|
-
if max_length!=_B and max_length>0:reference_result=(reference_result[::-1][:max_length]+(reference_result[::-1][max_length:]and get_config_value(
|
|
633
|
+
reference_result=reference.removeprefix(get_config_value(_BZ));max_length=get_config_value(_C4,number=_A)
|
|
634
|
+
if max_length!=_B and max_length>0:reference_result=(reference_result[::-1][:max_length]+(reference_result[::-1][max_length:]and get_config_value(_C5)[::-1]))[::-1]
|
|
634
635
|
return reference_result
|
|
635
636
|
@classmethod
|
|
636
637
|
def line_layout_content_indexes(self,content,indexes):
|
|
@@ -703,7 +704,7 @@ class SBDL_Parser:
|
|
|
703
704
|
else:highest_severity=worst_severity
|
|
704
705
|
return highest_severity if highest_severity>0 else worst_severity
|
|
705
706
|
if SBDL_Parser.Macros.cross_reference_available in macros:
|
|
706
|
-
extend_symbol=get_config_value(
|
|
707
|
+
extend_symbol=get_config_value(_CM)
|
|
707
708
|
if len(inp)<1:raise Exception('No element identifier provided')
|
|
708
709
|
this_elem=macros[macros[SBDL_Parser.Macros.self_reference]];this_aspect_links=[]
|
|
709
710
|
if SBDL_Parser.Types.aspect in this_elem:
|
|
@@ -818,14 +819,14 @@ class SBDL_Parser:
|
|
|
818
819
|
set_config_value(_AT,inp[0]);return''
|
|
819
820
|
def import_directive(macros,*inp):
|
|
820
821
|
param_path=''.join(inp);import_path=os.path.join(macros[SBDL_Parser.Macros.path].replace(macros[SBDL_Parser.Macros.file_name],''),param_path)
|
|
821
|
-
if get_config_value(
|
|
822
|
+
if get_config_value(_Bh,number=_A):
|
|
822
823
|
import_errors=import_custom_directive_file(import_path,f_print)
|
|
823
824
|
if import_errors:raise self.MacroReplaceException(f'ERROR importing custom directive file: "{import_path}"',first_pass_can_ignore=_C)
|
|
824
825
|
else:raise self.MacroReplaceException('ERROR import of custom directives is disabled',first_pass_can_ignore=_C)
|
|
825
826
|
return''
|
|
826
827
|
def load_config_directive(macros,*inp):
|
|
827
828
|
param_path=''.join(inp);config_path=os.path.join(macros[SBDL_Parser.Macros.path].replace(macros[SBDL_Parser.Macros.file_name],''),param_path)
|
|
828
|
-
if get_config_value(
|
|
829
|
+
if get_config_value(_Bi,number=_A):
|
|
829
830
|
try:load_config(config_path,skip_keys=[_T])
|
|
830
831
|
except Exception as e:raise self.MacroReplaceException(f"ERROR loading config: {e}",first_pass_can_ignore=_C)
|
|
831
832
|
else:raise self.MacroReplaceException('ERROR loading of config is disabled',first_pass_can_ignore=_C)
|
|
@@ -1129,14 +1130,14 @@ class SBDL_Parser:
|
|
|
1129
1130
|
return represult
|
|
1130
1131
|
replace_list=[SBDL_Parser.Tokens.comment,SBDL_Parser.Tokens.declaration_attribute_delimeter,*SBDL_Parser.Tokens.declaration_group_delimeters];result=unclean_string
|
|
1131
1132
|
for char_to_rep in replace_list:result=replace_unescapechar(result,char_to_rep)
|
|
1132
|
-
return result.encode(
|
|
1133
|
+
return result.encode(_CV).decode(_An).replace('\\\\',_Y)
|
|
1133
1134
|
@classmethod
|
|
1134
1135
|
def sanitize_escaped(self,unclean_string,reverse=_C):
|
|
1135
1136
|
escape_list=[[SBDL_Parser.Tokens.escape+SBDL_Parser.Tokens.declaration_group_delimeters[0],'##1'],[SBDL_Parser.Tokens.escape+SBDL_Parser.Tokens.declaration_group_delimeters[1],'##2']];result=unclean_string;incr=-1 if reverse else 1
|
|
1136
1137
|
for escape_pair in escape_list:result=result.replace(*escape_pair[::incr])
|
|
1137
1138
|
return result
|
|
1138
1139
|
@classmethod
|
|
1139
|
-
def remove_escape_chars(self,escaped_string):return escaped_string.encode(_o).decode(
|
|
1140
|
+
def remove_escape_chars(self,escaped_string):return escaped_string.encode(_o).decode(_CV)
|
|
1140
1141
|
@classmethod
|
|
1141
1142
|
def attribute_string(self,statement_object):
|
|
1142
1143
|
indent_str='';newline_str='';spacing_str=_I
|
|
@@ -1152,7 +1153,7 @@ class SBDL_Parser:
|
|
|
1152
1153
|
if len(content)>0:
|
|
1153
1154
|
delim=SBDL_Parser.Tokens.declaration_attribute_delimeter
|
|
1154
1155
|
if not needs_delim(content):delim=''
|
|
1155
|
-
attributes+='{indent}{attrname}{assign}{delimiter}{attrcontent}{delimiter}{separator}{newline}{spacing}'.format(attrname=attr,assign=SBDL_Parser.Tokens.declaration_attribute_assign,delimiter=delim,attrcontent=content,separator=SBDL_Parser.Tokens.declaration_attribute_separator if get_config_value(
|
|
1156
|
+
attributes+='{indent}{attrname}{assign}{delimiter}{attrcontent}{delimiter}{separator}{newline}{spacing}'.format(attrname=attr,assign=SBDL_Parser.Tokens.declaration_attribute_assign,delimiter=delim,attrcontent=content,separator=SBDL_Parser.Tokens.declaration_attribute_separator if get_config_value(_BL,number=_A)else'',indent=indent_str,newline=newline_str,spacing=spacing_str)
|
|
1156
1157
|
return attributes
|
|
1157
1158
|
@classmethod
|
|
1158
1159
|
def declaration_string(self,declaration_object):
|
|
@@ -1237,7 +1238,7 @@ class SBDL_Semantics:
|
|
|
1237
1238
|
lang_info_struct['CLI']=help_text();return lang_info_struct
|
|
1238
1239
|
@classmethod
|
|
1239
1240
|
def type_color(self,type_name):
|
|
1240
|
-
E='#FFFF00';D='#FF6347';C='#FF69B4';B='#9370DB';A='#1E90FF';color_list=['#FFC0CB','#FFA07A','#FFD700','#32CD32','#00FFFF',A,B,C,D,E,'#008000','#00FF7F','#00CED1','#00BFFF',A,B,C,D,'#FF4500',E,'#9ACD32','#ADFF2F','#7FFFD4','#AFEEEE','#ADD8E6','#87CEEB','#8A2BE2','#FF00FF','#FF1493'];color_index_map=get_config_value(
|
|
1241
|
+
E='#FFFF00';D='#FF6347';C='#FF69B4';B='#9370DB';A='#1E90FF';color_list=['#FFC0CB','#FFA07A','#FFD700','#32CD32','#00FFFF',A,B,C,D,E,'#008000','#00FF7F','#00CED1','#00BFFF',A,B,C,D,'#FF4500',E,'#9ACD32','#ADFF2F','#7FFFD4','#AFEEEE','#ADD8E6','#87CEEB','#8A2BE2','#FF00FF','#FF1493'];color_index_map=get_config_value(_BN)
|
|
1241
1242
|
if not type_name in color_index_map:
|
|
1242
1243
|
new_color='#FFFFFF'
|
|
1243
1244
|
if len(color_index_map.keys())<len(color_list):new_color=color_list[len(color_index_map)]
|
|
@@ -1282,16 +1283,16 @@ class SBDL_Semantics:
|
|
|
1282
1283
|
if right_to_left:text_words.reverse()
|
|
1283
1284
|
text_words=[x.capitalize()if not x.isupper()else x for x in text_words];return SBDL_Parser.sanitize_identifier(separator.join(text_words))
|
|
1284
1285
|
@classmethod
|
|
1285
|
-
def get_identifier_from_string_eng_standard_v2(self,input_string,aggressive_length=20,min_word_len=3,separator='',right_to_left=_A):stop_words={'the','and','of','to','in','a','on','for','with','at','by','an','shall','should','must','will','can','may','might','could','be','have','use','then'};stop_chars={'a','e','i','o','u'};abbreviations={
|
|
1286
|
+
def get_identifier_from_string_eng_standard_v2(self,input_string,aggressive_length=20,min_word_len=3,separator='',right_to_left=_A):stop_words={'the','and','of','to','in','a','on','for','with','at','by','an','shall','should','must','will','can','may','might','could','be','have','use','then'};stop_chars={'a','e','i','o','u'};abbreviations={_CW:'accel','actuator':'act',_CX:'aero','analysis':'anal',_CY:'approx',_CZ:'arch','assembly':'assy',_Ca:'aux','battery':'batt',_Cb:'calc',_Cc:'cg',_Cd:'cm',_Ce:'coeff',_Cf:_At,_Cg:_At,_h:'ctrl',_Ch:'cntrlr',_Ci:'coord',_Cj:'corr','current':'curr',_Ck:'daq','decibel':'db',_Cl:'dof','define':'def','design':'des',_Cm:'dev','diameter':'dia',_Cn:'dim','dynamic':'dyn',_Co:'eff',_Cp:'elec',_Cq:'em','error':'err','estimate':'est',_Cr:'eval','execute':'exec',_Cs:_q,'fatigue':'fat','feature':'feat','feedback':'fb',_Ct:'freq',_AB:'func','gradient':'grad','hardware':'hw',_Cu:'ht',_Cv:'hv',_Ai:_r,_Cw:_r,_Cx:'impl',_Al:'in',_Cy:'insp',_Cz:'instr',_C_:'intg',_w:'intf',_D0:'iter','load':'ld','logic':'log',_D1:'maint','manage':'mg',_D2:'mgmt',_D3:'mfg','material':'matl','maximum':'max',_D4:'meas',_D5:'mech','minimum':'min','model':'mdl','momentum':'mom','nominal':'nom',_D6:'os',_D7:'opt',_Ak:'out',_D8:'param','perform':'perf',_D9:'perf','physics':'phys','position':'pos','power':'pwr','pressure':'pres','process':'proc',_DA:'pid',_DB:'qa',_DC:'rad',_DD:'redund',_Ah:'ref',_DE:'rel',_V:'req',_DF:'res',_DG:'resist','safety':'sfty','sensor':'sens',_DH:'sim','software':'sw',_DI:'spec',_DJ:'stab','static':'stat',_DK:'struc',_DL:'subsys',_A2:'sys',_DM:'temp','tension':'tens','testing':'test','thermal':'therm','torque':'torq',_DN:'trans',_DO:'uncert',_DP:'val',_DQ:'verif','voltage':'volt','weight':'wt','target':'targ'};return self.get_identifier_from_string(re.sub(_DR,'',input_string),aggressive_length,min_word_len,separator,stop_words=stop_words,stop_chars=stop_chars,abbreviations=abbreviations,right_to_left=right_to_left)
|
|
1286
1287
|
@classmethod
|
|
1287
|
-
def get_identifier_from_string_eng_standard_v1(self,input_string,aggressive_length=20,min_word_len=3,separator='',right_to_left=_A):stop_words={'the','and','of','to','in','a','on','for','with','at','by','an',_A2,'shall','should','must','will','can','may','might','could','be','have','use','perform','execute','define',
|
|
1288
|
+
def get_identifier_from_string_eng_standard_v1(self,input_string,aggressive_length=20,min_word_len=3,separator='',right_to_left=_A):stop_words={'the','and','of','to','in','a','on','for','with','at','by','an',_A2,'shall','should','must','will','can','may','might','could','be','have','use','perform','execute','define',_Cf,'manage','then'};stop_chars={'a','e','i','o','u'};abbreviations={_CW:'accel','actuator':'act',_CX:'aero','analysis':'anal',_CY:'approx',_CZ:'arch','assembly':'assy',_Ca:'aux','battery':'batt',_Cb:'calc',_Cc:'cg',_Cd:'cm',_Ce:'coeff',_Cg:_At,_h:'ctrl',_Ch:'cntrlr',_Ci:'coord',_Cj:'corr','current':'curr',_Ck:'daq','decibel':'db',_Cl:'dof','design':'des',_Cm:'dev','diameter':'dia',_Cn:'dim','dynamic':'dyn',_Co:'eff',_Cp:'elec',_Cq:'em','error':'err','estimate':'est',_Cr:'eval',_Cs:_q,'fatigue':'fat','feature':'feat','feedback':'fb',_Ct:'freq',_AB:'func','gradient':'grad','hardware':'hw',_Cu:'ht',_Cv:'hv',_Ai:_r,_Cw:_r,_Cx:'impl',_Al:'in',_Cy:'insp',_Cz:'instr',_C_:'intg',_w:'intf',_D0:'iter','load':'ld','logic':'log',_D1:'maint',_D2:'mgmt',_D3:'mfg','material':'matl','maximum':'max',_D4:'meas',_D5:'mech','minimum':'min','model':'mdl','momentum':'mom','nominal':'nom',_D6:'os',_D7:'opt',_Ak:'out',_D8:'param',_D9:'perf','physics':'phys','position':'pos','power':'pwr','pressure':'pres','process':'proc',_DA:'pid',_DB:'qa',_DC:'rad',_DD:'redund',_Ah:'ref',_DE:'rel',_V:'req',_DF:'res',_DG:'resist','safety':'sfty','sensor':'sens',_DH:'sim','software':'sw',_DI:'spec',_DJ:'stab','static':'stat',_DK:'struc',_DL:'subsys',_A2:'sys',_DM:'temp','tension':'tens','testing':'test','thermal':'therm','torque':'torq',_DN:'trans',_DO:'uncert',_DP:'val',_DQ:'verif','voltage':'volt','weight':'wt','target':'targ'};return self.get_identifier_from_string(re.sub(_DR,'',input_string),aggressive_length,min_word_len,separator,stop_words=stop_words,stop_chars=stop_chars,abbreviations=abbreviations,right_to_left=right_to_left)
|
|
1288
1289
|
@classmethod
|
|
1289
1290
|
def get_identifier_from_string_eng_standard(self,input_string,aggressive_length=20,min_word_len=3,separator='',right_to_left=_A):return self.get_identifier_from_string_eng_standard_v1(input_string=input_string,aggressive_length=aggressive_length,min_word_len=min_word_len,separator=separator,right_to_left=right_to_left)
|
|
1290
1291
|
@classmethod
|
|
1291
1292
|
def shorten_string_on_word_boundary(self,input_string,shorten_length):return _I.join(input_string.split()[-len(input_string[-shorten_length:].split()):])
|
|
1292
1293
|
@classmethod
|
|
1293
1294
|
def get_unique_id_from_string(self,input_string):
|
|
1294
|
-
digest=hashlib.sha256(input_string.encode('utf‑8')).digest();alphabet=get_config_value(
|
|
1295
|
+
digest=hashlib.sha256(input_string.encode('utf‑8')).digest();alphabet=get_config_value(_CP);length=get_config_value(_CO,number=_A);num=int.from_bytes(digest,'big');base=len(alphabet);smart_key=[]
|
|
1295
1296
|
while len(smart_key)<length:num,idx=divmod(num,base);smart_key.append(alphabet[idx])
|
|
1296
1297
|
return''.join(smart_key)
|
|
1297
1298
|
@classmethod
|
|
@@ -1441,7 +1442,7 @@ class SBDL_Element(SBDL_Parser.Parser_Hints):
|
|
|
1441
1442
|
if self.type()==target:result=_A
|
|
1442
1443
|
except Exception as _:pass
|
|
1443
1444
|
if not result:
|
|
1444
|
-
if isinstance(target,type)and hasattr(target,
|
|
1445
|
+
if isinstance(target,type)and hasattr(target,_DS):
|
|
1445
1446
|
if target.class_type_name()==self.type()or target.class_type_name()in self.types():result=_A
|
|
1446
1447
|
return result
|
|
1447
1448
|
Element_Relation=Element_Link
|
|
@@ -1459,7 +1460,7 @@ class SBDL_Element(SBDL_Parser.Parser_Hints):
|
|
|
1459
1460
|
if self.type()==target:result=_A
|
|
1460
1461
|
except Exception as _:pass
|
|
1461
1462
|
if not result:
|
|
1462
|
-
if isinstance(target,type)and hasattr(target,
|
|
1463
|
+
if isinstance(target,type)and hasattr(target,_DS):
|
|
1463
1464
|
if target.class_type_name()in self.types():result=_A
|
|
1464
1465
|
return result
|
|
1465
1466
|
def __init__(self,declaration_statement):
|
|
@@ -1471,7 +1472,7 @@ class SBDL_Element(SBDL_Parser.Parser_Hints):
|
|
|
1471
1472
|
if self.type()in SBDL_Semantics.type_properties:
|
|
1472
1473
|
for aprop in SBDL_Semantics.type_properties[self.type()]:self._gather_properties_from_attr_type(aprop)
|
|
1473
1474
|
for aprop in SBDL_Semantics.global_properties:self._gather_properties_from_attr_type(aprop)
|
|
1474
|
-
if get_config_value(
|
|
1475
|
+
if get_config_value(_Bg,number=_A):
|
|
1475
1476
|
for aprop in[x for x in declaration_statement.data().keys()if x.startswith(SBDL_Parser.Attributes.custom_prefix)]:self._gather_properties_from_attr_type(aprop)
|
|
1476
1477
|
self.__check_raise_attrs()
|
|
1477
1478
|
if not SBDL_Parser.Attributes.reference in self.properties():self.set_property(SBDL_Parser.Attributes.reference,self._definition.parser_element().reference())
|
|
@@ -1622,7 +1623,7 @@ class SBDL_Element(SBDL_Parser.Parser_Hints):
|
|
|
1622
1623
|
for link in self.links()+self.parents()+self.children()+self.related():
|
|
1623
1624
|
link_valid,link_error=link.validate_self(elements)
|
|
1624
1625
|
if not link_valid:is_valid=_C;error+=link_error
|
|
1625
|
-
if get_config_value(
|
|
1626
|
+
if get_config_value(_BT,number=_A):
|
|
1626
1627
|
if link.hash():
|
|
1627
1628
|
if link.identifier()in elements:
|
|
1628
1629
|
link_hash=link.hash();target_hash=elements[link.identifier()].hash()
|
|
@@ -1641,7 +1642,7 @@ class SBDL_Element(SBDL_Parser.Parser_Hints):
|
|
|
1641
1642
|
prune_list(self._links);prune_list(self._parents);prune_list(self._children);prune_list(self._related)
|
|
1642
1643
|
def is_meta(self):return self._is_meta
|
|
1643
1644
|
def pragma(self):return self._definition.data()[SBDL_Parser.Attributes.pragma]if self._definition!=_B and SBDL_Parser.Attributes.pragma in self._definition.data()else _B
|
|
1644
|
-
def hash(self):return hashlib.sha256(re.sub('\\s+',_I,self.definition().parser_element().content().strip()).encode()).hexdigest()[:get_config_value(
|
|
1645
|
+
def hash(self):return hashlib.sha256(re.sub('\\s+',_I,self.definition().parser_element().content().strip()).encode()).hexdigest()[:get_config_value(_BS,number=_A)]
|
|
1645
1646
|
@classmethod
|
|
1646
1647
|
def apply_operator(self,operator_element,element_stack):
|
|
1647
1648
|
link_info_key='implicit_link_source';operator_value=operator_element.parser_element().content().strip()
|
|
@@ -1900,7 +1901,7 @@ class SBDL_AST:
|
|
|
1900
1901
|
try:
|
|
1901
1902
|
statement_element=SBDL_Element.statement_to_element(parsed_object);statement_element.set_parser_hint(SBDL_Parser.Statements.scope,scope_map)
|
|
1902
1903
|
if not statement_element.identifier()in sbdl_elements:
|
|
1903
|
-
if get_config_value(
|
|
1904
|
+
if get_config_value(_C6,number=_A)and statement_element.description():statement_element.set_property(SBDL_Parser.Attributes.description_bsci,SBDL_Semantics.calc_bsci(statement_element.description(),'english'))
|
|
1904
1905
|
sbdl_elements[statement_element.identifier()]=statement_element;sbdl_e_stack.append((statement_element,{}))
|
|
1905
1906
|
else:error_count+=1;self.__parser_error(print_l,parsed_object.parser_element().reference(),'Element redefinition ({})'.format(statement_element.identifier()),parsed_object.parser_element().content())
|
|
1906
1907
|
except Exception as e:error_count+=1;self.__parser_error(print_l,parsed_object.parser_element().reference(),str(e),parsed_object.parser_element().content())
|
|
@@ -2162,7 +2163,7 @@ def msexcel_input_handler(file_reference):
|
|
|
2162
2163
|
return result,handler
|
|
2163
2164
|
def make_remote_file_local(file_reference):
|
|
2164
2165
|
local_file_reference=file_reference;parsed_file_reference=urllib.parse.urlparse(local_file_reference);error_string=_B
|
|
2165
|
-
if parsed_file_reference.scheme in['http','https','ftp','file://']and get_config_value(
|
|
2166
|
+
if parsed_file_reference.scheme in['http','https','ftp','file://']and get_config_value(_CA,number=_A):
|
|
2166
2167
|
try:local_file_reference,_=urllib.request.urlretrieve(local_file_reference)
|
|
2167
2168
|
except Exception as e:error_string=str(e)+_f+file_reference+']'
|
|
2168
2169
|
if error_string:raise Exception(error_string)
|
|
@@ -2217,7 +2218,7 @@ def get_parser_elements_from_filepath(filepath,elements_list,print_l=print_null,
|
|
|
2217
2218
|
updates=explicit_updates
|
|
2218
2219
|
if updates is _B:updates={SBDL_Parser.Macros.path:filepath,SBDL_Parser.Macros.file_name:file_name,SBDL_Parser.Macros.directory:dir_name}
|
|
2219
2220
|
local_directives.update(updates);return updates
|
|
2220
|
-
file_name=os.path.basename(filepath);file_ext=os.path.splitext(filepath)[1:][0];dir_name=filepath.replace(file_name,'');abs_path=os.path.abspath(filepath);native_sbdl_file=_A if get_config_value(
|
|
2221
|
+
file_name=os.path.basename(filepath);file_ext=os.path.splitext(filepath)[1:][0];dir_name=filepath.replace(file_name,'');abs_path=os.path.abspath(filepath);native_sbdl_file=_A if get_config_value(_BP)==file_ext else _C;update_per_file_directives()
|
|
2221
2222
|
def clear_context_directives(target_dict):
|
|
2222
2223
|
context_mac=context_directive_sniffer([],'','',{},all_entries_result=_A)
|
|
2223
2224
|
for entry_id in context_mac:target_dict.pop(entry_id,'')
|
|
@@ -2225,13 +2226,13 @@ def get_parser_elements_from_filepath(filepath,elements_list,print_l=print_null,
|
|
|
2225
2226
|
def import_directive(_,*inp):
|
|
2226
2227
|
nonlocal errors;param_path=''.join(inp);import_path=os.path.join(local_directives[SBDL_Parser.Macros.path].replace(local_directives[SBDL_Parser.Macros.file_name],''),param_path);file_directive_cache={SBDL_Parser.Macros.import_sbdl:local_directives[SBDL_Parser.Macros.import_sbdl],SBDL_Parser.Macros.path:local_directives[SBDL_Parser.Macros.path],SBDL_Parser.Macros.file_name:local_directives[SBDL_Parser.Macros.file_name],SBDL_Parser.Macros.directory:local_directives[SBDL_Parser.Macros.directory]}
|
|
2227
2228
|
try:
|
|
2228
|
-
print_l('Import: {}'.format(import_path));read_elements,import_errors=aggregate_all_parser_elements_from_files([import_path],do_recurse=get_config_value(
|
|
2229
|
+
print_l('Import: {}'.format(import_path));read_elements,import_errors=aggregate_all_parser_elements_from_files([import_path],do_recurse=get_config_value(_BW,number=_A),do_hidden=_C,print_l=print_l,file_opener=file_opener,read_input_set=read_input_set);elements_list.extend(read_elements);errors+=import_errors
|
|
2229
2230
|
if import_errors:raise Exception('(see prior error)')
|
|
2230
2231
|
except Exception as e:errors+=1;handle_error(str(e),'Error during import of "{}"'.format(param_path))
|
|
2231
2232
|
update_per_file_directives(file_directive_cache);return''if errors==0 else''.join(inp)
|
|
2232
2233
|
local_directives[SBDL_Parser.Macros.import_sbdl]=import_directive
|
|
2233
2234
|
def strip_comments(line):
|
|
2234
|
-
result=line;comment_markers=[SBDL_Parser.Tokens.comment,get_config_value(
|
|
2235
|
+
result=line;comment_markers=[SBDL_Parser.Tokens.comment,get_config_value(_BK)]
|
|
2235
2236
|
for comment_marker in comment_markers:
|
|
2236
2237
|
if comment_marker!=_B:
|
|
2237
2238
|
comment_marker_match=re.search(comment_marker,line)
|
|
@@ -2260,7 +2261,7 @@ def get_parser_elements_from_filepath(filepath,elements_list,print_l=print_null,
|
|
|
2260
2261
|
if pre_line==non_sbdl_line_prefix.strip():pre_line=prev_non_sbdl_non_empty_lines[-2].strip()
|
|
2261
2262
|
return pre_line
|
|
2262
2263
|
local_directives.update({SBDL_Parser.Macros.context:prev_non_sbdl_non_empty_lines[-1],SBDL_Parser.Macros.curline:non_sbdl_line_prefix,SBDL_Parser.Macros.preline:previous_line(),SBDL_Parser.Macros.sucline:next_non_sbdl_non_empty_lines[0],SBDL_Parser.Macros.line:str(line_count)})
|
|
2263
|
-
if get_config_value(
|
|
2264
|
+
if get_config_value(_Bf,number=_A):
|
|
2264
2265
|
try:result_line=SBDL_Parser.replace_directives(result_line,local_directives,throw_error=_A,print_l=print_l)[0].strip()
|
|
2265
2266
|
except SBDL_Parser.MacroReplaceException as macro_excep:
|
|
2266
2267
|
if not macro_excep.first_pass_can_ignore():raise macro_excep
|
|
@@ -2279,11 +2280,11 @@ def get_parser_elements_from_filepath(filepath,elements_list,print_l=print_null,
|
|
|
2279
2280
|
def append_line_EOF():append_line('',eof=_A)
|
|
2280
2281
|
def detect_block_start_end(line):
|
|
2281
2282
|
nonlocal native_sbdl_file;result=_C
|
|
2282
|
-
if re.search(SBDL_Parser.Tokens.prefix_block_start,line)or re.search(get_config_value(
|
|
2283
|
-
elif re.search(SBDL_Parser.Tokens.prefix_block_end,line)or re.search(get_config_value(
|
|
2283
|
+
if re.search(SBDL_Parser.Tokens.prefix_block_start,line)or re.search(get_config_value(_BH),line):native_sbdl_file=_A;result=_A
|
|
2284
|
+
elif re.search(SBDL_Parser.Tokens.prefix_block_end,line)or re.search(get_config_value(_BI),line):native_sbdl_file=_C;result=_A
|
|
2284
2285
|
return result
|
|
2285
2286
|
def extract_sbdl_line_non_native(line):
|
|
2286
|
-
nonlocal non_sbdl_line_prefix;result='';custom_prefix=get_config_value(
|
|
2287
|
+
nonlocal non_sbdl_line_prefix;result='';custom_prefix=get_config_value(_BF);custom_suffix=get_config_value(_BG);custom_noop=get_config_value(_BJ)
|
|
2287
2288
|
if re.search(SBDL_Parser.Tokens.prefix,line):non_sbdl_line_prefix,result=re.split(SBDL_Parser.Tokens.prefix,line,maxsplit=1)
|
|
2288
2289
|
elif re.search(custom_prefix,line):
|
|
2289
2290
|
non_sbdl_line_prefix,result=re.split(custom_prefix,line,maxsplit=1)
|
|
@@ -2326,11 +2327,11 @@ def aggregate_all_parser_elements_from_files(input_list,do_recurse,do_hidden,pri
|
|
|
2326
2327
|
else:print_l('Skipping directory: {}'.format(afile))
|
|
2327
2328
|
elif is_input_file(afile):
|
|
2328
2329
|
if not is_hidden(afile)or do_hidden:
|
|
2329
|
-
print_l(
|
|
2330
|
+
print_l(_DT.format(afile))
|
|
2330
2331
|
try:parser_elements=[];errors_l=get_parser_elements_from_filepath(afile,parser_elements,print_l,file_opener,read_input_set);errors+=errors_l;aggregated_elements.extend(parser_elements)
|
|
2331
2332
|
except Exception as e:errors+=1;print_l('Error reading: {}\n {}'.format(afile,str(e)),error=_A)
|
|
2332
2333
|
else:print_l('Skipping hidden file: {}'.format(afile))
|
|
2333
|
-
else:errors+=1;print_l(
|
|
2334
|
+
else:errors+=1;print_l(_DU.format(afile),error=_A)
|
|
2334
2335
|
return aggregated_elements,errors
|
|
2335
2336
|
def data_tree_node_to_element(identifier,data_node):
|
|
2336
2337
|
if not isinstance(data_node,dict):raise Exception('Trying to extract tree information from not dict object')
|
|
@@ -2383,14 +2384,14 @@ def plantuml_writer(file_opener,output_file,content,_):
|
|
|
2383
2384
|
content_to_output=content
|
|
2384
2385
|
if not get_config_value(_AU,number=_A):
|
|
2385
2386
|
try:
|
|
2386
|
-
plantuml_env=os.environ.copy();plantuml_env.pop('LD_LIBRARY_PATH',_B);plantuml_env['PLANTUML_LIMIT_SIZE']=str(get_config_value(
|
|
2387
|
+
plantuml_env=os.environ.copy();plantuml_env.pop('LD_LIBRARY_PATH',_B);plantuml_env['PLANTUML_LIMIT_SIZE']=str(get_config_value(_Bc));plantuml_command=get_config_value(_Bb)
|
|
2387
2388
|
if isinstance(plantuml_command,str):plantuml_command=shlex.split(plantuml_command)
|
|
2388
|
-
plantuml_command_full=plantuml_command+['-t',get_config_value(
|
|
2389
|
+
plantuml_command_full=plantuml_command+['-t',get_config_value(_Bd),'-p'];debug_out('EXECUTE_PLANTUML: '+str(plantuml_command_full));exec_result=subprocess.run(plantuml_command_full,input=content.encode(),stdout=subprocess.PIPE,stderr=subprocess.STDOUT,env=plantuml_env,check=_C);content_to_output=exec_result.stdout
|
|
2389
2390
|
except:raise Exception('Error while executing PlantUML')
|
|
2390
2391
|
with file_opener(output_file,is_text=get_config_value(_AU,number=_A))as plantuml_file:plantuml_file.write(content_to_output)
|
|
2391
2392
|
def plantuml_footer_generator():
|
|
2392
2393
|
footer_content=''
|
|
2393
|
-
if get_config_value(
|
|
2394
|
+
if get_config_value(_Be,number=_A):footer_content+='footer \\nGenerated by {generator} on {date}\\n\\n\n'.format(generator='{} version {}'.format(__NAME,__VERSION),date=get_date_string())
|
|
2394
2395
|
return footer_content
|
|
2395
2396
|
def plantuml_identifier(in_string):
|
|
2396
2397
|
result=in_string.strip(_I).replace('/',_U).replace(_O,_U).replace('-',_U).replace(_d,_U)
|
|
@@ -2400,7 +2401,7 @@ def write_requirement_graph_output(sbdl_ast,output_file,file_opener,arguments,pr
|
|
|
2400
2401
|
B='rtype';A='rid';elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);requirements={k:v for(k,v)in elements.items()if v.is_a(SBDL_Requirement)};title_sanitized=SBDL_Parser.sanitize_identifier(arguments.title);root_requirement=SBDL_Element_Synthetic(title_sanitized,'',SBDL_Parser.Types.requirement,_B);root_requirement.add_link(SBDL_Element.Element_Link(title_sanitized,SBDL_Parser.Types.aspect));top_level_requirements=[]
|
|
2401
2402
|
for(rid,rev)in requirements.items():
|
|
2402
2403
|
if len(SBDL_AST.get_all_parents_for_element(rev,requirements))==0:top_level_requirements.append({A:rid,B:rev.type()})
|
|
2403
|
-
if len(top_level_requirements)==1 and not get_config_value(
|
|
2404
|
+
if len(top_level_requirements)==1 and not get_config_value(_Bs):root_requirement=requirements[top_level_requirements[0][A]]
|
|
2404
2405
|
else:
|
|
2405
2406
|
for top_level_requirement in top_level_requirements:root_requirement.add_child(SBDL_Element.Element_Link(top_level_requirement[A],top_level_requirement[B]))
|
|
2406
2407
|
def line_wrap(content,columns=1000):return _H.join(textwrap.wrap(content,columns))
|
|
@@ -2417,23 +2418,23 @@ def write_requirement_graph_output(sbdl_ast,output_file,file_opener,arguments,pr
|
|
|
2417
2418
|
else:prefix+='<'
|
|
2418
2419
|
rtype=''
|
|
2419
2420
|
if depth==1:rtype='<<source>>'
|
|
2420
|
-
elif depth<=get_config_value(
|
|
2421
|
+
elif depth<=get_config_value(_Br):rtype='<<toplevel>>'
|
|
2421
2422
|
else:rtype='<<regular>>'
|
|
2422
|
-
occurrences=len(SBDL_AST.get_all_parents_for_element(r_element,requirements));output='{prefix} <i>{aspect} </i>\\n<b>{rid} </b>\\n{rdesc}{occ} {rtype}\n'.format(prefix=prefix,aspect=line_wrap(r_element.get_ids_string(sbdl_ast.get_all_links_for_element(r_element,elements),SBDL_Aspect)),rid=r_element.identifier(),rdesc=sanitize_desc(r_element.description()),occ='\\n<i>[{} occurrences]</i>'.format(occurrences)if occurrences>1 else'',rtype=rtype);children=SBDL_AST.get_all_children_for_element(r_element,requirements);children.sort(key=lambda x:requirements[x.identifier()].get_ids_string(sbdl_ast.get_all_links_for_element(requirements[x.identifier()],elements),SBDL_Aspect));last_child_aspect=_B;prefix=_P*(depth+1);aspect_groups=get_config_value(
|
|
2423
|
+
occurrences=len(SBDL_AST.get_all_parents_for_element(r_element,requirements));output='{prefix} <i>{aspect} </i>\\n<b>{rid} </b>\\n{rdesc}{occ} {rtype}\n'.format(prefix=prefix,aspect=line_wrap(r_element.get_ids_string(sbdl_ast.get_all_links_for_element(r_element,elements),SBDL_Aspect)),rid=r_element.identifier(),rdesc=sanitize_desc(r_element.description()),occ='\\n<i>[{} occurrences]</i>'.format(occurrences)if occurrences>1 else'',rtype=rtype);children=SBDL_AST.get_all_children_for_element(r_element,requirements);children.sort(key=lambda x:requirements[x.identifier()].get_ids_string(sbdl_ast.get_all_links_for_element(requirements[x.identifier()],elements),SBDL_Aspect));last_child_aspect=_B;prefix=_P*(depth+1);aspect_groups=get_config_value(_Bq)
|
|
2423
2424
|
for child in children:
|
|
2424
2425
|
child_aspect=requirements[child.identifier()].get_ids_string(sbdl_ast.get_all_links_for_element(requirements[child.identifier()],elements),SBDL_Aspect)
|
|
2425
2426
|
if aspect_groups and child_aspect!=last_child_aspect:last_child_aspect=child_aspect;output+='{prefix} <i>{aspect} </i> <<aspect>>\n'.format(prefix=prefix,aspect=child_aspect)
|
|
2426
2427
|
lr=not lr;output+=output_requirement_tree(requirements[child.identifier()],depth+2 if aspect_groups else depth+1,path+[r_element.identifier()],lr)
|
|
2427
2428
|
return output
|
|
2428
2429
|
def plantuml_requirement_diagram_wrap(content):
|
|
2429
|
-
header=plantuml_footer_generator();legend_text='';legend=get_config_value(
|
|
2430
|
+
header=plantuml_footer_generator();legend_text='';legend=get_config_value(_Bu)
|
|
2430
2431
|
if legend!=_B:legend_text='legend\n{legend_content}\nendlegend\n'.format(legend_content=legend)
|
|
2431
|
-
plant_uml_prepost='@startwbs\n{style}\n\n{header}\n{content}\n{legend}@endwbs\n';return plant_uml_prepost.format(style=get_config_value(_X)+get_config_value(
|
|
2432
|
+
plant_uml_prepost='@startwbs\n{style}\n\n{header}\n{content}\n{legend}@endwbs\n';return plant_uml_prepost.format(style=get_config_value(_X)+get_config_value(_Bt),header=header,content=content,legend=legend_text)
|
|
2432
2433
|
plantuml_writer(file_opener,output_file,plantuml_requirement_diagram_wrap(output_requirement_tree(root_requirement)),print_l);return errors
|
|
2433
2434
|
def write_decomposition_graph_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
2434
2435
|
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A)
|
|
2435
2436
|
def plantuml_decomposition_diagram():
|
|
2436
|
-
header=plantuml_footer_generator();title=_A3.format(arguments.title)if arguments.title!=''else'';plant_uml_prepost=_A4;content='';notes='';note_count=0;interface_count=0;relations='';descriptions=get_config_value(
|
|
2437
|
+
header=plantuml_footer_generator();title=_A3.format(arguments.title)if arguments.title!=''else'';plant_uml_prepost=_A4;content='';notes='';note_count=0;interface_count=0;relations='';descriptions=get_config_value(_Bx,number=_A);interface_mem={};handled_elems=[];indentation_prefix=_M
|
|
2437
2438
|
def puml_id(elem_id):return plantuml_identifier(elem_id)
|
|
2438
2439
|
def note_rel_pos(posindex):positions={0:'top',1:'bottom',2:_AG,3:_AH};return positions[posindex%4]
|
|
2439
2440
|
def interface_rel_pos(posindex):positions={0:'up',1:'down',2:_AG,3:_AH};return positions[posindex%4]if get_config_value(_AV,number=_A)else''
|
|
@@ -2451,7 +2452,7 @@ def write_decomposition_graph_output(sbdl_ast,output_file,file_opener,arguments,
|
|
|
2451
2452
|
aspect_stereotype=elements[elem_id].stereotype()
|
|
2452
2453
|
if not aspect_stereotype:aspect_stereotype=elements[elem_id].type()
|
|
2453
2454
|
else:aspect_stereotype=elements[elem_id].type()+_d+aspect_stereotype
|
|
2454
|
-
aspect_stereotype=_Au.format(aspect_stereotype);content+=
|
|
2455
|
+
aspect_stereotype=_Au.format(aspect_stereotype);content+=_DV.format(pref,get_config_value(_Bv),elem_id,puml_id(elem_id),aspect_stereotype,''if not SBDL_Parser.Attributes.color in elements[elem_id].properties()else' #'+elements[elem_id].get_property(SBDL_Parser.Attributes.color));children=SBDL_AST.get_all_children_for_element(elements[elem_id],elements)
|
|
2455
2456
|
if len(children)>0 or len(interfaces):
|
|
2456
2457
|
content+=' { '
|
|
2457
2458
|
for port in ports:port_type='port'if len(interface_mem)%2==0 else'portout';add_interface_line(port,port_type,indentation_prefix)
|
|
@@ -2464,13 +2465,13 @@ def write_decomposition_graph_output(sbdl_ast,output_file,file_opener,arguments,
|
|
|
2464
2465
|
if relation_type.startswith(SBDL_Parser.Tokens.inherit):relation_end='|>'
|
|
2465
2466
|
elif elements[relation.identifier()].is_a(SBDL_Interface):relation_end='('
|
|
2466
2467
|
elif relation_type.startswith(SBDL_Parser.Tokens.compose):relation_end=_P
|
|
2467
|
-
relations+=
|
|
2468
|
+
relations+=_DW.format(puml_id(elem_id),interface_rel_pos(interface_count),relation_end,puml_id(relation.identifier()),link_text);interface_count+=1
|
|
2468
2469
|
else:0
|
|
2469
2470
|
elements_ordered=list(elements.keys());elements_ordered.sort(key=lambda key:len(SBDL_AST.get_all_parents_for_element(elements[key],elements)))
|
|
2470
2471
|
for elem in elements_ordered:handle_elem(elem)
|
|
2471
2472
|
for interface_id in interface_mem:
|
|
2472
2473
|
for int_link in interface_mem[interface_id]:relations+='{} .{}. {}\n'.format(puml_id(interface_id),interface_rel_pos(interface_count),puml_id(int_link.identifier()));interface_count+=1
|
|
2473
|
-
return plant_uml_prepost.format(style=(
|
|
2474
|
+
return plant_uml_prepost.format(style=(_DX if get_config_value(_AW,number=_A)else'')+get_config_value(_X)+get_config_value(_Aa),header=header+title,content=content+_E+relations+_E+(_E+notes if descriptions or arguments.source else''))
|
|
2474
2475
|
plantuml_writer(file_opener,output_file,plantuml_decomposition_diagram(),print_l);return errors
|
|
2475
2476
|
def write_element_graph_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
2476
2477
|
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A)
|
|
@@ -2480,7 +2481,7 @@ def write_element_graph_output(sbdl_ast,output_file,file_opener,arguments,print_
|
|
|
2480
2481
|
def interface_rel_pos(posindex):positions={0:'up',1:'down',2:_AG,3:_AH};return positions[posindex%4]if get_config_value(_AV,number=_A)else''
|
|
2481
2482
|
def detailed_content(elem_id):
|
|
2482
2483
|
props=[];links={};result='\t{}: **{}**\n'.format(SBDL_Parser.Attributes.type,elements[elem_id].type());elem=elements[elem_id]
|
|
2483
|
-
for prop in elem.properties():props.append('\t{}:\n\t {}'.format(prop,textwrap.shorten(elem.get_property(prop),width=get_config_value(
|
|
2484
|
+
for prop in elem.properties():props.append('\t{}:\n\t {}'.format(prop,textwrap.shorten(elem.get_property(prop),width=get_config_value(_C0,number=_A),placeholder='...')))
|
|
2484
2485
|
for link in elem.links():
|
|
2485
2486
|
if not link.type()in links:links[link.type()]=[]
|
|
2486
2487
|
links[link.type()].append(link.identifier())
|
|
@@ -2501,20 +2502,20 @@ def write_element_graph_output(sbdl_ast,output_file,file_opener,arguments,print_
|
|
|
2501
2502
|
aspect_stereotype=elements[elem_id].stereotype()
|
|
2502
2503
|
if not aspect_stereotype:aspect_stereotype=elements[elem_id].type()
|
|
2503
2504
|
else:aspect_stereotype=elements[elem_id].type()+_d+aspect_stereotype
|
|
2504
|
-
aspect_stereotype=_Au.format(aspect_stereotype);content+=
|
|
2505
|
+
aspect_stereotype=_Au.format(aspect_stereotype);content+=_DV.format(pref,get_config_value(_Bw),elem_id,puml_id(elem_id),aspect_stereotype,''if not SBDL_Parser.Attributes.color in elements[elem_id].properties()else' #'+elements[elem_id].get_property(SBDL_Parser.Attributes.color));content+='{{\n{}\n}}\n'.format(detailed_content(elem_id));related=elements[elem_id].related();related.extend([link for link in elements[elem_id].links()])
|
|
2505
2506
|
for relation in related:
|
|
2506
2507
|
relation_type=relation.stereotype();relation_type=relation_type if relation_type else'';link_text=': '+relation_type if relation_type else'';relation_end='>'
|
|
2507
2508
|
if relation_type.startswith(SBDL_Parser.Tokens.inherit):relation_end='|>'
|
|
2508
2509
|
elif elements[relation.identifier()].is_a(SBDL_Parser.Types.interface):relation_end='('
|
|
2509
2510
|
elif relation_type.startswith(SBDL_Parser.Tokens.compose):relation_end=_P
|
|
2510
|
-
relations+=
|
|
2511
|
+
relations+=_DW.format(puml_id(elem_id),interface_rel_pos(interface_count),relation_end,puml_id(relation.identifier()),link_text)
|
|
2511
2512
|
else:0
|
|
2512
2513
|
elements_ordered=list(elements.keys())
|
|
2513
2514
|
for elem in elements_ordered:handle_elem(elem)
|
|
2514
|
-
return plant_uml_prepost.format(style=(
|
|
2515
|
+
return plant_uml_prepost.format(style=(_DX if get_config_value(_AW,number=_A)else'')+get_config_value(_X)+get_config_value(_Aa),header=header+title,content=content+_E+relations+_E+(_E+''))
|
|
2515
2516
|
plantuml_writer(file_opener,output_file,plantuml_decomposition_diagram(),print_l);return errors
|
|
2516
2517
|
def write_function_graph_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
2517
|
-
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);show_descriptions=get_config_value(
|
|
2518
|
+
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);show_descriptions=get_config_value(_By,number=_A);event_count=0;entities={}
|
|
2518
2519
|
def puml_id(elem_id):return plantuml_identifier(elem_id)
|
|
2519
2520
|
def plantuml_function_diagram():
|
|
2520
2521
|
header=plantuml_footer_generator();title=_A3.format(arguments.title)if arguments.title!=''else'';plant_uml_prepost=_A4;content='';empty_aspect_replace=_A1
|
|
@@ -2534,7 +2535,7 @@ def write_function_graph_output(sbdl_ast,output_file,file_opener,arguments,print
|
|
|
2534
2535
|
else:aspect_stereotype=elements[aspect_name].type()+_d+aspect_stereotype
|
|
2535
2536
|
aspect_stereotype=_Au.format(aspect_stereotype);aspect_color=''
|
|
2536
2537
|
if aspect_name in elements and SBDL_Parser.Attributes.color in elements[aspect_name].properties():aspect_color=f" #{elements[aspect_name].get_property(SBDL_Parser.Attributes.color)}"
|
|
2537
|
-
content+='{}{} "{}{}" as {} {}{}\n'.format(_M*depth,get_config_value(
|
|
2538
|
+
content+='{}{} "{}{}" as {} {}{}\n'.format(_M*depth,get_config_value(_Bz),aspect_name,_H+elements[aspect_name].reference()if arguments.source else'',puml_id(aspect_name),aspect_stereotype,aspect_color)
|
|
2538
2539
|
content+='group {}<<{}>> {}{} #red\n'.format(elem_colour_prefix(func_element),f"{func_element.type()}::{func_element.stereotype()}"if func_element.stereotype()else func_element.type(),puml_id(func_element.identifier()),_H+func_element.reference()if arguments.source else'')
|
|
2539
2540
|
if show_descriptions:content+='{}note across: {}\n'.format(_M*depth,func_element.description())
|
|
2540
2541
|
for child in children:
|
|
@@ -2572,7 +2573,7 @@ def write_function_graph_output(sbdl_ast,output_file,file_opener,arguments,print
|
|
|
2572
2573
|
return plant_uml_prepost.format(style=get_config_value(_X)+get_config_value(_Ab),header=header+title,content=content)
|
|
2573
2574
|
plantuml_writer(file_opener,output_file,plantuml_function_diagram(),print_l);return errors
|
|
2574
2575
|
def write_process_graph_output(sbdl_ast,output_file,file_opener,_,print_l):
|
|
2575
|
-
errors=0;elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);show_descriptions=get_config_value(
|
|
2576
|
+
errors=0;elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);show_descriptions=get_config_value(_B_,number=_A);first_event=_A;g_process_elem=_B;note_stagger=_C
|
|
2576
2577
|
def elem_colour_prefix(elem):
|
|
2577
2578
|
colour=''
|
|
2578
2579
|
if SBDL_Parser.Attributes.color in elem.properties():colour=f"#{elem.get_property(SBDL_Parser.Attributes.color)} "
|
|
@@ -2622,7 +2623,7 @@ def write_process_graph_output(sbdl_ast,output_file,file_opener,_,print_l):
|
|
|
2622
2623
|
process_dia_cont+='\n@enduml\n';return process_dia_cont
|
|
2623
2624
|
plantuml_writer(file_opener,output_file,plantuml_process_diagram(),print_l);return errors
|
|
2624
2625
|
def write_state_graph_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
2625
|
-
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);show_descriptions=get_config_value(
|
|
2626
|
+
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);show_descriptions=get_config_value(_C2,number=_A)
|
|
2626
2627
|
def plantuml_state_diagram():
|
|
2627
2628
|
header=plantuml_footer_generator();title=_A3.format(arguments.title)if arguments.title!=''else'';plant_uml_prepost=_A4;statedefs='';statedefs_dict={};transitions_visited={};content='';relations=''
|
|
2628
2629
|
def handle_elem(elem_id,depth=0):
|
|
@@ -2638,7 +2639,7 @@ def write_state_graph_output(sbdl_ast,output_file,file_opener,arguments,print_l)
|
|
|
2638
2639
|
for elem_id in top_level_elems:
|
|
2639
2640
|
if elements[elem_id].is_a(SBDL_State):handle_elem(elem_id)
|
|
2640
2641
|
for statedef in statedefs_dict:statedefs+=statedefs_dict[statedef]+_E
|
|
2641
|
-
return plant_uml_prepost.format(style=get_config_value(_X)+get_config_value(
|
|
2642
|
+
return plant_uml_prepost.format(style=get_config_value(_X)+get_config_value(_C1),header=header+title,content=statedefs+content+_E+relations)
|
|
2642
2643
|
plantuml_writer(file_opener,output_file,plantuml_state_diagram(),print_l);return errors
|
|
2643
2644
|
def write_usecase_graph_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
2644
2645
|
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A)
|
|
@@ -2656,18 +2657,18 @@ def write_usecase_graph_output(sbdl_ast,output_file,file_opener,arguments,print_
|
|
|
2656
2657
|
content+='\nframe "{}" {{\n'.format(puml_id(aspect))
|
|
2657
2658
|
for usecase_tuple in aspects[aspect]:content+=' usecase "{}" as {}\n'.format('**{}**\\n{}{}'.format(usecase_tuple[3],_H.join(textwrap.wrap(usecase_tuple[4],get_config_value(_c,number=_A))),_H+usecase_tuple[6]if arguments.source else'')if get_config_value(_Ac,number=_A)else usecase_tuple[3],puml_id(usecase_tuple[3]));relations+='\n{} --> {}: {}{}\n'.format(puml_id(usecase_tuple[0]),puml_id(usecase_tuple[3]),'**{}**\\n{}'.format(usecase_tuple[1],_H.join(textwrap.wrap(usecase_tuple[2],get_config_value(_c,number=_A))))if get_config_value(_Ac,number=_A)else usecase_tuple[1],_H+usecase_tuple[5]if arguments.source else'')
|
|
2658
2659
|
content+='}\n'
|
|
2659
|
-
content+=relations;return plant_uml_prepost.format(style=get_config_value(_X)+get_config_value(
|
|
2660
|
+
content+=relations;return plant_uml_prepost.format(style=get_config_value(_X)+get_config_value(_C3),header=header+title,content=content)
|
|
2660
2661
|
plantuml_writer(file_opener,output_file,plantuml_usecase_diagram(),print_l);return errors
|
|
2661
2662
|
def write_network_graph_output(sbdl_ast,output_file,_,arguments,print_l):
|
|
2662
2663
|
try:import networkx as nx,matplotlib.pyplot as plt
|
|
2663
2664
|
except Exception as _:print_l('Could not import Python packages necessary for network graph rendering: networkx, matplotlib',error=_A);return 1
|
|
2664
|
-
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);sbdl_graph=nx.MultiDiGraph();skip_types={x for x in get_config_value(
|
|
2665
|
+
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);sbdl_graph=nx.MultiDiGraph();skip_types={x for x in get_config_value(_Bp,number=_C).split(_S)};node_name_sep=_d;node_text_wrap_width=25
|
|
2665
2666
|
def node_name(elem_id):
|
|
2666
2667
|
etype=elements[elem_id].type();stereotype=elements[elem_id].stereotype()
|
|
2667
2668
|
if stereotype:stereotype=f"\n<<{etype}∷{stereotype}>>"
|
|
2668
2669
|
else:stereotype=f"\n<<{etype}>>"
|
|
2669
2670
|
node_text=_E.join(textwrap.wrap('{}{}{}'.format(elem_id,node_name_sep,elements[elem_id].type()),width=node_text_wrap_width));node_text+=stereotype
|
|
2670
|
-
if get_config_value(
|
|
2671
|
+
if get_config_value(_Bl,number=_A):node_text+=_i+_E.join(textwrap.wrap(elements[elem_id].description(),width=node_text_wrap_width))
|
|
2671
2672
|
if arguments.source:node_text+=_i+_E.join(textwrap.wrap(elements[elem_id].reference(),width=node_text_wrap_width))
|
|
2672
2673
|
return node_text
|
|
2673
2674
|
def elem_id_f(node_name):return node_name_sep.join(node_name.replace(_E,'').split(node_name_sep)[:-1])
|
|
@@ -2683,11 +2684,11 @@ def write_network_graph_output(sbdl_ast,output_file,_,arguments,print_l):
|
|
|
2683
2684
|
def mpl(graphin):return nx.multipartite_layout(graphin,subset_key='elem_type')
|
|
2684
2685
|
def dot(graphin):return nx.nx_agraph.graphviz_layout(graphin,prog='dot',args='-Goverlap=false -Goverlap_scaling=1000000 -Gscale={} -Gsep=20 -Gdefaultdist=100000'.format(get_config_value(_AZ,number=_A)))
|
|
2685
2686
|
def spring(graphin):return nx.spring_layout(graphin,k=1)
|
|
2686
|
-
layouts={
|
|
2687
|
+
layouts={_CQ:mpl,'graphviz':dot,'spring':spring,'spiral':nx.spiral_layout,'random':nx.random_layout,'planar':nx.planar_layout};options={'font_size':10,'node_size':get_config_value(_AZ,number=_A),'edgecolors':'gray','edge_color':'darkgray','linewidths':1,'with_labels':get_config_value(_Bm,number=_A),'width':2,'node_color':colour_list,'node_shape':'s','pos':layouts[get_config_value(_Bn,number=_C)](sbdl_graph)};plt.figure(figsize=(get_config_value(_Bj,number=_A),get_config_value(_Bk,number=_A)));nx.draw_networkx(sbdl_graph,**options,alpha=1.);ax=plt.gca();ax.margins(.0);plt.axis('off');plt.tight_layout();plt.plot();plt.savefig(output_file,dpi=get_config_value(_Bo,number=_A));return errors
|
|
2687
2688
|
class OpenFMEA:
|
|
2688
2689
|
@classmethod
|
|
2689
2690
|
def generate_sbdl_table_from_ast(self,sbdl_ast,id_in_body=_C,source_in_body=_C,print_l=print_null,multi_field_separator=_B):
|
|
2690
|
-
A='key';complex_aspect=get_config_value(
|
|
2691
|
+
A='key';complex_aspect=get_config_value(_CL,number=_A)
|
|
2691
2692
|
if multi_field_separator is _B:multi_field_separator=get_config_value(_Ad)
|
|
2692
2693
|
id_counter=0;sbdl_row={A:_B,_e:_B,_V:_B,_L:_B,_a:_B,_R:_B,_h:_B,_j:_B,_y:_B,_z:_B,_AD:_B,_x:_B,_AC:_B,_A5:_B,_k:_B}
|
|
2693
2694
|
def is_row_empty(row):
|
|
@@ -2735,7 +2736,7 @@ class OpenFMEA:
|
|
|
2735
2736
|
else:result_rows=[in_row]
|
|
2736
2737
|
return result_rows
|
|
2737
2738
|
for elem_id in path:elements[elem_id].visited=_A
|
|
2738
|
-
rows_to_add=[row];expand_attrs=get_config_value(
|
|
2739
|
+
rows_to_add=[row];expand_attrs=get_config_value(_CE)
|
|
2739
2740
|
if len(expand_attrs)>0:
|
|
2740
2741
|
for exp_attr in expand_attrs.split(_S):rows_to_add=expand_rows_by_compound_attribute(rows_to_add,exp_attr)
|
|
2741
2742
|
for add_row in rows_to_add:add_row_local(flatten_row(add_row))
|
|
@@ -2751,13 +2752,13 @@ class OpenFMEA:
|
|
|
2751
2752
|
if link.identifier()in elements:result.append(element_text(elements[link.identifier()]))
|
|
2752
2753
|
return'({})'.format(_F.join(result))if len(result)>0 else''
|
|
2753
2754
|
if not element.identifier()in path:
|
|
2754
|
-
path[element.identifier()]=_A;custom_prop_prefix=SBDL_Parser.Attributes.custom_prefix+get_config_value(
|
|
2755
|
+
path[element.identifier()]=_A;custom_prop_prefix=SBDL_Parser.Attributes.custom_prefix+get_config_value(_BQ)
|
|
2755
2756
|
for aprop in element.properties():
|
|
2756
2757
|
if aprop.startswith(custom_prop_prefix):passthrough_attribute_key=aprop.replace(custom_prop_prefix,'',1);passthrough_attribute_value=element.get_property(aprop);assign_column_value(passthrough_attribute_key,passthrough_attribute_value)
|
|
2757
2758
|
if element.identifier()==start_node.identifier():recurse_links(SBDL_Failure_Cause)
|
|
2758
2759
|
elif element.identifier()==end_node.identifier():
|
|
2759
2760
|
print_l('ADD',element.identifier(),debug=_A)
|
|
2760
|
-
if not is_fully_meta()and(get_config_value(
|
|
2761
|
+
if not is_fully_meta()and(get_config_value(_CG,number=_A)or not is_partly_meta()):add_row()
|
|
2761
2762
|
elif element.is_a(SBDL_Failure_Cause):
|
|
2762
2763
|
events=get_compounded_linked_events();assign_column(_R,_I+events if len(events)>0 else'');assign_column_value(_z,element.rating());assign_column_value(_AD,element.rating(post=_A))
|
|
2763
2764
|
if not element.is_meta():
|
|
@@ -2786,12 +2787,12 @@ class OpenFMEA:
|
|
|
2786
2787
|
return rows
|
|
2787
2788
|
def get_orphans(elements_l):
|
|
2788
2789
|
rows=[]
|
|
2789
|
-
if get_config_value(
|
|
2790
|
+
if get_config_value(_CF,number=_A):
|
|
2790
2791
|
for el in elements_l:
|
|
2791
2792
|
if not'visited'in vars(elements[el])and not elements[el].is_a(SBDL_Event)and not elements[el].is_meta():print_l('ORPHAN',elements[el].identifier(),debug=_A);rows.extend(generate_table(elements[el],row=sbdl_row.copy(),add_single=_A))
|
|
2792
2793
|
return rows
|
|
2793
2794
|
def apply_smart_keys(input_rows):
|
|
2794
|
-
if get_config_value(
|
|
2795
|
+
if get_config_value(_CH,number=_A):
|
|
2795
2796
|
for row in input_rows:
|
|
2796
2797
|
join_props=[_V,_R,_L,_a];join_string=''
|
|
2797
2798
|
for join_prop in join_props:
|
|
@@ -2840,7 +2841,7 @@ class OpenFMEA:
|
|
|
2840
2841
|
with file_opener(output_file)as open_sbdl_file:OpenFMEA.write_struct_to_file(OpenFMEA.struct_from_table(arguments.title,self.replace_table_entries_in_place(sbdl_table,_B,'')),open_sbdl_file)
|
|
2841
2842
|
return errors
|
|
2842
2843
|
@classmethod
|
|
2843
|
-
def get_quickshare_output(self,sbdl_ast,arguments,print_l):mem_file=io.StringIO();sbdl_table,errors=OpenFMEA.generate_sbdl_table_from_ast(sbdl_ast,id_in_body=arguments.identifier,source_in_body=arguments.source,print_l=print_l);OpenFMEA.write_struct_to_file(OpenFMEA.struct_from_table(arguments.title,self.replace_table_entries_in_place(sbdl_table,_B,'')),mem_file,pretty=_C);mem_file.seek(0);compressed_openfmea=base64.b64encode(zlib.compress(mem_file.read().encode(_o))).decode(_o);mem_file.close();output_uri='{baseurl}/analyzer/?QUICK_SHARE#>>{content}<<'.format(baseurl=get_config_value(
|
|
2844
|
+
def get_quickshare_output(self,sbdl_ast,arguments,print_l):mem_file=io.StringIO();sbdl_table,errors=OpenFMEA.generate_sbdl_table_from_ast(sbdl_ast,id_in_body=arguments.identifier,source_in_body=arguments.source,print_l=print_l);OpenFMEA.write_struct_to_file(OpenFMEA.struct_from_table(arguments.title,self.replace_table_entries_in_place(sbdl_table,_B,'')),mem_file,pretty=_C);mem_file.seek(0);compressed_openfmea=base64.b64encode(zlib.compress(mem_file.read().encode(_o))).decode(_o);mem_file.close();output_uri='{baseurl}/analyzer/?QUICK_SHARE#>>{content}<<'.format(baseurl=get_config_value(_CI),content=compressed_openfmea);return errors,output_uri
|
|
2844
2845
|
@classmethod
|
|
2845
2846
|
def write_quickshare_output(self,sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
2846
2847
|
errors,output_uri=self.get_quickshare_output(sbdl_ast,arguments,print_l)
|
|
@@ -2893,7 +2894,7 @@ class OpenFMEA:
|
|
|
2893
2894
|
@classmethod
|
|
2894
2895
|
def elements_from_table(self,sbdl_table,_):
|
|
2895
2896
|
multi_field_separator=get_config_value(_Ad);elems_to_consider={_e:SBDL_Parser.Types.aspect,_V:SBDL_Parser.Types.requirement,_L:SBDL_Parser.Types.mode,_a:SBDL_Parser.Types.effect,_R:SBDL_Parser.Types.cause,_h:SBDL_Parser.Types.current_control,_j:SBDL_Parser.Types.current_detection,_A5:SBDL_Parser.Types.action_control,_k:SBDL_Parser.Types.action_detection};elem_rating={_a:_y,_R:_z,_L:_x};elem_rating_post={_R:_AD,_L:_AC};elem_link={_R:[_L,_h,_A5,_j,_k],_L:[_e,_a,_j,_V,_k,_R],_V:[_e,_L],_a:[_L],_h:[_R],_j:[_L],_A5:[_R],_k:[_L]};elem_present_every_row={_j,_k};replace_str=SBDL_Parser.Tokens.replacement_string_default;elements={};id_lookup={}
|
|
2896
|
-
if not get_config_value(
|
|
2897
|
+
if not get_config_value(_CK,number=_A):elem_link[_L].remove(_R);elem_link[_a].remove(_L)
|
|
2897
2898
|
def get_id_from_attr(attr_type,attr):
|
|
2898
2899
|
A='$COUNTER$';result=self.get_id_from_string(attr)
|
|
2899
2900
|
if result!=_B:0
|
|
@@ -2989,9 +2990,9 @@ class OpenFMEA:
|
|
|
2989
2990
|
if hidden or recurse:raise Exception('Cannot recurse for OpenFMEA input files')
|
|
2990
2991
|
aggregated_elements=[];errors=0
|
|
2991
2992
|
for input_file in source_files:
|
|
2992
|
-
print_l(
|
|
2993
|
+
print_l(_DT.format(input_file))
|
|
2993
2994
|
if is_input_file(input_file):open_sbdl_data=self.read_file(input_file);aggregated_elements.extend(self.statements_from_openfmea(open_sbdl_data,input_file))
|
|
2994
|
-
else:errors+=1;print_l(
|
|
2995
|
+
else:errors+=1;print_l(_DU.format(input_file),error=_A)
|
|
2995
2996
|
set_config_value(_A7,_A);set_config_value(_A8,_A);return aggregated_elements,errors
|
|
2996
2997
|
@classmethod
|
|
2997
2998
|
def aggregate_all_parser_elements_from_quickshare(self,source_files,recurse,hidden,_):
|
|
@@ -3029,14 +3030,14 @@ def write_aggregated_output(sbdl_ast,output_file,file_opener,__,print_l):
|
|
|
3029
3030
|
if sort_by_type or sort_by_iden:sbdl_elements.sort(key=gen_sort_key)
|
|
3030
3031
|
fmfile.write(SBDL_Parser.Tokens.hashbang+_E)
|
|
3031
3032
|
for element in sbdl_elements:
|
|
3032
|
-
if not get_config_value(
|
|
3033
|
-
print_l('Writing element: {}'.format(element.identifier()),debug=_A);fmfile.write('{}{} {}'.format(element.definition().string(),SBDL_Parser.Tokens.statement_separator if get_config_value(
|
|
3033
|
+
if not get_config_value(_BO,number=_A):element.delete_property(SBDL_Parser.Attributes.reference)
|
|
3034
|
+
print_l('Writing element: {}'.format(element.identifier()),debug=_A);fmfile.write('{}{} {}'.format(element.definition().string(),SBDL_Parser.Tokens.statement_separator if get_config_value(_BM,number=_A)else'',new_line_str))
|
|
3034
3035
|
return errors
|
|
3035
3036
|
def write_rpc_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
3036
3037
|
A='sbdl_statements';print_l('Remote processing to output [{}]: {}'.format(arguments.rpc,output_file),debug=_A);sbdl_elements,errors=sbdl_ast.elements();sbdl_statement_strings=[sbdl_elements[e].definition().string()for e in sbdl_elements]
|
|
3037
3038
|
if arguments.rpc==_B:errors+=1;print_l('RPC parameter required',error=_A)
|
|
3038
3039
|
else:
|
|
3039
|
-
rpc_result=rest_api_call(arguments.rpc,{
|
|
3040
|
+
rpc_result=rest_api_call(arguments.rpc,{_CS:str(sys.argv),A:sbdl_statement_strings},print_l)
|
|
3040
3041
|
with file_opener(output_file)as outfile:
|
|
3041
3042
|
if isinstance(rpc_result,dict):
|
|
3042
3043
|
if A in rpc_result and isinstance(rpc_result[A],list):outfile.write(_E.join(rpc_result[A]))
|
|
@@ -3086,7 +3087,7 @@ def apply_template_to_officex_files(officex_dir,sbdl_ast,print_l):
|
|
|
3086
3087
|
def template_docx_file(template_dict,infile,outfile):warnings.filterwarnings(_A6,category=UserWarning,module='docxcompose');docxtpl=lazy_import('docxtpl');word_template=docxtpl.DocxTemplate(infile);word_template.render(template_dict);word_template.save(outfile)
|
|
3087
3088
|
def write_template_fill(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
3088
3089
|
elements,errors=sbdl_ast.elements();full_dict,errors_dict=sbdl_ast.get_full_ast_as_dict(elements);errors+=errors_dict;template_context={_b:full_dict}
|
|
3089
|
-
if get_config_value(
|
|
3090
|
+
if get_config_value(_CJ,number=_A):openfmea,errors_fmea=OpenFMEA.generate_sbdl_table_from_ast(sbdl_ast,id_in_body=arguments.identifier,source_in_body=arguments.source,print_l=print_l);errors+=errors_fmea;template_context[_AK]=openfmea
|
|
3090
3091
|
file_ext=os.path.splitext(arguments.template)[1]
|
|
3091
3092
|
if arguments.template==_B:print_l('Template file not specified',error=_A);errors+=1
|
|
3092
3093
|
elif file_ext in['.docx']:debug_out('Word Docx template detected');template_docx_file(template_context,arguments.template,output_file)
|
|
@@ -3142,7 +3143,7 @@ def install_package(package_name,package_url,install_target,print_l):
|
|
|
3142
3143
|
except Exception as e:print_l(str(e),error=_A);errors+=1
|
|
3143
3144
|
return errors
|
|
3144
3145
|
def update_self(print_l,force=_C):
|
|
3145
|
-
print_l(f"Updating {__NAME}...");ret,stdout,stderr=exec_external([sys.executable,_G,'pip','install',*(['--trusted-host',f"{urllib.parse.urlparse(__URL).netloc}"]if force else[]),'--upgrade',urllib.parse.urljoin(url(),get_config_value(
|
|
3146
|
+
print_l(f"Updating {__NAME}...");ret,stdout,stderr=exec_external([sys.executable,_G,'pip','install',*(['--trusted-host',f"{urllib.parse.urlparse(__URL).netloc}"]if force else[]),'--upgrade',urllib.parse.urljoin(url(),get_config_value(_BU)),*(['--break-system-packages']if force else[])]);print_l(stdout)
|
|
3146
3147
|
if ret!=0:print_l('Error during update:',error=_A);print_l(stderr,error=_A)
|
|
3147
3148
|
return ret
|
|
3148
3149
|
def initialise_dependencies(print_l):
|
|
@@ -3152,7 +3153,7 @@ def initialise_dependencies(print_l):
|
|
|
3152
3153
|
print_l(f"Installation complete (errors: {errors}).");return errors
|
|
3153
3154
|
def get_cache_file_path(input_file):
|
|
3154
3155
|
cache_file_path=_B
|
|
3155
|
-
if input_file!=SBDL_Parser.Tokens.stdio_name:cache_file_path=f"{input_file}{get_config_value(
|
|
3156
|
+
if input_file!=SBDL_Parser.Tokens.stdio_name:cache_file_path=f"{input_file}{get_config_value(_BY)}"
|
|
3156
3157
|
return cache_file_path
|
|
3157
3158
|
def check_ast_cache(do_caching,source_files,print_l):
|
|
3158
3159
|
valid_cache=_C;cache_file=_B
|
|
@@ -3221,7 +3222,7 @@ def main(arguments):
|
|
|
3221
3222
|
else:print_l('Encountered {} errors during: {} {}'.format(error_count,step,content),error=_A)
|
|
3222
3223
|
else:print_l(f"{step} done [{time.time()-step_time_point:.3f}s]")
|
|
3223
3224
|
step_time_point=time.time()
|
|
3224
|
-
operations={_Aw:write_aggregated_output,'aggregate':write_aggregated_output,'query':query_output,_AL:write_matrixcsv_output,'matrixcsv':write_matrixcsv_output,_AM:write_matrixjson_output,'matrixjson':write_matrixjson_output,_Ax:write_yaml_tree_output,
|
|
3225
|
+
operations={_Aw:write_aggregated_output,'aggregate':write_aggregated_output,'query':query_output,_AL:write_matrixcsv_output,'matrixcsv':write_matrixcsv_output,_AM:write_matrixjson_output,'matrixjson':write_matrixjson_output,_Ax:write_yaml_tree_output,_DY:write_csv_output,'fmeacsv':write_csv_output,_AK:OpenFMEA.write_opensbdl_output,'openfmea-quickshare':OpenFMEA.write_quickshare_output,_Ay:OpenFMEA.write_opensbdl_portfolio_output,A:write_aggregated_output,_Az:write_aggregated_output,B:write_aggregated_output,C:write_aggregated_output,_A_:write_decomposition_graph_output,_B0:write_element_graph_output,_B1:write_requirement_graph_output,_B2:write_network_graph_output,_B3:write_function_graph_output,_B4:write_process_graph_output,_B5:write_state_graph_output,_B6:write_usecase_graph_output,_DZ:write_template_fill,'rpc':write_rpc_output,_AN:write_aggregated_output,_B7:write_aggregated_output,_AO:write_aggregated_output,'type-info':write_type_information,'lsp':lsp_start};macro_errors=0
|
|
3225
3226
|
for amacropath in arguments.custom_directive:macro_errors+=import_custom_directive_file(amacropath,print_l)
|
|
3226
3227
|
check_step('Custom directive import',macro_errors);mode_errors=0
|
|
3227
3228
|
for amodepath in arguments.custom_mode:
|
|
@@ -3234,8 +3235,8 @@ def main(arguments):
|
|
|
3234
3235
|
if arguments.already_processed:print_l('Input should be treated as already-processed');arguments.skip_validation=_A;set_config_value(_AA,_C)
|
|
3235
3236
|
if not arguments.mode in operations:print_l('Mode "{}" is not in available modes'.format(arguments.mode),error=_A);check_step('Mode selection',1,ignorable=_C)
|
|
3236
3237
|
if len(arguments.source_files)==0:print_l('WARNING: no source files specified',error=_A)
|
|
3237
|
-
aggregate_methods={_Az:OpenFMEA.aggregate_all_parser_elements_from_files,A:OpenFMEA.aggregate_all_parser_elements_from_quickshare,C:OpenFMEA.aggregate_all_parser_elements_from_files,B:OpenFMEA.aggregate_all_parser_elements_from_quickshare,_AN:aggregate_all_parser_elements_from_json,_B7:aggregate_all_parser_elements_from_yaml,_AO:aggregate_all_parser_elements_from_csv};aggregation_method=aggregate_all_parser_elements_from_files if not arguments.mode in aggregate_methods else aggregate_methods[arguments.mode];parser_elements,read_errors=aggregation_method([fix_wsl_path(x)for x in arguments.source_files],arguments.recurse,arguments.hidden,print_l);check_step('File reading',read_errors);sbdl_ast=load_ast_cache(parser_elements,get_config_value(
|
|
3238
|
-
for pre_hook in get_config_value(
|
|
3238
|
+
aggregate_methods={_Az:OpenFMEA.aggregate_all_parser_elements_from_files,A:OpenFMEA.aggregate_all_parser_elements_from_quickshare,C:OpenFMEA.aggregate_all_parser_elements_from_files,B:OpenFMEA.aggregate_all_parser_elements_from_quickshare,_AN:aggregate_all_parser_elements_from_json,_B7:aggregate_all_parser_elements_from_yaml,_AO:aggregate_all_parser_elements_from_csv};aggregation_method=aggregate_all_parser_elements_from_files if not arguments.mode in aggregate_methods else aggregate_methods[arguments.mode];parser_elements,read_errors=aggregation_method([fix_wsl_path(x)for x in arguments.source_files],arguments.recurse,arguments.hidden,print_l);check_step('File reading',read_errors);sbdl_ast=load_ast_cache(parser_elements,get_config_value(_BX,number=_A),arguments.source_files,print_l);check_step('Parsing',sbdl_ast.check_parsing(print_l))
|
|
3239
|
+
for pre_hook in get_config_value(_BR):check_step('Pre Hook: {}'.format(pre_hook.__name__),pre_hook(sbdl_ast,print_l))
|
|
3239
3240
|
sbdl_elements,statement_errors=sbdl_ast.elements(print_l);check_step('Element instantiation',statement_errors)
|
|
3240
3241
|
if arguments.filter_related!=_B:sbdl_ast.add_filter_element_set_connected(arguments.filter_related,arguments.filter_depth)
|
|
3241
3242
|
if arguments.filter_related_x!=_B:sbdl_ast.add_filter_element_set_linked(arguments.filter_related_x,arguments.filter_depth)
|
|
@@ -3250,7 +3251,7 @@ def main(arguments):
|
|
|
3250
3251
|
if arguments.trace:trace_elements,trace_errors=aggregate_all_parser_elements_from_files(arguments.trace,arguments.recurse,arguments.hidden,print_l);_,trace_process_errors=sbdl_ast.process_trace_elements(trace_elements,print_l);trace_errors+=trace_process_errors;check_step('Tracing',trace_errors)
|
|
3251
3252
|
for post_hook in get_config_value(_m):check_step('Post Hook: {}'.format(post_hook.__name__),post_hook(sbdl_ast,print_l))
|
|
3252
3253
|
print_l('Mode: {}'.format(arguments.mode));print_l('Writing: {}'.format(arguments.output));check_step('Output writing',operations[arguments.mode](sbdl_ast,arguments.output,open_output_file,arguments,print_l));print_l('C_DEF GLOBALS: {}'.format(get_config_value(_T)),debug=_A);print_l(f"All operations complete [{time.time()-start_time_point:.3f}s]");add_profile_mem_snapshot('main_compilation_process');return total_errors if not arguments.skip_errors else 0
|
|
3253
|
-
def handle_arguments(args_l):F='append';E='config_file';D='normal';C='output_file';B='element_identifier';A='store_true';operating_modes={_Aw:'Parse all specified input files, gather SBDL elements, validate model, apply filters, write SBDL-formatted output','query':'Compile inputs, then pretty print the results (after filtering)',_AL:'Compile inputs, then write a CSV-formatted representation of the SBDL elements to the output',_AM:'Compile inputs, then write a JSON-formatted representation of the SBDL elements to the output',_Ax:'Compile inputs, then write a YAML-formatted representation of the SBDL elements to the output',_AO:'Read SBDL-schema CSV-matrix inputs and write SBDL-formatted output',_AN:'Read SBDL-schema JSON-tree inputs and write SBDL-formatted output',_B7:'Read SBDL-schema YAML-tree inputs and write SBDL-formatted output',_AK:'Compile inputs, then write the FMEA-related content to an OpenFMEA-formatted ouput',_Ay:'Compile inputs, then write the FMEA-related content to an OpenFMEA Portfolio-formatted ouput, organised by aspect hierarchy',_Az:'Read OpenFMEA-formatted input and write SBDL-formatted output',
|
|
3254
|
+
def handle_arguments(args_l):F='append';E='config_file';D='normal';C='output_file';B='element_identifier';A='store_true';operating_modes={_Aw:'Parse all specified input files, gather SBDL elements, validate model, apply filters, write SBDL-formatted output','query':'Compile inputs, then pretty print the results (after filtering)',_AL:'Compile inputs, then write a CSV-formatted representation of the SBDL elements to the output',_AM:'Compile inputs, then write a JSON-formatted representation of the SBDL elements to the output',_Ax:'Compile inputs, then write a YAML-formatted representation of the SBDL elements to the output',_AO:'Read SBDL-schema CSV-matrix inputs and write SBDL-formatted output',_AN:'Read SBDL-schema JSON-tree inputs and write SBDL-formatted output',_B7:'Read SBDL-schema YAML-tree inputs and write SBDL-formatted output',_AK:'Compile inputs, then write the FMEA-related content to an OpenFMEA-formatted ouput',_Ay:'Compile inputs, then write the FMEA-related content to an OpenFMEA Portfolio-formatted ouput, organised by aspect hierarchy',_Az:'Read OpenFMEA-formatted input and write SBDL-formatted output',_DY:'Compile inputs, then write the FMEA-related content to a CSV-formatted ouput',_B2:'Compile inputs, then write a PNG-formatted output, visually representing the network of SBDL elements',_B1:'Compile inputs, then write a SysML-style requirements diagram to rendering-backend-formatted output',_A_:'Compile inputs, then write a SysML-style block diagram to rendering-backend-formatted output (simplified, aspects only)',_B0:'Compile inputs, then write a SysML-style block diagram to rendering-backend-formatted output (detailed, with properties and relations)',_B3:'Compile inputs, then write a SysML-style sequence diagram to rendering-backend-formatted output',_B4:'Compile inputs, then write a SysML-style activity diagram to rendering-backend-formatted output',_B5:'Compile inputs, then write a SysML-style state diagram to rendering-backend-formatted output',_B6:'Compile inputs, then write a SysML-style use-case diagram to rendering-backend-formatted output',_DZ:"Compile inputs, then provide an object, 'sbdl', in a Jinja parsing environment and apply it to the specified template file",'rpc':'Compile inputs, then transmit to the RPC server for processing by the specified RPC (see --rpc)'};parser=argparse.ArgumentParser(description='{}\n\n{} Version {} (DSL Version {}). System Behaviour Description Language (SBDL) compiler.\nWWW: {}. Author: {}.'.format(logo(),name().upper(),version(),version_dsl(),url(),author()),epilog='e.g. "'+os.path.basename(sys.argv[0])+' <file 1> <file 2> <file n>"\n\n---------------\nOperating Modes\n---------------\n{}'.format(_E.join(['{}: {}'.format(x.rjust(25),operating_modes[x])for x in operating_modes])),formatter_class=argparse.RawDescriptionHelpFormatter);parser._positionals.title='Base Arguments';parser._optionals.title='Optional Arguments';parser.add_argument('source_files',help='List of files to compile ["-" implies stdin]',nargs=_P);parser.add_argument(_G,'--mode',metavar='operating_mode',help='Specify the mode of operation',default=_Aw);parser.add_argument(_D,'--output',metavar=C,help='Specify the name of the output file',default=SBDL_Parser.Tokens.stdio_name);parser.add_argument('--version',help='Print the current version',action=A,default=_C);parser.add_argument('--debug',help=argparse.SUPPRESS,action=A,default=_C);parser.add_argument('-W','-w','--warning',help='Set warning level',choices=[D,'all'],default=D);parser.add_argument('--hidden',help='Include hidden files when recursing',action=A,default=_C);parser.add_argument('-i','--identifier',help='Include element identifiers in applicable output formats',action=A,default=_C);parser.add_argument('-s','--source',help='Include source reference in applicable output formats',action=A,default=_C);parser.add_argument('-r','--recurse',help='Recurse on directories specified in the input list',action=A,default=_C);parser.add_argument('--skip-errors',help='Do not stop for errors (emit warning instead)',action=A,default=_C);parser.add_argument('--skip-validation',help='Do not validate model elements and relations',action=A,default=_C);parser.add_argument('--already-processed',help='Disables certain processing actions (implies --skip-validation). Useful when input has already been processed',action=A,default=_C);parser.add_argument('--title',help='Provide a default title for certain output formats',default='');parser.add_argument('-v','--verbose',help='Enable verbose output during execution',action=A,default=_C);parser.add_argument('--dumpaffinitygraph',metavar=C,help=argparse.SUPPRESS,action=_B);parser.add_argument('--dumplanginfo',metavar=C,help=argparse.SUPPRESS,action=_B);parser.add_argument('--run_tests','--run-tests',action=A,help=argparse.SUPPRESS);parser.add_argument('--rest-api-ping',action=A,help=argparse.SUPPRESS);parser.add_argument('--manual',help='Show extensive {} manual page'.format(name().upper()),action=A);parser.add_argument('--dump-config','--dumpconfig',metavar=E,help='Dump the internal configuration to a named JSON file',action=_B);parser.add_argument('--load-config','--loadconfig',metavar=E,help='Load the internal configuration from a named JSON file',default=_B);parser.add_argument('--list-config','--listconfig',help='List internal configuration options',action=A,default=_C);parser.add_argument('--set-config','--setconfig',metavar=('config_option','config_value'),help='Set a named configuration option',action=F,nargs=2);parser.add_argument('-D','--define',metavar=('name','value'),help='Specify a named global definition',action=F,nargs=2);parser.add_argument('--trace',metavar='trace_files',help='Provide a trace file to be processed',default=_B,nargs=_P);parser.add_argument('--template',metavar='template_file',help="Specify a template file for the 'template-fill' mode",default=_B);parser.add_argument('-fr','--filter-related',metavar=B,help='Filter everything but those elements with a direct or indirect relation to the specified element identifier (regex) [INCLUDES: parents/children]',default=_B);parser.add_argument('-frx','--filter-related-x',metavar=B,help='Filter everything but those elements with a direct or indirect connection to the specified element identifier (regex) [EXCLUDES: parents/children]',default=_B);parser.add_argument('-fch','--filter-children',metavar=B,help='Filter everything but those elements which are children of the specified element identifier (regex)',default=_B);parser.add_argument('-fpa','--filter-parents',metavar=B,help='Filter everything but those elements which are parental ancestors of the specified element identifier (regex)',default=_B);parser.add_argument('-fd','--filter-depth',metavar='filter_depth',help='Maximum depth for filters which pursue links (natural number)',type=int,default=_B);parser.add_argument('-ft','--filter-type',metavar='element_type',help='Filter everything but those elements which are of the specified element type (regex)',default=_B);parser.add_argument('-fi','--filter-identifier',metavar=B,help='Filter everything but those elements whose identifiers match the specified string (regex)',default=_B);parser.add_argument('-fpr','--filter-property',metavar=('property_name','property_value'),help='Filter everything but those elements possessing a named property matching the specified string (regex)',default=_B,nargs=2);parser.add_argument('-fg','--filter-group',metavar='group_identifier',help='Shortcut filter for everything but those elements which are children of the specified group identifier (regex) -- excludes the group element itself',default=_B);parser.add_argument(_Da,metavar='compiler_definitions',help='Specify a file path defining custom compiler directives',default=[],nargs=_P);parser.add_argument(_Db,'--custom_mode',metavar='mode_definitions',help='Specify a file path containing custom compiler modes',default=[],nargs=_P);parser.add_argument('--rpc',help='Remote Procedure Call to be used by RPC-based modes',default=_B);parser.add_argument('--update',help=argparse.SUPPRESS,action=A,default=_C);parser.add_argument('--update-force',help=argparse.SUPPRESS,action=A,default=_C);parser.add_argument('--install-deps',help=argparse.SUPPRESS,action=A,default=_C);help_tmp=io.StringIO();parser.print_help(file=help_tmp);help_tmp.seek(0);global __HELP_TEXT;__HELP_TEXT=help_tmp.read();return parser.parse_args(args_l)
|
|
3254
3255
|
def show_manual(_):
|
|
3255
3256
|
B='----------------------\n';A='===========================================================\n';manual_text=A;manual_text+=' {} Manual\n'.format(name().upper());manual_text+=A;manual_text+=help_text()+_E;manual_text+=B;manual_text+='Model Type Information\n';manual_text+=B
|
|
3256
3257
|
def add_manual(strcon=''):nonlocal manual_text;manual_text+=strcon+_E
|
|
@@ -3268,7 +3269,7 @@ def show_manual(_):
|
|
|
3268
3269
|
add_manual('\n-------------------');add_manual('Compiler Directives');add_manual('-------------------\n')
|
|
3269
3270
|
for directive in sbdl_directives:add_manual(' {}: {}'.format(directive,sbdl_directives[directive]))
|
|
3270
3271
|
try:
|
|
3271
|
-
manual_command=get_config_value(
|
|
3272
|
+
manual_command=get_config_value(_C7)
|
|
3272
3273
|
if isinstance(manual_command,str)and len(manual_command)==0:f_print(_E+manual_text,prefix=_B)
|
|
3273
3274
|
else:
|
|
3274
3275
|
if not isinstance(manual_command,list):manual_command=shlex.split(manual_command)
|
|
@@ -3295,8 +3296,8 @@ class LanguageLevelTests(unittest.TestCase):
|
|
|
3295
3296
|
def testEscaping(self):main(handle_arguments(['test/escaped_directive_test.sbdl',_D,self.TEST_OUTPUT_FILE]))
|
|
3296
3297
|
def testCustomDirectiveImport(self):main(handle_arguments(['test/directive_imp_test.sbdl',_D,self.TEST_OUTPUT_FILE]))
|
|
3297
3298
|
def testProlog(self):main(handle_arguments(['test/test_prolog.sbdl',_D,self.TEST_OUTPUT_FILE]))
|
|
3298
|
-
def testCustomDirective(self):main(handle_arguments([_J,
|
|
3299
|
-
def testCustomModes(self):main(handle_arguments([_J,'--mode','test_mode',
|
|
3299
|
+
def testCustomDirective(self):main(handle_arguments([_J,_Da,_Dc,_D,self.TEST_OUTPUT_FILE]))
|
|
3300
|
+
def testCustomModes(self):main(handle_arguments([_J,'--mode','test_mode',_Db,_Dc,_D,self.TEST_OUTPUT_FILE]))
|
|
3300
3301
|
def testIdFromProp(self):main(handle_arguments(['test/id_from_prop.sbdl',_D,self.TEST_OUTPUT_FILE]))
|
|
3301
3302
|
def testDirectiveChain(self):main(handle_arguments(['test/macro_chain.sbdl',_D,self.TEST_OUTPUT_FILE]))
|
|
3302
3303
|
def testMarkDownRefs(self):main(handle_arguments(['test/test.md',_D,self.TEST_OUTPUT_FILE]))
|
|
@@ -3328,10 +3329,10 @@ class LanguageSemanticTests(unittest.TestCase):
|
|
|
3328
3329
|
def test_geneal_relations_check(self):
|
|
3329
3330
|
for elem in self.sbdl_elements:0
|
|
3330
3331
|
def test_existence_type_semantic_check(self):
|
|
3331
|
-
expected_elem_type={_B9:SBDL_Aspect,'rocket_booster':SBDL_Aspect,_BA:SBDL_Aspect,
|
|
3332
|
+
expected_elem_type={_B9:SBDL_Aspect,'rocket_booster':SBDL_Aspect,_BA:SBDL_Aspect,_Dd:SBDL_Aspect,_BB:SBDL_Requirement,_De:SBDL_Requirement,_Df:SBDL_Requirement,_BC:SBDL_Function,_Dg:SBDL_Event,_Dh:SBDL_Event,_Di:SBDL_State,_Dj:SBDL_State,_BD:SBDL_Transition,_Dk:SBDL_Event}
|
|
3332
3333
|
for elem in expected_elem_type:0
|
|
3333
3334
|
def test_existence_semantic_relation(self):
|
|
3334
|
-
relations_between={
|
|
3335
|
+
relations_between={_Dd:_BA,_BB:_B9,_De:_BB,_Df:_BA,_BC:_B9,_Dg:_BC,_Dh:_Dk,_Di:_BD,_Dj:_BD}
|
|
3335
3336
|
def relation_exists(elemidA,elemidB):return elemidB in[*[x.identifier()for x in SBDL_AST.get_all_children_for_element(self.sbdl_elements[elemidA],self.sbdl_elements)],*[x.identifier()for x in SBDL_AST.get_all_parents_for_element(self.sbdl_elements[elemidA],self.sbdl_elements)],*[x.identifier()for x in SBDL_AST.get_all_links_for_element(self.sbdl_elements[elemidA],self.sbdl_elements)]]
|
|
3336
3337
|
for elem in relations_between:0
|
|
3337
3338
|
def run_tests(_):errors=0;test_results=unittest.main(argv=[name()],exit=_C,verbosity=2).result;errors=errors+len(test_results.failures)+len(test_results.errors);return errors
|
|
@@ -3382,15 +3383,15 @@ def whoopsie_handler(whoopsie):
|
|
|
3382
3383
|
except Exception as _:w_print('Could not print stack trace')
|
|
3383
3384
|
w_print(A);sys.exit(99)
|
|
3384
3385
|
def init_profiling():
|
|
3385
|
-
global main,main_original;profile_output=get_config_value(
|
|
3386
|
+
global main,main_original;profile_output=get_config_value(_CN);profile_output_mem=get_config_value(_u)
|
|
3386
3387
|
def wrap_main(ARGS):
|
|
3387
3388
|
f_print(f"Profiling performance to: {profile_output}",warning=_A,do_warning=_A);cProfile=lazy_import('cProfile')
|
|
3388
3389
|
def profile_main():main_original(ARGS)
|
|
3389
3390
|
cProfile.runctx('profile_main()',globals(),locals(),profile_output)
|
|
3390
3391
|
if profile_output is not _B:main_original=main;main=wrap_main
|
|
3391
|
-
if profile_output_mem is not _B:f_print(f"Profiling memory to: {profile_output_mem}",warning=_A,do_warning=_A);
|
|
3392
|
+
if profile_output_mem is not _B:f_print(f"Profiling memory to: {profile_output_mem}",warning=_A,do_warning=_A);lazy_import(_BE).start()
|
|
3392
3393
|
def add_profile_mem_snapshot(snapshot_name):
|
|
3393
|
-
if get_config_value(_u)is not _B:add_to_config_value(_v,{snapshot_name:
|
|
3394
|
+
if get_config_value(_u)is not _B:add_to_config_value(_v,{snapshot_name:lazy_import(_BE,'Tracemalloc not available').take_snapshot()})
|
|
3394
3395
|
def add_profile_mem_counter(counter_name,counter_incrememnt=1):
|
|
3395
3396
|
if get_config_value(_u)is not _B:
|
|
3396
3397
|
snapshots=get_config_value(_v)
|
|
@@ -3399,7 +3400,7 @@ def add_profile_mem_counter(counter_name,counter_incrememnt=1):
|
|
|
3399
3400
|
def deinit_profiling():
|
|
3400
3401
|
A='----------------\n';profile_output_mem=get_config_value(_u)
|
|
3401
3402
|
if profile_output_mem is not _B:
|
|
3402
|
-
current,peak=tracemalloc.get_traced_memory();tracemalloc.stop()
|
|
3403
|
+
tracemalloc=lazy_import(_BE);current,peak=tracemalloc.get_traced_memory();tracemalloc.stop()
|
|
3403
3404
|
with open(profile_output_mem,'w',encoding=_o)as profile_output_file:
|
|
3404
3405
|
profile_output_file.write(A);profile_output_file.write(' General Stats\n');profile_output_file.write(A);profile_output_file.write(f"Memory in use at termination: {current/1024**2:.2f} MB\n");profile_output_file.write(f"Peak memory during execution: {peak/1024**2:.2f} MB\n")
|
|
3405
3406
|
for(snapshot_name,snapshot)in get_config_value(_v).items():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|