Skip to content

Commit

Permalink
Prepare for 0.24.2
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Mar 1, 2018
1 parent 3d10620 commit a8945c9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Changelog
=========

0.24.1 (2018-02-27)
0.24.2 (2018-02-27)
-------------------

- (Added) ``sismic.io`` contains an ``export_to_plantuml`` function to export a statechart to PlantUML.
- (Added) ``sismic-behave`` accepts a ``--properties`` argument, pointing to a list of YAML files containing
property statecharts that will be checked during execution (in a fail fast mode).
- (Changed) ``sismic.io.export_to_yaml`` accepts an additional ``filepath`` argument.
- (Fix) Whitespaces in strings are trimmed when using ``import_from_dict`` (and hence, using ``import_from_yaml``).


0.23.1 (2018-02-20)
Expand Down
2 changes: 1 addition & 1 deletion sismic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__description__ = 'Sismic Interactive Statechart Model Interpreter and Checker'
__version__ = '0.24.1'
__version__ = '0.24.2'
__url__ = 'https://github.com/AlexandreDecan/sismic/'
__author__ = 'Alexandre Decan'
__email__ = 'alexandre.decan@lexpage.net'
Expand Down
27 changes: 19 additions & 8 deletions sismic/io/datadict.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,25 @@ def _import_transition_from_dict(state_name: str, transition_d: Mapping[str, Any
:return: an instance of Transition
"""
event = transition_d.get('event', None)
transition = Transition(state_name, transition_d.get('target', None), event,
transition_d.get('guard', None), transition_d.get('action', None))
guard = transition_d.get('guard', None)
action = transition_d.get('action', None)

transition = Transition(
state_name,
transition_d.get('target', None),
event.strip() if event else None,
guard.strip() if guard else None,
action.strip() if action else None,
)

# Preconditions, postconditions and invariants
for condition in transition_d.get('contract', []):
if condition.get('before', None):
transition.preconditions.append(condition['before'])
transition.preconditions.append(condition['before'].strip())
elif condition.get('after', None):
transition.postconditions.append(condition['after'])
transition.postconditions.append(condition['after'].strip())
elif condition.get('always', None):
transition.invariants.append(condition['always'])
transition.invariants.append(condition['always'].strip())

return transition

Expand All @@ -94,8 +102,11 @@ def _import_state_from_dict(state_d: Mapping[str, Any]) -> StateMixin:
"""
name = state_d.get('name')
stype = state_d.get('type', None)

on_entry = state_d.get('on entry', None)
on_entry = on_entry.strip() if on_entry else None
on_exit = state_d.get('on exit', None)
on_exit = on_exit.strip() if on_exit else None

if stype == 'final':
state = FinalState(name, on_entry=on_entry, on_exit=on_exit) # type: Any
Expand All @@ -121,11 +132,11 @@ def _import_state_from_dict(state_d: Mapping[str, Any]) -> StateMixin:
# Preconditions, postconditions and invariants
for condition in state_d.get('contract', []):
if condition.get('before', None):
state.preconditions.append(condition['before'])
state.preconditions.append(condition['before'].strip())
elif condition.get('after', None):
state.postconditions.append(condition['after'])
state.postconditions.append(condition['after'].strip())
elif condition.get('always', None):
state.invariants.append(condition['always'])
state.invariants.append(condition['always'].strip())
return state


Expand Down
2 changes: 1 addition & 1 deletion sismic/model/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def __repr__(self):
return 'Transition({!r}, {!r}, event={!r})'.format(self.source, self.target, self.event)

def __str__(self):
return '{} [{}] -> {}'.format(self.source, self.event, self.target if self.target else '')
return '{} -> {} [{}] -> {}'.format(self.source, self.event, self.guard, self.target if self.target else '')

def __hash__(self):
return hash(self.source)

0 comments on commit a8945c9

Please sign in to comment.