sbdl 1.18.15__tar.gz → 1.18.16__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.18.15 → sbdl-1.18.16}/PKG-INFO +1 -1
- {sbdl-1.18.15 → sbdl-1.18.16}/sbdl.egg-info/PKG-INFO +1 -1
- {sbdl-1.18.15 → sbdl-1.18.16}/sbdl.py +76 -68
- {sbdl-1.18.15 → sbdl-1.18.16}/setup.py +1 -1
- {sbdl-1.18.15 → sbdl-1.18.16}/csv-to-sbdl.py +0 -0
- {sbdl-1.18.15 → sbdl-1.18.16}/sbdl +0 -0
- {sbdl-1.18.15 → sbdl-1.18.16}/sbdl.egg-info/SOURCES.txt +0 -0
- {sbdl-1.18.15 → sbdl-1.18.16}/sbdl.egg-info/dependency_links.txt +0 -0
- {sbdl-1.18.15 → sbdl-1.18.16}/sbdl.egg-info/requires.txt +0 -0
- {sbdl-1.18.15 → sbdl-1.18.16}/sbdl.egg-info/top_level.txt +0 -0
- {sbdl-1.18.15 → sbdl-1.18.16}/sbdl_server.py +0 -0
- {sbdl-1.18.15 → sbdl-1.18.16}/setup.cfg +0 -0
|
@@ -1,35 +1,36 @@
|
|
|
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
|
-
|
|
2
|
+
_Cd='SteeringFirmware::correctCourse'
|
|
3
|
+
_Cc='rocket_in_motion'
|
|
4
|
+
_Cb='rocket_ready'
|
|
5
|
+
_Ca='correct_course'
|
|
6
|
+
_CZ='fire_booster'
|
|
7
|
+
_CY='steering_requirement_1'
|
|
8
|
+
_CX='booster_requirement_1'
|
|
9
|
+
_CW='steering_firmware'
|
|
10
|
+
_CV='test/macro.py'
|
|
11
|
+
_CU='--custom-mode'
|
|
12
|
+
_CT='--custom-directive'
|
|
13
|
+
_CS='template-fill'
|
|
14
|
+
_CR='openfmea-csv'
|
|
15
|
+
_CQ='skinparam linetype ortho\n'
|
|
16
|
+
_CP='{} .{}.{} {}{}\n'
|
|
17
|
+
_CO='\n{}{} "{}" as {} {}{}'
|
|
18
|
+
_CN='Not a file: {}'
|
|
19
|
+
_CM='Reading: {}'
|
|
20
|
+
_CL='class_type_name'
|
|
21
|
+
_CK='unicode_escape'
|
|
22
|
+
_CJ='identifier'
|
|
23
|
+
_CI='reference'
|
|
24
|
+
_CH='^\\s*{}\\s*{}.*?{}\\s*$'
|
|
25
|
+
_CG='customtype'
|
|
26
|
+
_CF='arguments'
|
|
27
|
+
_CE='skinparam NoteBackgroundColor LightSteelBlue\nskinparam ParticipantBackgroundColor LightGrey\nskinparam backgroundColor transparent'
|
|
28
|
+
_CD='multipartite'
|
|
29
|
+
_CC='sbdl_unique_identifier_gen_alphabet'
|
|
30
|
+
_CB='sbdl_unique_identifier_gen_length'
|
|
31
|
+
_CA='profile_output'
|
|
32
|
+
_C9='fmea_cause_extension'
|
|
33
|
+
_C8='openfmea_complex_aspect'
|
|
33
34
|
_C7='openfmea_bidirectional_import_relations'
|
|
34
35
|
_C6='openfmea_include_in_template'
|
|
35
36
|
_C5='openfmea_fmeadev_url'
|
|
@@ -218,15 +219,15 @@ _B=None
|
|
|
218
219
|
_A=True
|
|
219
220
|
import argparse,base64,datetime,csv,functools,getpass,hashlib,importlib,io,json,os,pathlib,pickle,platform,re,shlex,string,subprocess,sys,tarfile,tempfile,textwrap,time,traceback,types,unittest,urllib.request,urllib.parse,warnings,zlib,zipfile
|
|
220
221
|
__NAME=_j
|
|
221
|
-
__VERSION='1.18.
|
|
222
|
-
__VERSION_DEV='
|
|
222
|
+
__VERSION='1.18.16'
|
|
223
|
+
__VERSION_DEV='8a43dee'
|
|
223
224
|
__VERSION_DSL='25.6'
|
|
224
225
|
__VERSION_REST_API='1.1.0'
|
|
225
226
|
__AUTHOR='contact@sbdl.dev'
|
|
226
227
|
__URL='https://sbdl.dev'
|
|
227
228
|
__LOGO=''
|
|
228
229
|
__HELP_TEXT=''
|
|
229
|
-
_CONFIG_DATA={_B3:'_sbdl\\s?\\(',_B4:'\\)$',_B5:'_sbdl_block_begin',_B6:'_sbdl_block_end',_B7:'^\\.\\.\\.$',_B8:_B,_B9:_A,_BA:_C,_p:_A,_BB:{},_V:_C,_BC:_A,_BD:'.sbdl',_BE:_O,_BF:[],_k:[],_BG:5,_BH:_A,_BI:'sbdl-package.tar.gz',_AK:_C,_A1:_C,_A2:_C,_BJ:_A,_BK:_A,_BL:_C,_BM:'.sbdlc',_AL:{},_BN:_A,_l:_A,_A3:_C,_AM:_B,_AN:_C,_BO:'plantuml',_BP:65536,_BQ:'png',_BR:_A,_AO:_C,_AP:_C,_A4:_A,_BS:_A,_AQ:_A,_AR:_A,_T:{},_BT:_A,_BU:_A,_BV:_A,_BW:38,_BX:22,_BY:_C,_BZ:_A,_AS:20000,_Ba:
|
|
230
|
+
_CONFIG_DATA={_B3:'_sbdl\\s?\\(',_B4:'\\)$',_B5:'_sbdl_block_begin',_B6:'_sbdl_block_end',_B7:'^\\.\\.\\.$',_B8:_B,_B9:_A,_BA:_C,_p:_A,_BB:{},_V:_C,_BC:_A,_BD:'.sbdl',_BE:_O,_BF:[],_k:[],_BG:5,_BH:_A,_BI:'sbdl-package.tar.gz',_AK:_C,_A1:_C,_A2:_C,_BJ:_A,_BK:_A,_BL:_C,_BM:'.sbdlc',_AL:{},_BN:_A,_l:_A,_A3:_C,_AM:_B,_AN:_C,_BO:'plantuml',_BP:65536,_BQ:'png',_BR:_A,_AO:_C,_AP:_C,_A4:_A,_BS:_A,_AQ:_A,_AR:_A,_T:{},_BT:_A,_BU:_A,_BV:_A,_BW:38,_BX:22,_BY:_C,_BZ:_A,_AS:20000,_Ba:_CD,_Bb:200,_Bc:'',_Bd:_C,_Be:2,_Bf:_C,_W:"!pragma layout newlayouter\nskinparam dpi 200\nskinparam backgroundColor transparent\n'skinparam monochrome reverse\n\n",_Bg:'\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>',_Bh:_B,_AT:'hide circle',_Bi:'frame',_Bj:'class',_Bk:_C,_AU:_CE,_Bl:_C,_Bm:'participant','process_diagram_style':_CE,_Bn:_C,_q:_C,_b:15,_Bo:40,_Bp:'',_Bq:_C,_Br:'',_AV:_C,_Bs:0,_Bt:'[...]',_Bu:_C,_Bv:'less -R'if os.name=='posix'else'',_Bw:'SBDL_NO_PRETTY',_Bx:_C,_By:_A,_Bz:_C,_B_:'1879da28-0fc2-4f1d-8ff1-407f4c070c44',_C0:'{base}/{endp}'.format(base=__URL,endp='rest.api'),_AW:'; ',_C1:'',_C2:_A,_C3:_A,_C4:_C,_C5:'https://fmea.dev',_C6:_A,_C7:_C,_C8:_C,_C9:_U,_CA:_B,_CB:8,_CC:'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'}
|
|
230
231
|
def name():return __NAME
|
|
231
232
|
def version():return __VERSION
|
|
232
233
|
def version_dev():return __VERSION_DEV
|
|
@@ -312,7 +313,7 @@ def fix_wsl_path(path):
|
|
|
312
313
|
return result
|
|
313
314
|
def rest_api_call(function_name,arguments_dict,print_l=print_null):
|
|
314
315
|
D='result';C='api_version';B='errors';A='api_name';API_END_POINT=get_config_value(_C0);result_data={}
|
|
315
|
-
def create_rest_object(command,arguments_dict):return{A:name(),C:version_rest_api(),'api_key':get_config_value(_B_),_Aa:command,
|
|
316
|
+
def create_rest_object(command,arguments_dict):return{A:name(),C:version_rest_api(),'api_key':get_config_value(_B_),_Aa:command,_CF:{**arguments_dict}}
|
|
316
317
|
def report_errors(response_struct):
|
|
317
318
|
print_l('REST_API_CALL:: {} <-- {}'.format(API_END_POINT,response_struct),debug=_A)
|
|
318
319
|
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(_G.join(response_struct[B])),error=_A)
|
|
@@ -338,10 +339,10 @@ def rest_api_call(function_name,arguments_dict,print_l=print_null):
|
|
|
338
339
|
return result_data
|
|
339
340
|
def rest_api_call_ping(print_l):print_l(rest_api_call('ping',{'date':get_date_string()},print_l=print_l));return 0
|
|
340
341
|
class SBDL_Parser:
|
|
341
|
-
class Statements:declaration='declaration';using='using';scope='scope';operator='operator';customtype=
|
|
342
|
+
class Statements:declaration='declaration';using='using';scope='scope';operator='operator';customtype=_CG
|
|
342
343
|
class Types:aspect=_c;requirement=_Y;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=_Aa;event='event';state='state';transition='transition';usecase='usecase';interface=_A5;trace='trace';group='group'
|
|
343
|
-
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=
|
|
344
|
-
class Attributes:description=_P;detectability=_s;detectability_post=_A6;severity=_t;occurrence=_u;occurrence_post=_A7;separator=_S;parent='parent';child='child';related='related';pragma='pragma';remark='remark';reference=
|
|
344
|
+
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=_CG;line_continuation=_X;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=_CH.format(using,declaration_group_delimeters[0],declaration_group_delimeters[1]);scope_rule=_CH.format(scope,declaration_group_delimeters[0],declaration_group_delimeters[1]);customtype_rule='^\\s*{}\\s+{}'.format(customtype,declaration_rule.replace('^',''));macro_delimeters=[_d,']'];macro_variable='@';macro_defer='%';macro_rule='\\{}{}(?:[^\\]\\\\]|\\\\.)*\\{}'.format(macro_delimeters[0],macro_variable,macro_delimeters[1]);macro_index_separator=':';whitespace_list=list(string.whitespace);escape=_X;stereotype_separator='^';link_operator='||';source_link_operator='~|';operator_rule='\\s*({}|{})\\s*'.format(_X+_X.join(link_operator),_X+_X.join(source_link_operator));inherit='inherit';compose='compose';hash_separator='~';scope_prefix=_m;stdio_name='-'
|
|
345
|
+
class Attributes:description=_P;detectability=_s;detectability_post=_A6;severity=_t;occurrence=_u;occurrence_post=_A7;separator=_S;parent='parent';child='child';related='related';pragma='pragma';remark='remark';reference=_CI;identifier=_CJ;type=_K;types=_Z;stereotype='stereotype';actor=_Ab;tag='tag';description_bsci='description_bsci';precondition='precondition';postcondition='postcondition';invariant='invariant';output='output';input='input';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'
|
|
345
346
|
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'
|
|
346
347
|
class Parser_Element:
|
|
347
348
|
def __init__(self,content,source,indexes,context=''):self.__content=content;self.__source=source;self.__index=indexes;self.__context=context
|
|
@@ -452,7 +453,7 @@ class SBDL_Parser:
|
|
|
452
453
|
else:highest_severity=worst_severity
|
|
453
454
|
return highest_severity if highest_severity>0 else worst_severity
|
|
454
455
|
if SBDL_Parser.Macros.cross_reference_available in macros:
|
|
455
|
-
extend_symbol=get_config_value(
|
|
456
|
+
extend_symbol=get_config_value(_C9)
|
|
456
457
|
if len(inp)<1:raise Exception('No element identifier provided')
|
|
457
458
|
this_elem=macros[macros[SBDL_Parser.Macros.self_reference]];this_aspect_links=[]
|
|
458
459
|
if SBDL_Parser.Types.aspect in this_elem:
|
|
@@ -863,14 +864,14 @@ class SBDL_Parser:
|
|
|
863
864
|
return represult
|
|
864
865
|
replace_list=[SBDL_Parser.Tokens.comment,SBDL_Parser.Tokens.declaration_attribute_delimeter,*SBDL_Parser.Tokens.declaration_group_delimeters];result=unclean_string
|
|
865
866
|
for char_to_rep in replace_list:result=replace_unescapechar(result,char_to_rep)
|
|
866
|
-
return result.encode(
|
|
867
|
+
return result.encode(_CK).decode(_Ad).replace('\\\\',_X)
|
|
867
868
|
@classmethod
|
|
868
869
|
def sanitize_escaped(self,unclean_string,reverse=_C):
|
|
869
870
|
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
|
|
870
871
|
for escape_pair in escape_list:result=result.replace(*escape_pair[::incr])
|
|
871
872
|
return result
|
|
872
873
|
@classmethod
|
|
873
|
-
def remove_escape_chars(self,escaped_string):return escaped_string.encode(_r).decode(
|
|
874
|
+
def remove_escape_chars(self,escaped_string):return escaped_string.encode(_r).decode(_CK)
|
|
874
875
|
@classmethod
|
|
875
876
|
def attribute_string(self,statement_object):
|
|
876
877
|
indent_str='';newline_str='';spacing_str=_I
|
|
@@ -1016,12 +1017,12 @@ class SBDL_Semantics:
|
|
|
1016
1017
|
if right_to_left:text_words.reverse()
|
|
1017
1018
|
text_words=[x.capitalize()if not x.isupper()else x for x in text_words];return SBDL_Parser.sanitize_identifier(separator.join(text_words))
|
|
1018
1019
|
@classmethod
|
|
1019
|
-
def get_identifier_from_string_eng_standard(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',_A8,'shall','should','must','will','can','may','might','could','be','have','use','perform','execute','define','configure','manage','then'};stop_chars={'a','e','i','o','u'};abbreviations={'acceleration':'accel','actuator':'act','aerodynamics':'aero','analysis':'anal','approximate':'approx','architecture':'arch','assembly':'assy','auxiliary':'aux','battery':'batt','calculation':'calc','center of gravity':'cg','center of mass':'cm','coefficient':'coeff','configuration':'config',_o:'ctrl','controller':'cntrlr','coordinate':'coord','correction':'corr','current':'curr','data acquisition':'daq','decibel':'db','degrees of freedom':'dof','design':'des','development':'dev','diameter':'dia','dimension':'dim','dynamic':'dyn','efficiency':'eff','electrical':'elec','electromagnetic':'em','error':'err','estimate':'est','evaluation':'eval','failure mode and effects analysis':_x,'fatigue':'fat','feature':'feat','feedback':'fb','frequency':'freq',_Aa:'func','gradient':'grad','hardware':'hw','heat transfer':'ht','high voltage':'hv',
|
|
1020
|
+
def get_identifier_from_string_eng_standard(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',_A8,'shall','should','must','will','can','may','might','could','be','have','use','perform','execute','define','configure','manage','then'};stop_chars={'a','e','i','o','u'};abbreviations={'acceleration':'accel','actuator':'act','aerodynamics':'aero','analysis':'anal','approximate':'approx','architecture':'arch','assembly':'assy','auxiliary':'aux','battery':'batt','calculation':'calc','center of gravity':'cg','center of mass':'cm','coefficient':'coeff','configuration':'config',_o:'ctrl','controller':'cntrlr','coordinate':'coord','correction':'corr','current':'curr','data acquisition':'daq','decibel':'db','degrees of freedom':'dof','design':'des','development':'dev','diameter':'dia','dimension':'dim','dynamic':'dyn','efficiency':'eff','electrical':'elec','electromagnetic':'em','error':'err','estimate':'est','evaluation':'eval','failure mode and effects analysis':_x,'fatigue':'fat','feature':'feat','feedback':'fb','frequency':'freq',_Aa:'func','gradient':'grad','hardware':'hw','heat transfer':'ht','high voltage':'hv',_CJ:'id','identification':'id','implementation':'impl','input':'in','inspection':'insp','instrumentation':'instr','integration':'intg',_A5:'intf','iteration':'iter','load':'ld','logic':'log','maintenance':'maint','management':'mgmt','manufacturing':'mfg','material':'matl','maximum':'max','measurement':'meas','mechanism':'mech','minimum':'min','model':'mdl','momentum':'mom','nominal':'nom','operating system':'os','optimization':'opt','output':'out','parameter':'param','performance':'perf','physics':'phys','position':'pos','power':'pwr','pressure':'pres','process':'proc','proportional-integral-derivative':'pid','quality assurance':'qa','radiation':'rad','redundancy':'redund',_CI:'ref','reliability':'rel',_Y:'req','resolution':'res','resistance':'resist','safety':'sfty','sensor':'sens','simulation':'sim','software':'sw','specification':'spec','stability':'stab','static':'stat','structure':'struc','subsystem':'subsys',_A8:'sys','temperature':'temp','tension':'tens','testing':'test','thermal':'therm','torque':'torq','transient':'trans','uncertainty':'uncert','validation':'val','verification':'verif','voltage':'volt','weight':'wt','target':'targ'};return self.get_identifier_from_string(re.sub('[^a-zA-Z0-9.:_ ]+|(?<=.)\\.$','',input_string),aggressive_length,min_word_len,separator,stop_words=stop_words,stop_chars=stop_chars,abbreviations=abbreviations,right_to_left=right_to_left)
|
|
1020
1021
|
@classmethod
|
|
1021
1022
|
def shorten_string_on_word_boundary(self,input_string,shorten_length):return _I.join(input_string.split()[-len(input_string[-shorten_length:].split()):])
|
|
1022
1023
|
@classmethod
|
|
1023
1024
|
def get_unique_id_from_string(self,input_string):
|
|
1024
|
-
digest=hashlib.sha256(input_string.encode('utf‑8')).digest();alphabet=get_config_value(
|
|
1025
|
+
digest=hashlib.sha256(input_string.encode('utf‑8')).digest();alphabet=get_config_value(_CC);length=get_config_value(_CB,number=_A);num=int.from_bytes(digest,'big');base=len(alphabet);smart_key=[]
|
|
1025
1026
|
while len(smart_key)<length:num,idx=divmod(num,base);smart_key.append(alphabet[idx])
|
|
1026
1027
|
return''.join(smart_key)
|
|
1027
1028
|
@classmethod
|
|
@@ -1168,7 +1169,7 @@ class SBDL_Element:
|
|
|
1168
1169
|
if self.type()==target:result=_A
|
|
1169
1170
|
except Exception as _:pass
|
|
1170
1171
|
if not result:
|
|
1171
|
-
if isinstance(target,type)and hasattr(target,
|
|
1172
|
+
if isinstance(target,type)and hasattr(target,_CL):
|
|
1172
1173
|
if target.class_type_name()==self.type()or target.class_type_name()in self.types():result=_A
|
|
1173
1174
|
return result
|
|
1174
1175
|
Element_Relation=Element_Link
|
|
@@ -1186,7 +1187,7 @@ class SBDL_Element:
|
|
|
1186
1187
|
if self.type()==target:result=_A
|
|
1187
1188
|
except Exception as _:pass
|
|
1188
1189
|
if not result:
|
|
1189
|
-
if isinstance(target,type)and hasattr(target,
|
|
1190
|
+
if isinstance(target,type)and hasattr(target,_CL):
|
|
1190
1191
|
if target.class_type_name()in self.types():result=_A
|
|
1191
1192
|
return result
|
|
1192
1193
|
def __init__(self,declaration_statement):
|
|
@@ -2052,11 +2053,11 @@ def aggregate_all_parser_elements_from_files(input_list,do_recurse,do_hidden,pri
|
|
|
2052
2053
|
else:print_l('Skipping directory: {}'.format(afile))
|
|
2053
2054
|
elif is_input_file(afile):
|
|
2054
2055
|
if not is_hidden(afile)or do_hidden:
|
|
2055
|
-
print_l(
|
|
2056
|
+
print_l(_CM.format(afile))
|
|
2056
2057
|
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)
|
|
2057
2058
|
except Exception as e:errors+=1;print_l('Error reading: {}\n {}'.format(afile,str(e)),error=_A)
|
|
2058
2059
|
else:print_l('Skipping hidden file: {}'.format(afile))
|
|
2059
|
-
else:errors+=1;print_l(
|
|
2060
|
+
else:errors+=1;print_l(_CN.format(afile),error=_A)
|
|
2060
2061
|
return aggregated_elements,errors
|
|
2061
2062
|
def data_tree_node_to_element(identifier,data_node):
|
|
2062
2063
|
if not isinstance(data_node,dict):raise Exception('Trying to extract tree information from not dict object')
|
|
@@ -2177,7 +2178,7 @@ def write_decomposition_graph_output(sbdl_ast,output_file,file_opener,arguments,
|
|
|
2177
2178
|
aspect_stereotype=elements[elem_id].stereotype()
|
|
2178
2179
|
if not aspect_stereotype:aspect_stereotype=elements[elem_id].type()
|
|
2179
2180
|
else:aspect_stereotype=elements[elem_id].type()+_m+aspect_stereotype
|
|
2180
|
-
aspect_stereotype=_Aj.format(aspect_stereotype);content+=
|
|
2181
|
+
aspect_stereotype=_Aj.format(aspect_stereotype);content+=_CO.format(pref,get_config_value(_Bi),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)
|
|
2181
2182
|
if len(children)>0 or len(interfaces):
|
|
2182
2183
|
content+=' { '
|
|
2183
2184
|
for port in ports:port_type='port'if len(interface_mem)%2==0 else'portout';add_interface_line(port,port_type,indentation_prefix)
|
|
@@ -2190,13 +2191,13 @@ def write_decomposition_graph_output(sbdl_ast,output_file,file_opener,arguments,
|
|
|
2190
2191
|
if relation_type.startswith(SBDL_Parser.Tokens.inherit):relation_end='|>'
|
|
2191
2192
|
elif elements[relation.identifier()].is_a(SBDL_Interface):relation_end='('
|
|
2192
2193
|
elif relation_type.startswith(SBDL_Parser.Tokens.compose):relation_end=_O
|
|
2193
|
-
relations+=
|
|
2194
|
+
relations+=_CP.format(puml_id(elem_id),interface_rel_pos(interface_count),relation_end,puml_id(relation.identifier()),link_text);interface_count+=1
|
|
2194
2195
|
else:0
|
|
2195
2196
|
elements_ordered=list(elements.keys());elements_ordered.sort(key=lambda key:len(SBDL_AST.get_all_parents_for_element(elements[key],elements)))
|
|
2196
2197
|
for elem in elements_ordered:handle_elem(elem)
|
|
2197
2198
|
for interface_id in interface_mem:
|
|
2198
2199
|
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
|
|
2199
|
-
return plant_uml_prepost.format(style=(
|
|
2200
|
+
return plant_uml_prepost.format(style=(_CQ if get_config_value(_AP,number=_A)else'')+get_config_value(_W)+get_config_value(_AT),header=header+title,content=content+_D+relations+_D+(_D+notes if descriptions or arguments.source else''))
|
|
2200
2201
|
plantuml_writer(file_opener,output_file,plantuml_decomposition_diagram(),print_l);return errors
|
|
2201
2202
|
def write_element_graph_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
2202
2203
|
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A)
|
|
@@ -2227,17 +2228,17 @@ def write_element_graph_output(sbdl_ast,output_file,file_opener,arguments,print_
|
|
|
2227
2228
|
aspect_stereotype=elements[elem_id].stereotype()
|
|
2228
2229
|
if not aspect_stereotype:aspect_stereotype=elements[elem_id].type()
|
|
2229
2230
|
else:aspect_stereotype=elements[elem_id].type()+_m+aspect_stereotype
|
|
2230
|
-
aspect_stereotype=_Aj.format(aspect_stereotype);content+=
|
|
2231
|
+
aspect_stereotype=_Aj.format(aspect_stereotype);content+=_CO.format(pref,get_config_value(_Bj),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()])
|
|
2231
2232
|
for relation in related:
|
|
2232
2233
|
relation_type=relation.stereotype();relation_type=relation_type if relation_type else'';link_text=': '+relation_type if relation_type else'';relation_end='>'
|
|
2233
2234
|
if relation_type.startswith(SBDL_Parser.Tokens.inherit):relation_end='|>'
|
|
2234
2235
|
elif elements[relation.identifier()].is_a(SBDL_Parser.Types.interface):relation_end='('
|
|
2235
2236
|
elif relation_type.startswith(SBDL_Parser.Tokens.compose):relation_end=_O
|
|
2236
|
-
relations+=
|
|
2237
|
+
relations+=_CP.format(puml_id(elem_id),interface_rel_pos(interface_count),relation_end,puml_id(relation.identifier()),link_text)
|
|
2237
2238
|
else:0
|
|
2238
2239
|
elements_ordered=list(elements.keys())
|
|
2239
2240
|
for elem in elements_ordered:handle_elem(elem)
|
|
2240
|
-
return plant_uml_prepost.format(style=(
|
|
2241
|
+
return plant_uml_prepost.format(style=(_CQ if get_config_value(_AP,number=_A)else'')+get_config_value(_W)+get_config_value(_AT),header=header+title,content=content+_D+relations+_D+(_D+''))
|
|
2241
2242
|
plantuml_writer(file_opener,output_file,plantuml_decomposition_diagram(),print_l);return errors
|
|
2242
2243
|
def write_function_graph_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
2243
2244
|
elements,errors=sbdl_ast.elements(print_l,prune_missing_references=_A);show_descriptions=get_config_value(_Bl,number=_A);event_count=0;entities={}
|
|
@@ -2409,11 +2410,11 @@ def write_network_graph_output(sbdl_ast,output_file,_,arguments,print_l):
|
|
|
2409
2410
|
def mpl(graphin):return nx.multipartite_layout(graphin,subset_key='elem_type')
|
|
2410
2411
|
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(_AS,number=_A)))
|
|
2411
2412
|
def spring(graphin):return nx.spring_layout(graphin,k=1)
|
|
2412
|
-
layouts={
|
|
2413
|
+
layouts={_CD: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(_AS,number=_A),'edgecolors':'gray','edge_color':'darkgray','linewidths':1,'with_labels':get_config_value(_BZ,number=_A),'width':2,'node_color':colour_list,'node_shape':'s','pos':layouts[get_config_value(_Ba,number=_C)](sbdl_graph)};plt.figure(figsize=(get_config_value(_BW,number=_A),get_config_value(_BX,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(_Bb,number=_A));return errors
|
|
2413
2414
|
class OpenFMEA:
|
|
2414
2415
|
@classmethod
|
|
2415
2416
|
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):
|
|
2416
|
-
A='key'
|
|
2417
|
+
A='key';complex_aspect=get_config_value(_C8,number=_A)
|
|
2417
2418
|
if multi_field_separator is _B:multi_field_separator=get_config_value(_AW)
|
|
2418
2419
|
id_counter=0;sbdl_row={A:_B,_c:_B,_Y:_B,_L:_B,_a:_B,_R:_B,_o:_B,_g:_B,_t:_B,_u:_B,_A7:_B,_s:_B,_A6:_B,_A0:_B,_h:_B}
|
|
2419
2420
|
def is_row_empty(row):
|
|
@@ -2486,13 +2487,20 @@ class OpenFMEA:
|
|
|
2486
2487
|
if not is_fully_meta()and(get_config_value(_C3,number=_A)or not is_partly_meta()):add_row()
|
|
2487
2488
|
elif element.is_a(SBDL_Failure_Cause):
|
|
2488
2489
|
events=get_compounded_linked_events();assign_column(_R,_I+events if len(events)>0 else'');assign_column_value(_u,element.rating());assign_column_value(_A7,element.rating(post=_A))
|
|
2489
|
-
if not element.is_meta():
|
|
2490
|
+
if not element.is_meta():
|
|
2491
|
+
if complex_aspect:recurse_links(SBDL_Aspect,append=_A)
|
|
2492
|
+
recurse_links(SBDL_Failure_Current_Control,append=_A);recurse_links(SBDL_Failure_Current_Detection,append=_A);recurse_links(SBDL_Test_Definition,append=_A);recurse_links(SBDL_Failure_Action_Control,append=_A);recurse_links(SBDL_Failure_Action_Detection,append=_A)
|
|
2490
2493
|
recurse_links(SBDL_Failure_Mode)
|
|
2491
2494
|
elif element.is_a(SBDL_Failure_Mode):
|
|
2492
2495
|
assign_column(_L);assign_column_value(_s,element.rating());assign_column_value(_A6,element.rating(post=_A))
|
|
2493
|
-
if not element.is_meta():
|
|
2496
|
+
if not element.is_meta():
|
|
2497
|
+
if complex_aspect:recurse_links(SBDL_Aspect,append=_A)
|
|
2498
|
+
recurse_links(SBDL_Requirement,append=_A);recurse_links(SBDL_Failure_Current_Control,append=_A);recurse_links(SBDL_Failure_Current_Detection,append=_A);recurse_links(SBDL_Test_Definition,append=_A);recurse_links(SBDL_Failure_Action_Control,append=_A);recurse_links(SBDL_Failure_Action_Detection,append=_A)
|
|
2494
2499
|
recurse_links(SBDL_Failure_Effect)
|
|
2495
|
-
elif element.is_a(SBDL_Failure_Effect):
|
|
2500
|
+
elif element.is_a(SBDL_Failure_Effect):
|
|
2501
|
+
assign_column(_a);assign_column_value(_t,element.rating())
|
|
2502
|
+
if not element.is_meta()and complex_aspect:recurse_links(SBDL_Aspect,append=_A)
|
|
2503
|
+
recurse_links(end_node.type())
|
|
2496
2504
|
elif element.is_a(SBDL_Aspect):element.visited=_A;assign_column(_c)
|
|
2497
2505
|
elif element.is_a(SBDL_Requirement):element.visited=_A;assign_column(_Y);recurse_links(SBDL_Aspect,append=_A)
|
|
2498
2506
|
elif element.is_a(SBDL_Failure_Current_Control):element.visited=_A;assign_column(_o)
|
|
@@ -2707,9 +2715,9 @@ class OpenFMEA:
|
|
|
2707
2715
|
if hidden or recurse:raise Exception('Cannot recurse for OpenFMEA input files')
|
|
2708
2716
|
aggregated_elements=[];errors=0
|
|
2709
2717
|
for input_file in source_files:
|
|
2710
|
-
print_l(
|
|
2718
|
+
print_l(_CM.format(input_file))
|
|
2711
2719
|
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))
|
|
2712
|
-
else:errors+=1;print_l(
|
|
2720
|
+
else:errors+=1;print_l(_CN.format(input_file),error=_A)
|
|
2713
2721
|
set_config_value(_A1,_A);set_config_value(_A2,_A);return aggregated_elements,errors
|
|
2714
2722
|
@classmethod
|
|
2715
2723
|
def aggregate_all_parser_elements_from_quickshare(self,source_files,recurse,hidden,_):
|
|
@@ -2754,7 +2762,7 @@ def write_rpc_output(sbdl_ast,output_file,file_opener,arguments,print_l):
|
|
|
2754
2762
|
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]
|
|
2755
2763
|
if arguments.rpc==_B:errors+=1;print_l('RPC parameter required',error=_A)
|
|
2756
2764
|
else:
|
|
2757
|
-
rpc_result=rest_api_call(arguments.rpc,{
|
|
2765
|
+
rpc_result=rest_api_call(arguments.rpc,{_CF:str(sys.argv),A:sbdl_statement_strings},print_l)
|
|
2758
2766
|
with file_opener(output_file)as outfile:
|
|
2759
2767
|
if isinstance(rpc_result,dict):
|
|
2760
2768
|
if A in rpc_result and isinstance(rpc_result[A],list):outfile.write(_D.join(rpc_result[A]))
|
|
@@ -2939,7 +2947,7 @@ def main(arguments):
|
|
|
2939
2947
|
else:print_l('Encountered {} errors during: {} {}'.format(error_count,step,content),error=_A)
|
|
2940
2948
|
else:print_l(f"{step} done [{time.time()-step_time_point:.3f}s]")
|
|
2941
2949
|
step_time_point=time.time()
|
|
2942
|
-
operations={_Al:write_aggregated_output,'aggregate':write_aggregated_output,'query':query_output,_AE:write_matrixcsv_output,'matrixcsv':write_matrixcsv_output,_AF:write_matrixjson_output,'matrixjson':write_matrixjson_output,_Am:write_yaml_tree_output,
|
|
2950
|
+
operations={_Al:write_aggregated_output,'aggregate':write_aggregated_output,'query':query_output,_AE:write_matrixcsv_output,'matrixcsv':write_matrixcsv_output,_AF:write_matrixjson_output,'matrixjson':write_matrixjson_output,_Am:write_yaml_tree_output,_CR:write_csv_output,'fmeacsv':write_csv_output,_AD:OpenFMEA.write_opensbdl_output,'openfmea-quickshare':OpenFMEA.write_quickshare_output,_An:OpenFMEA.write_opensbdl_portfolio_output,A:write_aggregated_output,_Ao:write_aggregated_output,B:write_aggregated_output,C:write_aggregated_output,_Ap:write_decomposition_graph_output,_Aq:write_element_graph_output,_Ar:write_requirement_graph_output,_As:write_network_graph_output,_At:write_function_graph_output,_Au:write_process_graph_output,_Av:write_state_graph_output,_Aw:write_usecase_graph_output,_CS:write_template_fill,'rpc':write_rpc_output,_AG:write_aggregated_output,_Ax:write_aggregated_output,_AH:write_aggregated_output,'type-info':write_type_information};macro_errors=0
|
|
2943
2951
|
for amacropath in arguments.custom_directive:macro_errors+=import_custom_directive_file(amacropath,print_l)
|
|
2944
2952
|
check_step('Custom directive import',macro_errors);mode_errors=0
|
|
2945
2953
|
for amodepath in arguments.custom_mode:
|
|
@@ -2968,7 +2976,7 @@ def main(arguments):
|
|
|
2968
2976
|
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)
|
|
2969
2977
|
for post_hook in get_config_value(_k):check_step('Post Hook: {}'.format(post_hook.__name__),post_hook(sbdl_ast,print_l))
|
|
2970
2978
|
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]");return total_errors if not arguments.skip_errors else 0
|
|
2971
|
-
def handle_arguments(args_l):F='append';E='config_file';D='normal';C='output_file';B='element_identifier';A='store_true';operating_modes={_Al:'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)',_AE:'Compile inputs, then write a CSV-formatted representation of the SBDL elements to the output',_AF:'Compile inputs, then write a JSON-formatted representation of the SBDL elements to the output',_Am:'Compile inputs, then write a YAML-formatted representation of the SBDL elements to the output',_AH:'Read SBDL-schema CSV-matrix inputs and write SBDL-formatted output',_AG:'Read SBDL-schema JSON-tree inputs and write SBDL-formatted output',_Ax:'Read SBDL-schema YAML-tree inputs and write SBDL-formatted output',_AD:'Compile inputs, then write the FMEA-related content to an OpenFMEA-formatted ouput',_An:'Compile inputs, then write the FMEA-related content to an OpenFMEA Portfolio-formatted ouput, organised by aspect hierarchy',_Ao:'Read OpenFMEA-formatted input and write SBDL-formatted output',
|
|
2979
|
+
def handle_arguments(args_l):F='append';E='config_file';D='normal';C='output_file';B='element_identifier';A='store_true';operating_modes={_Al:'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)',_AE:'Compile inputs, then write a CSV-formatted representation of the SBDL elements to the output',_AF:'Compile inputs, then write a JSON-formatted representation of the SBDL elements to the output',_Am:'Compile inputs, then write a YAML-formatted representation of the SBDL elements to the output',_AH:'Read SBDL-schema CSV-matrix inputs and write SBDL-formatted output',_AG:'Read SBDL-schema JSON-tree inputs and write SBDL-formatted output',_Ax:'Read SBDL-schema YAML-tree inputs and write SBDL-formatted output',_AD:'Compile inputs, then write the FMEA-related content to an OpenFMEA-formatted ouput',_An:'Compile inputs, then write the FMEA-related content to an OpenFMEA Portfolio-formatted ouput, organised by aspect hierarchy',_Ao:'Read OpenFMEA-formatted input and write SBDL-formatted output',_CR:'Compile inputs, then write the FMEA-related content to a CSV-formatted ouput',_As:'Compile inputs, then write a PNG-formatted output, visually representing the network of SBDL elements',_Ar:'Compile inputs, then write a SysML-style requirements diagram to rendering-backend-formatted output',_Ap:'Compile inputs, then write a SysML-style block diagram to rendering-backend-formatted output (simplified, aspects only)',_Aq:'Compile inputs, then write a SysML-style block diagram to rendering-backend-formatted output (detailed, with properties and relations)',_At:'Compile inputs, then write a SysML-style sequence diagram to rendering-backend-formatted output',_Au:'Compile inputs, then write a SysML-style activity diagram to rendering-backend-formatted output',_Av:'Compile inputs, then write a SysML-style state diagram to rendering-backend-formatted output',_Aw:'Compile inputs, then write a SysML-style use-case diagram to rendering-backend-formatted output',_CS:"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(_D.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=_O);parser.add_argument(_F,'--mode',metavar='operating_mode',help='Specify the mode of operation',default=_Al);parser.add_argument(_E,'--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=_O);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(_CT,metavar='compiler_definitions',help='Specify a file path defining custom compiler directives',default=[],nargs=_O);parser.add_argument(_CU,'--custom_mode',metavar='mode_definitions',help='Specify a file path containing custom compiler modes',default=[],nargs=_O);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)
|
|
2972
2980
|
def show_manual(_):
|
|
2973
2981
|
B='----------------------\n';A='===========================================================\n';manual_text=A;manual_text+=' {} Manual\n'.format(name().upper());manual_text+=A;manual_text+=help_text()+_D;manual_text+=B;manual_text+='Model Type Information\n';manual_text+=B
|
|
2974
2982
|
def add_manual(strcon=''):nonlocal manual_text;manual_text+=strcon+_D
|
|
@@ -3013,8 +3021,8 @@ class LanguageLevelTests(unittest.TestCase):
|
|
|
3013
3021
|
def testEscaping(self):main(handle_arguments(['test/escaped_directive_test.sbdl',_E,self.TEST_OUTPUT_FILE]))
|
|
3014
3022
|
def testCustomDirectiveImport(self):main(handle_arguments(['test/directive_imp_test.sbdl',_E,self.TEST_OUTPUT_FILE]))
|
|
3015
3023
|
def testProlog(self):main(handle_arguments(['test/test_prolog.sbdl',_E,self.TEST_OUTPUT_FILE]))
|
|
3016
|
-
def testCustomDirective(self):main(handle_arguments([_J,
|
|
3017
|
-
def testCustomModes(self):main(handle_arguments([_J,'--mode','test_mode',
|
|
3024
|
+
def testCustomDirective(self):main(handle_arguments([_J,_CT,_CV,_E,self.TEST_OUTPUT_FILE]))
|
|
3025
|
+
def testCustomModes(self):main(handle_arguments([_J,'--mode','test_mode',_CU,_CV,_E,self.TEST_OUTPUT_FILE]))
|
|
3018
3026
|
def testIdFromProp(self):main(handle_arguments(['test/id_from_prop.sbdl',_E,self.TEST_OUTPUT_FILE]))
|
|
3019
3027
|
def testDirectiveChain(self):main(handle_arguments(['test/macro_chain.sbdl',_E,self.TEST_OUTPUT_FILE]))
|
|
3020
3028
|
def testGeneralAspectDiagram(self):main(handle_arguments([_J,_E,self.TEST_DIAGRAM_OUTPUT_FILE,_F,_Ap]))
|
|
@@ -3044,10 +3052,10 @@ class LanguageSemanticTests(unittest.TestCase):
|
|
|
3044
3052
|
def test_geneal_relations_check(self):
|
|
3045
3053
|
for elem in self.sbdl_elements:0
|
|
3046
3054
|
def test_existence_type_semantic_check(self):
|
|
3047
|
-
expected_elem_type={_Az:SBDL_Aspect,'rocket_booster':SBDL_Aspect,_A_:SBDL_Aspect,
|
|
3055
|
+
expected_elem_type={_Az:SBDL_Aspect,'rocket_booster':SBDL_Aspect,_A_:SBDL_Aspect,_CW:SBDL_Aspect,_B0:SBDL_Requirement,_CX:SBDL_Requirement,_CY:SBDL_Requirement,_B1:SBDL_Function,_CZ:SBDL_Event,_Ca:SBDL_Event,_Cb:SBDL_State,_Cc:SBDL_State,_B2:SBDL_Transition,_Cd:SBDL_Event}
|
|
3048
3056
|
for elem in expected_elem_type:0
|
|
3049
3057
|
def test_existence_semantic_relation(self):
|
|
3050
|
-
relations_between={
|
|
3058
|
+
relations_between={_CW:_A_,_B0:_Az,_CX:_B0,_CY:_A_,_B1:_Az,_CZ:_B1,_Ca:_Cd,_Cb:_B2,_Cc:_B2}
|
|
3051
3059
|
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)]]
|
|
3052
3060
|
for elem in relations_between:0
|
|
3053
3061
|
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
|
|
@@ -3098,7 +3106,7 @@ def whoopsie_handler(whoopsie):
|
|
|
3098
3106
|
except Exception as _:w_print('Could not print stack trace')
|
|
3099
3107
|
w_print(A);sys.exit(99)
|
|
3100
3108
|
def init_profiling():
|
|
3101
|
-
global main,main_original;profile_output=get_config_value(
|
|
3109
|
+
global main,main_original;profile_output=get_config_value(_CA)
|
|
3102
3110
|
def wrap_main(ARGS):
|
|
3103
3111
|
f_print(f"Profiling to: {profile_output}",warning=_A,do_warning=_A);cProfile=lazy_import('cProfile')
|
|
3104
3112
|
def profile_main():main_original(ARGS)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|