def
add_to_config_value(key, data):
Append or merge data into an existing list or dict config value, skipping locked keys.
def
aggregate_all_parser_elements_auto( input_list, do_recurse, do_hidden, print_l=<function print_null>, file_opener=<function open_input_file>, arguments=None):
Read a mix of SBDL sources and SQL databases, auto-detecting database inputs.
def
aggregate_all_parser_elements_from_csv( input_list, do_recurse, do_hidden, print_l=<function print_null>, file_opener=<function open_input_file>):
Read CSV files from input_list and return (parser_elements, error_count).
def
aggregate_all_parser_elements_from_files( input_list, do_recurse, do_hidden, print_l=<function print_null>, file_opener=<function open_input_file>, read_input_set=None, is_valid_input=<function is_input_file>):
Read all files/directories in input_list and return (parser_elements, error_count).
def
aggregate_all_parser_elements_from_json( input_list, do_recurse, do_hidden, print_l=<function print_null>, file_opener=<function open_input_file>):
Read JSON files from input_list and return (parser_elements, error_count).
def
aggregate_all_parser_elements_from_sql( input_list, do_recurse, do_hidden, print_l=<function print_null>, file_opener=<function open_input_file>, arguments=None, sql_filter_only=False):
Read SBDL-schema SQL databases from input_list and return (parser_elements, error_count).
def
aggregate_all_parser_elements_from_yaml( input_list, do_recurse, do_hidden, print_l=<function print_null>, file_opener=<function open_input_file>):
Read YAML files from input_list and return (parser_elements, error_count).
def
author():
Return the author contact string.
def
config_data():
Return the live configuration dict (read/iterate/in-place mutation).
def
config_default():
Return the default-configuration snapshot taken by init().
def
f_print( *content, end=None, error=False, verbose=True, do_debug=False, debug=False, do_warning=True, warning=False, opts=None, prefix=None, first_line_heuristic=True, file=None):
Print formatted output to stdout (or stderr for errors/warnings) with optional ANSI colour codes.
def
get_config_value(key, raise_on_missing=True, default=None, number=None):
Retrieve a configuration value by key, with optional environment variable override and numeric coercion.
def
get_parser_elements_from_filepath( filepath, elements_list, print_l=<function print_null>, file_opener=<function open_input_file>, read_input_set=None):
def
help_text():
Return the application help text string.
def
import_custom_directive_file(file_path, print_l):
Dynamically load a Python file and merge its DIRECTIVES dict into the global parser directives.
def
import_custom_modes_file(file_path, print_l):
Dynamically load a Python file defining custom output modes and register them.
def
init():
Snapshot the current configuration as the default state for later reset.
def
load_config(config_path, skip_keys=None):
Load a JSON configuration file and merge its values into the global config.
Lives in core (a config operation, also invoked by the model's config
directives) but reaches the IO layer's file opener lazily to keep core a leaf.
def
lock_config_key(key):
Lock a configuration key so it cannot be modified by subsequent set_config_value calls.
def
logo():
Return the application logo string, or empty string if pretty-print is disabled.
def
main(arguments):
Entry point for a single compilation run: read inputs, build AST, apply filters, verify, and write output.
def
name():
Return the application name.
class
OpenFMEA:
Utilities for generating FMEA table data from an SBDL AST.
@classmethod
def
generate_sbdl_table_from_ast( self, sbdl_ast, id_in_body=False, source_in_body=False, print_l=<function print_null>, multi_field_separator=None, prune_missing_references=False):
Traverse the fully-connected CME graph and return a list of FMEA row dicts.
@classmethod
def
struct_from_table(self, title, sbdl_table, open_fmea_type='FMEA'):
Wrap an FMEA table in an OpenFMEA metadata envelope dict.
@classmethod
def
read_file(self, file_path):
Open an OpenFMEA JSON file and return its parsed dict content.
@classmethod
def
write_struct_to_file(self, open_sbdl_struct, open_sbdl_file, pretty=True):
Serialise open_sbdl_struct as JSON to open_sbdl_file, with optional pretty-printing.
@classmethod
def
read_struct_from_file(self, open_sbdl_file):
Parse and verify an OpenFMEA JSON file, raising if the format or type is incorrect.
@classmethod
def
write_opensbdl_output(self, sbdl_ast, output_file, file_opener, arguments, print_l):
Generate an OpenFMEA JSON file from the AST and write it to output_file.
@classmethod
def
write_opensbdl_portfolio_output(self, sbdl_ast, output_file, file_opener, arguments, print_l):
Generate an OpenFMEA Portfolio JSON file, organising FMEA rows by aspect hierarchy.
@classmethod
def
elements_from_table(self, sbdl_table, _):
Convert an OpenFMEA table (list of row dicts) back into a list of SBDL_Element_Synthetic objects.
@classmethod
def
elements_from_general(self, general_entries, fmea_elements, _):
Convert general (non-FMEA) OpenFMEA entries into SBDL_Element_Synthetic objects linked to fmea_elements.
@classmethod
def
statements_from_openfmea(self, openfmea_data, source_name):
Extract Parser_Element objects from an OpenFMEA data dict, covering both FMEA and general elements.
@classmethod
def
aggregate_all_parser_elements_from_files(self, source_files, recurse, hidden, print_l):
Read OpenFMEA JSON files and return (parser_elements, error_count).
def
query_output(sbdl_ast, _, __, ___, ____):
Print a human-readable summary of every element in the AST to stdout.
def
register_reset_hook(hook):
Register a zero-arg callable to be run by reset() (e.g. the model clearing its
custom-type registry). Lets reset() live in core -- with init/config -- without
core depending on other modules: each module registers its own reset behaviour.
def
reset():
Restore configuration to the initial default snapshot and run all registered
reset hooks, clearing every module's global mutable state between compilations.
SBDL element representing an architectural aspect (system decomposition unit).
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
verify_link_stereotype(self, target):
Return True if this aspect's stereotype is compatible with the target link's target stereotype.
def
verify_parent_link_type(self, parent_link):
Return True if the parent link type is compatible with this element's type hierarchy.
def
verify_child_link_type(self, child_link):
Return True if the child link type is compatible with this element's type hierarchy.
class
SBDL_AST:
Abstract Syntax Tree for an SBDL model: parses statements, builds elements, runs verification hooks.
def
ast(self):
Return a copy of the list of parsed statement objects in this AST.
def
force_parsed_objects(self, parsed_objects):
Replace the internal parsed object list (used for testing or pre-built ASTs).
def
check_parsing(self, print_l=<function print_null>):
Report any parsing errors in the AST and return the error count.
def
sbdl_elements( self, print_l=<function print_null>, prune_missing_references=False, base_elements=None, prior_depends=None):
Alias for elements(); build and return the SBDL element dict from the AST.
def
elements( self, print_l=<function print_null>, prune_missing_references=False, base_elements=None, prior_depends=None):
Build SBDL elements from parsed statements, apply directives and hooks, return (elements, error_count).
@classmethod
def
get_all_parent_children_for_element(self, element, elements, parents_children, _rev_idx=None):
Return all parents (or children) for an element, including those declared on the other side of the link.
@classmethod
def
get_all_parents_for_element(self, element, elements, _rev_idx=None):
Return all parents for an element including those declared by child links in other elements.
@classmethod
def
get_all_children_for_element(self, element, elements, _rev_idx=None):
Return all children for an element including those declared by parent links in other elements.
@classmethod
def
get_all_relations_for_element(self, element, elements, _rev_idx=None):
Return all relation links for an element including those declared on the other side.
@classmethod
def
get_all_parents_links_children_for_element(self, element, elements, _rev_idx=None):
Return the combined list of all parents, children, and relation links for an element.
@classmethod
def
get_top_level_element_set(self, elements, child_elements=None, depth=0):
Return the set of element identifiers that are not children of any other element.
@classmethod
def
verify_elements(self, sbdl_elements, print_l=<function print_null>):
Verify all elements and their links in sbdl_elements; report errors and return (result, error_count).
@classmethod
def
get_full_ast_as_dict( self, elements, flatten_references=False, force_bijective_relations=False, property_stereotype_set=False):
Build a cross-reference dict (keyed by identifier) of all element data for macro expansion.
def
fully_connected_cme_graph(self, _=<function print_null>, prune_missing_references=False):
Build a fully-connected cause-mode-effect graph, inserting placeholder nodes where links are absent.
@classmethod
def
filter_element_set(self, element_set, filter_pred_f):
Return a filtered copy of element_set containing only elements for which filter_pred_f returns True.
def
add_filter_element_set(self, filter_function):
Register a filter predicate f(element, element_set) -> bool to be applied when retrieving elements.
def
clear_filter_element_set(self):
Remove all registered element filter predicates.
def
filter_memo_function_elements_operation( self, element, elements, filter_id, search_set, memo_set, object_link_function, depth=0, depth_bound=None, filter_id_re=None):
Recursively traverse element links to determine whether any reachable element matches filter_id, with memoisation.
def
add_filter_element_set_linked(self, filter_id, depth_bound):
Add a filter that retains elements reachable via links from elements matching filter_id, up to depth_bound.
def
add_filter_element_set_connected(self, filter_id, depth_bound):
Add a filter that retains elements connected (parents, links, children) to elements matching filter_id, up to depth_bound.
def
add_filter_element_set_parents(self, filter_id, depth_bound):
Add a filter that retains elements whose ancestors match filter_id, up to depth_bound.
def
add_filter_element_set_children(self, filter_id, depth_bound):
Add a filter that retains elements whose descendants match filter_id, up to depth_bound.
def
add_filter_element_set_type(self, filter_id):
Add a filter that retains only elements whose type matches the regex filter_id.
def
add_filter_element_set_id(self, filter_id):
Add a filter that retains only elements whose identifier matches the regex filter_id.
def
add_filter_element_set_property(self, property_name, property_value):
Add a filter that retains only elements whose named property value matches the regex property_value.
def
process_trace_elements(self, parser_element_list, print_l=<function print_null>):
Simulate a trace over the model, counting how often each element and its linked targets are visited.
Element representation of a 'customtype' declaration that registers a new user-defined type.
@classmethod
def
class_type_name(self):
Return the 'customtype' statement type name.
def
definition(self):
Return an SBDL_Customtype_Statement for this custom type element.
Parsed 'customtype' declaration statement that introduces a user-defined element type.
def
copy(self):
Return a shallow copy of this statement.
Parsed SBDL element declaration holding an identifier, declared type, and key-value attribute data.
def
data_type(self):
Return the declaration data type; None for generic statements.
def
identifier(self):
Return a synthetic identifier composed of statement type and source reference.
def
apply_scope(self, scope_data):
Prepend scope prefixes to matching attribute values and return the resulting scope map.
def
copy(self):
Return a shallow copy of this statement.
SBDL element representing a prescriptive design definition.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
Element representation of a 'depends' statement that imports external files.
@classmethod
def
class_type_name(self):
Return the 'depends' statement type name.
def
definition(self):
Return an SBDL_Declaration_Statement reconstructed from this element's current state.
Parsed 'depends' statement that imports external files into the current scope.
def
data_type(self):
Return the declaration data type; None for generic statements.
def
copy(self):
Return a shallow copy of this statement.
def
identifier(self):
Return a synthetic identifier composed of statement type and source reference.
class
SBDL_Element(sbdl_model.SBDL_Parser.Parser_Hints):
Base class for all SBDL model elements, providing type, links, properties, and verification infrastructure.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
is_a(self, target):
Return True if this element is an instance of, or has a type matching, the given target type/class/name.
def
identifier(self, with_stereotype=False):
Return the element identifier, optionally including the stereotype suffix.
def
stereotype(self):
Return the stereotype string for this element, or None if absent.
def
description(self):
Return the description property of this element with escape characters resolved.
def
replace_directives_from_dict(self, input_dict, throw_error=True, print_l=<function print_null>):
Expand all macro directives within this element's properties and links using the provided macro dict.
def
get_as_dictionary( self, extra_links=None, flatten_references=True, property_stereotype_set=False):
Return the element's full data as a plain dict, optionally including extra links.
def
definition(self):
Return an SBDL_Declaration_Statement reconstructed from this element's current state.
def
reference(self):
Return the source reference string for this element (file:line or overridden reference property).
def
type(self):
Return the type name string of this element.
@classmethod
def
types(self):
Return the list of type names for this element's class hierarchy (from most to least derived).
def
links(self):
Return a copy of this element's relation (link) list.
def
relations(self):
Return the element's relations; alias for links().
def
parents(self):
Return a copy of this element's parent link list.
def
children(self):
Return a copy of this element's child link list.
def
properties(self):
Return the dict_keys view of this element's property names.
def
get_property_stereotype(self, key):
Return the stereotype of the named property.
def
get_property(self, key, value_only=False):
Return the value of the named property (value_only specifies that stereotype should be removed from result).
def
delete_property(self, key):
Delete the named property if it exists.
def
set_property(self, key, value):
Set a property value, or delete it if value is None.
@classmethod
def
declaration_type_to_class(self, type_name, raise_on_error=True):
Return the SBDL_Element subclass corresponding to the given type name string.
@classmethod
def
declaration_to_element(self, declaration_statement):
Instantiate and return the appropriate SBDL_Element subclass for the given declaration statement.
@classmethod
def
statement_to_element(self, statement):
Convert a parsed statement object into the corresponding SBDL_Element instance.
def
verify_link_type(self, link):
Return True if a link between this element's type and the given link's type is semantically valid.
def
verify_parent_link_type(self, parent_link):
Return True if the parent link type is compatible with this element's type hierarchy.
def
verify_child_link_type(self, child_link):
Return True if the child link type is compatible with this element's type hierarchy.
def
verify_relation_extended(self, _, __):
Extended relation validation hook; returns (True, '') by default.
def
verify_self(self, elements=None):
Verify all links on this element, checking stereotypes and hash integrity; return (is_valid, error).
@classmethod
def
get_ids_string(self, link_list, elem_type=None):
Return a comma-separated string of link identifiers, optionally filtered by element type.
def
prune_missing_references(self, element_set):
Remove any links (in all link lists) whose target identifier is not present in element_set.
def
pragma(self):
Return the pragma attribute value from the declaration data, or None if absent.
def
hash(self):
Return a short SHA-256 hash of the element's canonical declaration content.
@classmethod
def
apply_operator(self, operator_element, element_stack):
Apply the operator in operator_element to the top two elements on element_stack (RPN context).
class
SBDL_Element.Element_Link:
Represents a directed link (relation) from one SBDL element to another, carrying type and optional stereotype/hash.
def
verify_self(self, _):
Verify this link for correctness; return (is_valid, error_message).
def
type(self):
Return the relation type name string of this link.
def
types(self):
Return the list of type names this link's type resolves to (including base types).
def
identifier(self, with_stereotype=False, with_hash=False):
Return the target element identifier, optionally including stereotype and hash suffixes.
def
stereotype(self, target=False):
Return the stereotype string (source or target) for this link.
def
hash(self):
Return the hash suffix for this link's identifier, if any.
def
identifier_is_origin(self):
Return True if the identifier denotes the origin of the link direction.
def
copy(self):
Return a copy of this Element_Link.
def
is_a(self, target):
Return True if this link's type matches the target type, class, or type name.
Base class for SBDL elements that carry a numerical rating (detectability, severity, or occurrence).
def
rating(self, post=False):
Return the element's rating value, returning the post-action value when post=True if available.
def
rating_name(self, post=False):
Return the attribute name string for this element's rating (or post-action rating if post=True).
def
replace_directives_from_dict(self, input_dict, throw_error=True, print_l=<function print_null>):
Expand macros in rating attributes in addition to the base element's directive expansion.
class
SBDL_Element_Rating.Ratings:
Mapping of element type names to their respective rating attribute names.
Programmatically constructed SBDL element not backed by a parsed declaration statement.
@classmethod
def
from_element(self, sbdl_element):
Create an SBDL_Element_Synthetic that is a copy of the given SBDL element.
def
copy(self):
Return a copy of this synthetic element.
def
class_type_name(self):
Return the type name of this synthetic element.
def
types(self):
Return the type hierarchy list for this synthetic element.
def
definition(self):
Construct and return an SBDL_Declaration_Statement representing this synthetic element.
def
set_identifier(self, identifier):
Set the identifier of this synthetic element.
def
set_type(self, type_name):
Set the type name of this synthetic element.
def
set_rating(self, rating, post=False):
Set the (pre- or post-action) rating value for this synthetic element.
def
add_link(self, elem_link):
Add a relation link to this element, removing duplicates.
def
add_relation(self, elem_link):
def
set_links(self, links):
Replace this element's relation links list, removing duplicates.
def
set_relations(self, links):
def
add_parent(self, parent_link):
Add a parent link to this element, removing duplicates.
def
set_parents(self, parents):
Replace this element's parent links list, removing duplicates.
def
add_child(self, child_link):
Add a child link to this element, removing duplicates.
def
set_children(self, children):
Replace this element's children links list, removing duplicates.
def
native_element(self):
Convert this synthetic element back to a native SBDL_Element via a declaration round-trip.
def
verify_parent_link_type(self, parent_link):
Always returns True for synthetic elements (no parent type restrictions).
def
verify_child_link_type(self, child_link):
Always returns True for synthetic elements (no child type restrictions).
SBDL element representing a dynamic system event, optionally with conditions and alternative branches.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
verify_child_link_type(self, child_link):
Return True if the child link type is compatible with this element's type hierarchy.
def
condition_alternative(self):
Return a copy of this event's condition-alternative link list.
def
verify_self(self, elements=None):
Validate this event, checking condition-alternative elements and stereotype-property consistency.
SBDL element representing an improvement action to prevent a failure cause or mode.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
SBDL element representing an improvement action to increase detection of a failure mode.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
SBDL element representing a FMEA failure cause with optional occurrence rating.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
verify_child_link_type(self, child_link):
Return True if the child link type is compatible with this element's type hierarchy.
def
verify_relation_extended(self, link_obj, elements):
Extended relation validation hook; returns (True, '') by default.
SBDL element representing an existing control that prevents a failure cause or mode.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
SBDL element representing an existing detection (test) that measures failure mode occurrence.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
SBDL element representing a FMEA failure effect with optional severity rating.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
verify_parent_link_type(self, parent_link):
Return True if the parent link type is compatible with this element's type hierarchy.
def
verify_relation_extended(self, link_obj, elements):
Extended relation validation hook; returns (True, '') by default.
SBDL element representing a FMEA failure mode with optional detectability rating.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
verify_parent_link_type(self, parent_link):
Return True if the parent link type is compatible with this element's type hierarchy.
def
verify_child_link_type(self, child_link):
Return True if the child link type is compatible with this element's type hierarchy.
@classmethod
def
verify_fmea_relation_extended(self, source, link_obj, elements):
Check that hierarchical FMEA link targets share a common aspect ancestry; return (is_valid, error).
def
verify_relation_extended(self, link_obj, elements):
Verify a failure-mode relation against FMEA aspect hierarchy rules.
SBDL element representing a system function with optional parent/child hierarchy.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
SBDL element representing a structural grouping of other elements with no semantic implications.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
verify_child_link_type(self, child_link):
Always returns True; groups accept any child element type.
SBDL element representing an external interface exposed by an aspect.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
verify_parent_link_type(self, parent_link):
Return True if the parent link type is compatible with this element's type hierarchy.
Parsed operator statement (e.g. link or source-link operator between elements).
def
data_type(self):
Return the declaration data type; None for generic statements.
def
copy(self):
Return a shallow copy of this statement.
class
SBDL_Parsed_Object(sbdl_model.SBDL_Parser.Parser_Hints):
Abstract base for all parsed SBDL objects; raises on any unimplemented interface method.
def
throw_error(self, err='Unknown'):
Raise an Exception indicating that an abstract method was called.
class
SBDL_Parser:
Container for SBDL language parser constants, token rules, directive handling, and parsing logic.
@classmethod
def
parse_statements(self, parser_element):
Parse all SBDL statements within a parser element and return a list of statement objects.
@classmethod
def
parse_elements(self, parser_element):
Alias for parse_statements; parse all SBDL elements in a parser element.
class
SBDL_Parser.Parser_Element(sbdl_model.SBDL_Parser.Parser_Hints):
Represents a single parsed text element with its source location and line index information.
def
content(self):
Return the raw text content of this parser element.
def
content_line_layout(self):
Return a formatted string showing content with line numbers derived from the index map.
def
content_sanitized(self):
Return the content with leading and trailing whitespace stripped.
def
source(self):
Return the source file path of this parser element.
def
index(self):
Return the source line number at the start of this element's content.
def
indexes(self):
Return the full list of (content_position, line_number) index pairs for this element.
def
indexes_at(self, pos):
Return all index pairs whose content position is at or after the given pos.
def
index_at(self, pos):
Return the source line number corresponding to the given content position.
def
reference(self):
Return a shortened 'source:line' reference string for this element.
def
context(self):
Return the context string associated with this parser element.
def
copy(self):
Return a new Parser_Element with the same content, source, indexes, and context.
@classmethod
def
shorten_reference(self, reference):
Strip configured prefix and apply maximum-length elision to a reference string.
@classmethod
def
line_layout_content_indexes(self, content, indexes):
Build a numbered-line display string from content and its (position, line_number) index pairs.
SBDL element representing a technical realisation of a design definition.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
SBDL element representing a system requirement or acceptance criterion.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
Element representation of a 'scope' statement that applies namespace prefixes.
@classmethod
def
class_type_name(self):
Return the 'scope' statement type name.
Parsed 'scope' statement that applies a namespace prefix to identifiers in the current block.
def
data_type(self):
Return the declaration data type; None for generic statements.
def
copy(self):
Return a shallow copy of this statement.
def
identifier(self):
Return a synthetic identifier composed of statement type and source reference.
class
SBDL_Semantics:
Container for SBDL semantic rules: allowed type links, type properties, type/category/property descriptions, and custom type registration.
@classmethod
def
get_valid_link_type_for_type_name(self, type_name):
Return a list of valid relation target type names for the given element type name.
@classmethod
def
type_color(self, type_name):
Return (and memoize) a consistent hex color string for the given element type name.
@classmethod
@functools.lru_cache(maxsize=None)
def
calc_bsci(self, statement_text, language):
Calculate a Behavioural Specification Complexity Index (BSCI) score for the given statement text.
@classmethod
def
get_identifier_from_string( self, input_string, aggressive_length=20, min_word_len=3, separator='', stop_words=None, stop_chars=None, abbreviations=None, right_to_left=True):
Derive a compact SBDL identifier from a natural-language string by applying stop-word removal, abbreviations, and vowel elision.
@classmethod
@functools.lru_cache(maxsize=None)
def
get_identifier_from_string_eng_standard_v2( self, input_string, aggressive_length=20, min_word_len=3, separator='', right_to_left=True):
Derive a compact identifier using the v2 engineering standard stop-word/abbreviation set.
@classmethod
@functools.lru_cache(maxsize=None)
def
get_identifier_from_string_eng_standard_v1( self, input_string, aggressive_length=20, min_word_len=3, separator='', right_to_left=True):
Derive a compact identifier using the v1 engineering standard stop-word/abbreviation set.
@classmethod
@functools.lru_cache(maxsize=None)
def
get_identifier_from_string_eng_standard( self, input_string, aggressive_length=20, min_word_len=3, separator='', right_to_left=True):
Derive a compact identifier using the default engineering standard rules.
@classmethod
def
shorten_string_on_word_boundary(self, input_string, shorten_length):
Return the last shorten_length characters of input_string, aligned to a word boundary.
@classmethod
def
get_unique_id_from_string(self, input_string):
Generate a short, base-62-encoded unique identifier from a SHA-256 hash of the input string.
@classmethod
def
create_custom_embedded_function(self, function_content, argument_list):
Compile an embedded Python function from a #!python-prefixed string and return the callable.
@classmethod
def
create_customtype_from_prototype(self, prototype):
Register a new custom element type from a prototype declaration, building its class and semantic rules.
SBDL element representing a system state with optional parent/child hierarchy.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
Concrete parsed statement holding its parser element, type, attribute data, and error state.
def
parser_element(self):
Return a copy of the underlying Parser_Element for this statement.
def
type(self):
Return the statement type string.
def
data_type(self):
Return the declaration data type; None for generic statements.
def
data(self):
Return the attribute data dict, injecting the syntactic parent as a parent attribute if present.
def
error(self):
Return True if this statement encountered a parse error.
def
error_position(self):
Return the character position within the content where the error occurred.
def
error_message(self):
Return the error message string for this statement.
def
extend_error_message(self, extension):
Append additional text to the existing error message.
def
copy(self):
Return a shallow copy of this statement.
def
inherit_data(self, parent_data, append=False):
Merge parent_data into this statement's data dict.
For keys that exist only in parent_data, they're added as-is.
For keys that exist in both dictionaries, behavior depends on append:
- If append=True, the parent's value is appended to the existing
value with a ", " separator (existing first, then parent).
- If append=False (default), the existing value is preserved and
the parent's value is discarded.
def
apply_scope(self, scope_data):
Prepend scope prefixes to matching attribute values and return the resulting scope map.
def
identifier(self):
Return a synthetic identifier composed of statement type and source reference.
def
syntactic_parent(self):
Return the syntactic parent statement, or None if there is none.
SBDL element representing a test instance for a particular design element.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
SBDL element representing a dynamic trace instance embedded in a log or execution record.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
SBDL element representing a state transition; must reference exactly one ordered pair of states.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
def
verify_self(self, elements=None):
Verify that this transition references exactly two state links.
def
verify_parent_link_type(self, parent_link):
Return True if the parent link type is compatible with this element's type hierarchy.
SBDL element representing a system use case with an optional actor property.
@classmethod
def
class_type_name(self):
Return the type name string for this element class; None for the abstract base.
Element representation of a 'using' statement that imports shared attributes.
@classmethod
def
class_type_name(self):
Return the 'using' statement type name.
Parsed 'using' statement that imports attributes from named element definitions into the current scope.
def
data_type(self):
Return the declaration data type; None for generic statements.
def
copy(self):
Return a shallow copy of this statement.
def
identifier(self):
Return a synthetic identifier composed of statement type and source reference.
def
set_config_data(new_config):
Replace the entire configuration dict.
def
set_config_value(key, data, warn_on_new=True):
Set a configuration value by key, warning if the key is new and skipping if locked.
def
set_help_text(help_content):
Set the application help text string (loaded lazily from the manual).
def
set_logo(logo_text):
Set the application logo string (the large ANSI banner is assigned at startup).
def
template_docx_file(template_dict, infile, outfile):
Render infile as a docxtpl Word template with template_dict context and save to outfile.
def
use_config_data(new_config_data, skip_keys=None):
Merge new_config_data into the global config, skipping locked and explicitly excluded keys.
def
version():
Return the current compiler version string.
def
version_dev():
Return the development version marker string.
def
version_dsl():
Return the DSL language specification version string.
def
version_rest_api():
Return the REST API version string.
def
write_aggregated_output(sbdl_ast, output_file, file_opener, __, print_l):
Write all AST elements as SBDL statements to output_file, optionally sorted and pretty-printed.
def
write_aspect_graph_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Generate a PlantUML component/decomposition diagram from the AST and write it to output_file.
def
write_csv_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Generate a CSV FMEA table from the AST and write it to output_file.
def
write_element_graph_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Generate a detailed PlantUML element diagram showing all element properties and relations.
def
write_function_graph_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Generate a PlantUML sequence diagram of function/event flows and write it to output_file.
def
write_matrixcsv_output(sbdl_ast, output_file, file_opener, __, ___):
Write a flat CSV matrix of all element attributes (from the full AST dict) to output_file.
def
write_matrixjson_output(sbdl_ast, output_file, file_opener, __, ___):
Write the full AST as an indented JSON dict to output_file.
def
write_network_graph_output(sbdl_ast, output_file, _, arguments, print_l):
Generate a networkx/matplotlib network graph of all elements and write it to output_file.
def
write_process_graph_output(sbdl_ast, output_file, file_opener, _, print_l):
Generate a PlantUML activity/process diagram from the AST and write it to output_file.
def
write_requirement_graph_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Generate a PlantUML requirements diagram from the AST and write it to output_file.
def
write_rpc_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Send AST elements to a remote REST endpoint for processing and write the response to output_file.
def
write_sigma_graph_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Generate an interactive Sigma.js HTML network graph from the AST and write it to output_file.
def
write_sql_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Materialise the SBDL element model into a normalised SQL database.
The model is written into three related tables so that relations -- including
structural parent/child links -- become first-class, joinable rows pointing
at other elements:
- elements(identifier PK, type, types, stereotype, description, reference,
hash) -- one row per SBDL element. 'description' and 'reference' are
promoted to columns as the two most commonly queried properties.
- properties(element_id FK, name, value) -- every other property
(tags, FMEA ratings, conditions, custom: attributes ...) as
entity-attribute-value rows, so arbitrary/custom properties need no
schema change.
- relations(source_id FK, relation, target_id, stereotype, hash, derived) --
every typed relation as a directed edge. 'relation' is the SBDL relation
name ('aspect', 'requirement', 'fmea:mode', 'parent', 'child', ...). Both
reciprocal halves are kept (distinct named relations) with 'derived'
flagging the bijective reverse half (1) versus the forward-declared link
(0); exact duplicate edges are de-duplicated.
- customtypes(name, declaration, ordinal) -- each custom type's verbatim
canonical declaration, in source order, so 'from:sql' can re-emit them
ahead of the elements that use them and round-trip custom typing losslessly.
A small sbdl_meta(key,value) table records the schema version, generator
version and a timestamp to support future synchronisation/diffing and the
'from:sql' reconstruction reader.
The backend is selected from the output locator (-o): a plain path writes a
local SQLite file; a 'mysql://'/'mariadb://' DSN selects a remote backend
(the seam for pushing the same schema to a server, not yet implemented).
Returns the number of errors encountered while gathering the model.
def
write_state_graph_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Generate a PlantUML state-machine diagram from the AST and write it to output_file.
def
write_sysmlv2_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Translate the SBDL element model into a SysML v2 textual-notation document and write it to output_file.
The mapping mirrors the SBDL type/element distinction: SBDL customtypes
become SysML v2 definitions (part/requirement/action/... def, keyword
chosen from the custom type's resolved base), and SBDL elements become
usages typed by their custom type where they have one. Aspects/definitions/
realisations/groups are parts, requirements (and FMEA elements) are
requirements, functions and events are actions, states are states, use cases
and interfaces map directly, and tests are verification cases.
The translation favours persistent model constructs (everything survives
parsing, unlike '//' notes):
- descriptions become 'doc' (Documentation) elements;
- provenance (the originating SBDL type and source location) becomes a
'comment' (Comment) element;
- numeric FMEA ratings become attributes;
- a function's ordered events -- and, recursively, each event's child
events -- are invoked as action steps ('first start; then perform ...;'),
so multi-level sequences are preserved without producing unreferenced
action definitions;
- states and transitions are collected into a single 'state def' state
machine (states as nested usages), with each transition rendered as
'transition ... first ... accept ... then ...';
- a requirement and its aspect become a 'satisfy' relation;
- every other typed relation (FMEA cross-links, test coverage, conditional
alternatives, generic 'related' and structural parent links) becomes a
typed KerML 'dependency' whose name encodes the SBDL relation type.
SBDL conditions are free text rather than valid SysML v2 boolean
expressions, so conditional events keep their condition as documentation
(and their alternatives as dependencies) instead of fabricating unresolvable
decision guards. SBDL identifiers are rendered as SysML v2 unrestricted
(single-quoted) names so ids containing ':', '-', '.' or '::' remain valid,
and all elements live in a single package for simple name resolution.
Returns the number of errors encountered while gathering the model.
def
write_template_fill(sbdl_ast, output_file, file_opener, arguments, print_l):
Render a Jinja2 or Office template (txt/docx/xlsx) with AST data and write the result to output_file.
def
write_usecase_graph_output(sbdl_ast, output_file, file_opener, arguments, print_l):
Generate a PlantUML use-case diagram from the AST and write it to output_file.
def
write_yaml_tree_output(sbdl_ast, output_file, file_opener, __, ___):
Write the full AST as a YAML document to output_file.