Module io

sismic.io.import_from_yaml(text=None, filepath=None, *, ignore_schema=False, ignore_validation=False)

Import a statechart from a YAML representation (first argument) or a YAML file (filepath argument).

Unless specified, the structure contained in the YAML is validated against a predefined schema (see sismic.io.SCHEMA), and the resulting statechart is validated using its validate() method.

Parameters:
  • text (str) – A YAML text. If not provided, filepath argument has to be provided.

  • filepath (str) – A path to a YAML file.

  • ignore_schema (bool) – set to True to disable yaml validation.

  • ignore_validation (bool) – set to True to disable statechart validation.

Return type:

Statechart

Returns:

a Statechart instance

sismic.io.export_to_yaml(statechart, filepath=None)

Export given Statechart instance to YAML. Its YAML representation is returned by this function. Automatically save the output to filepath, if provided.

Parameters:
  • statechart (Statechart) – statechart to export

  • filepath (str) – save output to given filepath, if provided

Return type:

str

Returns:

A textual YAML representation

sismic.io.export_to_plantuml(statechart, filepath=None, *, based_on=None, based_on_filepath=None, statechart_name=True, statechart_description=False, statechart_preamble=False, state_contracts=False, state_action=True, transition_contracts=False, transition_action=True)

Export given statechart to plantUML (see http://plantuml/plantuml). If a filepath is provided, also save the output to this file.

Due to the way statecharts are representing, and due to the presence of features that are specific to Sismic,the resulting statechart representation does not include all the informations. For example, final states and history states won’t have name, actions and contracts.

If a previously exported representation for the statechart is provided, either as text (based_on parameter) or as a filepath (based_on_filepath parameter), it will attempt to reuse the modifications made to the transitions (their direction and length).

Parameters:
  • statechart (Statechart) – statechart to export

  • filepath (str) – save output to given filepath, if provided

  • based_on (str) – existing representation of the statechart in PlantUML

  • based_on_filepath (str) – filepath to an existing representation of the statechart in PlantUML

  • statechart_name (bool) – include the name of the statechart

  • statechart_description (bool) – include the description of the statechart

  • statechart_preamble (bool) – include the preamble of the statechart

  • state_contracts (bool) – include state contracts

  • state_action (bool) – include state actions (on entry, on exit and internal transitions)

  • transition_contracts (bool) – include transition contracts

  • transition_action (bool) – include actions on transition

Return type:

str

Returns:

textual representation using plantuml