Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from os.path import splitext
from setuptools import setup

changelog_url = 'https://github.com/ZigRazor/PyStateMachine/blob/master/CHANGELOG.md'


def read(*names, **kwargs):
with io.open(
Expand All @@ -27,7 +29,10 @@ def read(*names, **kwargs):
license='GNU GENERAL PUBLIC LICENSE',
description='PyStateMachine Package',
long_description='%s\n%s' % (
re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.md')),
re.compile(
'^.. start-badges.*^.. end-badges',
re.M | re.S
).sub('', read('README.md')),
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.md'))
),
author='ZigRazor',
Expand All @@ -40,7 +45,8 @@ def read(*names, **kwargs):
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
# complete classifier list:
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU GENERAL PUBLIC LICENSE',
Expand All @@ -61,7 +67,7 @@ def read(*names, **kwargs):
'Topic :: Utilities',
],
project_urls={
'Changelog': 'https://github.com/ZigRazor/PyStateMachine/blob/master/CHANGELOG.md',
'Changelog': changelog_url,
'Issue Tracker': 'https://github.com/ZigRazor/PyStateMachine/issues',
},
keywords=[
Expand All @@ -86,4 +92,4 @@ def read(*names, **kwargs):
'nameless = nameless.cli:main',
]
},
)
)
9 changes: 8 additions & 1 deletion src/Event.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
class Event:
"""Construct an Event class"""

def __init__(self, name: str, to_state: str, pre_conditions: Conditions, post_conditions: Conditions, pre_actions: Actions, post_actions: Actions):
def __init__(
self, name: str,
to_state: str,
pre_conditions: Conditions,
post_conditions: Conditions,
pre_actions: Actions,
post_actions: Actions
):
"""Initialize Event Class"""
self.name = name
self.to_state = to_state
Expand Down
8 changes: 7 additions & 1 deletion src/ReadStateMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ def ReadStateMachineFile(xml_file: str):
post_actions = Actions(post_action_elements)

events[event_name] = Event(
event_name, to_state, pre_conditions, post_conditions, pre_actions, post_actions)
event_name,
to_state,
pre_conditions,
post_conditions,
pre_actions,
post_actions
)
# print(event.to_string())
elif state_child.tag == "Name":
# print("Name element = ", state_child.text)
Expand Down
13 changes: 9 additions & 4 deletions src/StateMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class StateMachine:
xml_file (str): The name of the xml that defines the state machine.
states (list): list of possible states of the machine.
current_state (str): the current state of the machine.
context (dict): dictionary that contains the imported module at runtime for state machine operations.
context (dict): dictionary that contains the imported module
at runtime for state machine operations.
saved_state (list): list of variables for restore state in case of rollback.
"""
def __init__(self, xml_file: str):
Expand All @@ -25,8 +26,11 @@ def __init__(self, xml_file: str):
self.current_state = ""
self.context = {}
self.saved_state = None
logging.basicConfig(filename=xml_file.split(sep=".xml")[
0] + '.log', format='%(asctime)s - %(levelname)s - %(message)s', level=logging.DEBUG)
logging.basicConfig(
filename=xml_file.split(sep=".xml")[0] + '.log',
format='%(asctime)s - %(levelname)s - %(message)s',
level=logging.DEBUG
)

def __CheckConditions(self, conditions):
"""
Expand All @@ -35,7 +39,8 @@ def __CheckConditions(self, conditions):
Parameters:
conditions (list): List of condition to check.
Returns:
all_conditions_satisfied: a boolean that indicates if all conditions are satisfied
all_conditions_satisfied:
a boolean that indicates if all conditions are satisfied
"""
all_conditions_satisfied = True
if conditions is not None:
Expand Down