diff --git a/setup.py b/setup.py index 11bc12d..fd307e0 100644 --- a/setup.py +++ b/setup.py @@ -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( @@ -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', @@ -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', @@ -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=[ @@ -86,4 +92,4 @@ def read(*names, **kwargs): 'nameless = nameless.cli:main', ] }, -) \ No newline at end of file +) diff --git a/src/Event.py b/src/Event.py index d68e9b1..0992afc 100644 --- a/src/Event.py +++ b/src/Event.py @@ -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 diff --git a/src/ReadStateMachine.py b/src/ReadStateMachine.py index cbb5aab..de535ed 100644 --- a/src/ReadStateMachine.py +++ b/src/ReadStateMachine.py @@ -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) diff --git a/src/StateMachine.py b/src/StateMachine.py index 37ed5a1..7adc238 100644 --- a/src/StateMachine.py +++ b/src/StateMachine.py @@ -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): @@ -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): """ @@ -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: