Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add int state suport #25

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/python/fysom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _apply(self, cfg):
>> Prepares the event to state transitions map.
'''
init = cfg['initial'] if 'initial' in cfg else None
if self._is_base_string(init):
if self._is_base_string_or_int(init):
init = {'state': init}

self._final = cfg['final'] if 'final' in cfg else None
Expand All @@ -207,7 +207,7 @@ def add(e):
Adds the event into the machine map.
'''
if 'src' in e:
src = [e['src']] if self._is_base_string(
src = [e['src']] if self._is_base_string_or_int(
e['src']) else e['src']
else:
src = [WILDCARD]
Expand Down Expand Up @@ -357,12 +357,12 @@ def _change_state(self, e):
if hasattr(self, fnname):
return getattr(self, fnname)(e)

def _is_base_string(self, object): # pragma: no cover
def _is_base_string_or_int(self, object): # pragma: no cover
'''
Returns if the object is an instance of basestring.
'''
try:
return isinstance(object, basestring)
return isinstance(object, basestring) or isinstance(object, int)
except NameError:
return isinstance(object, str)

Expand Down