sbdl 1.18.9__tar.gz → 1.18.11__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sbdl
3
- Version: 1.18.9
3
+ Version: 1.18.11
4
4
  Summary: System Behaviour Description Language (Compiler)
5
5
  Home-page: https://sbdl.dev
6
6
  Author: Michael A. Hicks
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sbdl
3
- Version: 1.18.9
3
+ Version: 1.18.11
4
4
  Summary: System Behaviour Description Language (Compiler)
5
5
  Home-page: https://sbdl.dev
6
6
  Author: Michael A. Hicks
@@ -217,8 +217,8 @@ _B=None
217
217
  _A=True
218
218
  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
219
219
  __NAME=_i
220
- __VERSION='1.18.9'
221
- __VERSION_DEV='a7bc4c2'
220
+ __VERSION='1.18.11'
221
+ __VERSION_DEV='1a386c8'
222
222
  __VERSION_DSL='25.6'
223
223
  __VERSION_REST_API='1.1.0'
224
224
  __AUTHOR='contact@sbdl.dev'
@@ -640,8 +640,15 @@ class SBDL_Parser:
640
640
  except Exception as e:raise self.MacroReplaceException(str(e),first_pass_can_ignore=_C)
641
641
  return hasher.hexdigest()[:8]
642
642
  define_name=args[0];filepath=os.path.join(macros['DIR'],*args[1:]);macros[define_name]=hash_file(filepath);return''
643
+ def split_term_id(input_str):
644
+ result=[input_str];escape=SBDL_Parser.Tokens.escape;splitc=SBDL_Parser.Tokens.macro_index_separator;pos=0
645
+ while pos<len(input_str):
646
+ if input_str[pos:pos+len(escape)]==escape:pos+=len(escape)
647
+ elif input_str[pos:pos+len(splitc)]==splitc:result=[input_str[:pos].replace(escape,''),input_str[pos+len(splitc):]];break
648
+ pos+=1
649
+ return result
643
650
  def term(match):
644
- result_l=match[len(SBDL_Parser.Tokens.macro_delimeters[0])+len(SBDL_Parser.Tokens.macro_variable):-len(SBDL_Parser.Tokens.macro_delimeters[1])];result_l=result_l.split(SBDL_Parser.Tokens.macro_index_separator);index=_B
651
+ result_l=match[len(SBDL_Parser.Tokens.macro_delimeters[0])+len(SBDL_Parser.Tokens.macro_variable):-len(SBDL_Parser.Tokens.macro_delimeters[1])];result_l=split_term_id(result_l);index=_B
645
652
  if len(result_l)>1:index=SBDL_Parser.Tokens.macro_index_separator.join(result_l[1:]);result_l=SBDL_Parser.Tokens.macro_index_separator.join(result_l[0:1])
646
653
  else:result_l=''.join(result_l)
647
654
  return result_l,index
@@ -675,10 +682,16 @@ class SBDL_Parser:
675
682
  elif index==_B:replace_content=macro_definitions[macro]
676
683
  else:
677
684
  index_fudge=fudge_recurse(index)
678
- if isinstance(macro_definitions[macro],dict)and index_fudge in macro_definitions[macro]:replace_content=macro_definitions[macro][index_fudge]
679
- else:
680
- print_l(B.format('[Index Not Found]'),debug=_A);errors+=1
681
- if throw_error:raise self.MacroReplaceException('Attempted replacement for non-existent definition index: "{}:{}"'.format(macro,index_fudge))
685
+ def replace_cross_ref(rmacro,rindex):
686
+ nonlocal errors;replace_result=_B
687
+ if isinstance(macro_definitions[rmacro],dict)and rindex in macro_definitions[rmacro]:replace_result=macro_definitions[rmacro][rindex]
688
+ else:
689
+ print_l(B.format('[Index Not Found]'),debug=_A);errors+=1
690
+ if throw_error:raise self.MacroReplaceException('Attempted replacement for non-existent definition index: "{}[{}]"'.format(rmacro,rindex))
691
+ replace_result=smart_flatten_macro_definition(replace_result)
692
+ if SBDL_Parser.Tokens.macro_variable in replace_result:replace_result,errors=self.replace_directives(replace_result,macro_definitions,throw_error,print_l)
693
+ return replace_result
694
+ replace_content=replace_cross_ref(macro,index_fudge)
682
695
  print_l('C_DEF REPLACE: "{}" --> "{}"'.format(input_str,replace_content),debug=_A)
683
696
  if replace_content!=_B and replace_content!=str(_B)and errors==0:result=result.replace(amatch,str(smart_flatten_macro_definition(replace_content)))
684
697
  else:
@@ -2946,9 +2959,8 @@ def main(arguments):
2946
2959
  else:check_step('Validation (skipped)',0)
2947
2960
  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)
2948
2961
  for post_hook in get_config_value(_j):check_step('Post Hook: {}'.format(post_hook.__name__),post_hook(sbdl_ast,print_l))
2949
- 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)
2950
- if get_config_value(_AK,number=_A)and operations[arguments.mode]is write_aggregated_output:store_ast_cache(sbdl_ast.ast(),get_cache_file_path(arguments.output),print_l)
2951
- print_l(f"All operations complete [{time.time()-start_time_point:.3f}s]");return total_errors if not arguments.skip_errors else 0
2962
+ if total_errors==0 and get_config_value(_AK,number=_A)and operations[arguments.mode]is write_aggregated_output:store_ast_cache(sbdl_ast.ast(),get_cache_file_path(arguments.output),print_l)
2963
+ 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
2952
2964
  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)',_AD:'Compile inputs, then write a CSV-formatted representation of the SBDL elements to the output',_AE:'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',_AG:'Read SBDL-schema CSV-matrix inputs and write SBDL-formatted output',_AF:'Read SBDL-schema JSON-tree inputs and write SBDL-formatted output',_Ax:'Read SBDL-schema YAML-tree inputs and write SBDL-formatted output',_AC:'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',_CP:'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',_CQ:"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(_CR,metavar='compiler_definitions',help='Specify a file path defining custom compiler directives',default=[],nargs=_O);parser.add_argument(_CS,'--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)
2953
2965
  def show_manual(_):
2954
2966
  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
@@ -2997,6 +3009,7 @@ class LanguageLevelTests(unittest.TestCase):
2997
3009
  def testCustomDirective(self):main(handle_arguments([_J,_CR,_CT,_E,self.TEST_OUTPUT_FILE]))
2998
3010
  def testCustomModes(self):main(handle_arguments([_J,'--mode','test_mode',_CS,_CT,_E,self.TEST_OUTPUT_FILE]))
2999
3011
  def testIdFromProp(self):main(handle_arguments(['test/id_from_prop.sbdl',_E,self.TEST_OUTPUT_FILE]))
3012
+ def testDirectiveChain(self):main(handle_arguments(['test/macro_chain.sbdl',_E,self.TEST_OUTPUT_FILE]))
3000
3013
  def testGeneralAspectDiagram(self):main(handle_arguments([_J,_E,self.TEST_DIAGRAM_OUTPUT_FILE,_F,_Ap]))
3001
3014
  def testGeneralElementDiagram(self):main(handle_arguments([_J,_E,self.TEST_DIAGRAM_OUTPUT_FILE,_F,_Aq]))
3002
3015
  def testGeneralFunctionDiagram(self):main(handle_arguments([_Ay,_E,self.TEST_DIAGRAM_OUTPUT_FILE,_F,_At]))
@@ -2,7 +2,7 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name='sbdl',
5
- version='1.18.9',
5
+ version='1.18.11',
6
6
  description = "System Behaviour Description Language (Compiler)",
7
7
  author = "Michael A. Hicks",
8
8
  author_email = "michael@mahicks.org",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes