# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['favink']

package_data = \
{'': ['*']}

setup_kwargs = {
    'name': 'favink',
    'version': '2.0.0',
    'description': 'Over-simple Python finite automata (finite-state machine) implementation',
    'long_description': '# FAVink\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/7134fd6ab3adcd626ac9/maintainability)](https://codeclimate.com/github/k-vinogradov/favink/maintainability)\n[![CodeFactor](https://www.codefactor.io/repository/github/k-vinogradov/favink/badge)](https://www.codefactor.io/repository/github/k-vinogradov/favink)\n[![Build Status](https://travis-ci.org/k-vinogradov/favink.svg?branch=master)](https://travis-ci.org/k-vinogradov/favink)\n\n- [FAVink](#favink)\n  - [Getting Started](#getting-started)\n  - [Transition Table and Initial State](#transition-table-and-initial-state)\n  - [Events](#events)\n    - [Event Handler Definitions](#event-handler-definitions)\n  - [Car Example](#car-example)\n  - [API Reference](#api-reference)\n    - [Predefined `FiniteAutomata` Methods](#predefined-finiteautomata-methods)\n      - [`FiniteAutomata.get_state(self)`](#finiteautomatagetstateself)\n      - [`FiniteAutomata.get_allowed_transitions(self)`](#finiteautomatagetallowedtransitionsself)\n      - [`FiniteAutomata.is_allowed(self, transition)`](#finiteautomataisallowedself-transition)\n    - [Transition Methods](#transition-methods)\n\nOver-simple python finite automata (finite-state machine) implementation\n\n## Getting Started\n\nTo install favink use the package from the PyPI repository:\n\n```sh\npip install favink\n```\n\nTo add finite automata feature to the class in your code you have to inherit\nFiniteAutomata class and define the following members:\n\n- transitions table `transitions`\n- initial state `init_state`\n- event handlers methods.\n\nFor every transition the constructor creates a dynamic method with argument mask\n`(self, *args, **kwargs)`. Each method is named after the transition.\n\nTo make the transition you should call the transition method. After the method\nhas been called it changes the instance state and invoke related event handlers.\nIf the called transition isn\'t allowed for the current state `InvalidTransition`\nextension will be raised.\n\n## Transition Table and Initial State\n\nThe `transitions` is a dictionary where keys are transition names,\nvalues define the allowed and target states:\n\n```Python\ntransitions = {\n    "transition_1":\n    [\n        "allowed_state_1",\n        "target_state_1"\n    ],\n    "transition_2":\n    [\n        [\n            "allowed_state_2",\n            "allowed_state_3"\n        ],\n        "target_state_2"\n    ]\n}\n```\n\nInitial state is defined by `init_state` member.\n\n## Events\n\n![Transition Life Cycle](https://github.com/k-vinogradov/favink/raw/master/docs/images/lifecycle.svg?sanitize=true)\n\nMaking of transition triggers the following events and invokes the related handlers\n(if they have been implemented in the class):\n\n- `after`\n- `before`\n- `on`\n\n### Event Handler Definitions\n\nFor every state (for example `state_name`) the following methods can be defined:\n\n```Python\ndef before_state_name(self, name, *args, **kwargs):\n    ...\n\n\ndef on_state_name(self, name, origin, *args, **kwargs):\n    ...\n\n\ndef after_state_name(self, name, *args, **kwargs):\n    ...\n```\n\nThe following arguments are passed to the handlers:\n\n- `name` is a invoked transition name,\n- `origin` (passed only to `on_...` handler) is a previous state name,\n- `*args, **kwargs` are positional and keyword arguments passed to the transition method.\n\nIf `after_...` or `before...` handlers raise the exception transition is aborted.\n\n## Car Example\n\n![Transition Life Cycle](https://github.com/k-vinogradov/favink/raw/master/docs/images/car.svg?sanitize=true)\n\n```Python\nclass Car(FiniteAutomata):\n    init_state = "stopped"\n    transitions = {\n        "start_engine": ["stopped", "idle"],\n        "stop_engine": ["idle", "stopped"],\n        "forward": ["idle", "moving_forward"],\n        "backward": ["idle", "moving_backward"],\n        "stop": [["moving_forward", "moving_backward"], "idle"],\n    }\n\n    def on_stopped(self, transition, origin, *args, **kwargs):\n        print("Engine has been stopped")\n\n    def on_idle(self, transition, origin, *args, **kwargs):\n        print("I\'m not moving, but engine is on")\n\n    def on_moving_forward(self, transition, origin, *args, **kwargs):\n        print("Let\'s go!")\n\n    def on_moving_backward(self, transition, origin, *args, **kwargs):\n        print("Why are we retreating?")\n\ncar = Car()\n\ncar.start_engine()\ncar.forward()\ncar.stop()\ncar.backward()\ncar.stop()\ncar.stop_engine()\n```\n\nOutput:\n\n```plain\nI\'m not moving, but engine is on\nLet\'s go!\nI\'m not moving, but engine is on\nWhy are we retreating?\nI\'m not moving, but engine is on\nEngine has been stopped\n```\n\n## API Reference\n\n### Predefined `FiniteAutomata` Methods\n\n#### `FiniteAutomata.get_state(self)`\n\nReturns the current instance state name as a string.\n\n#### `FiniteAutomata.get_allowed_transitions(self)`\n\nReturn the list contains all transactions which are allowed for the current instance state.\n\n#### `FiniteAutomata.is_allowed(self, transition)`\n\n### Transition Methods\n\nDynamically defined methods for every transition (key) in the `transitions` dictionary.\n',
    'author': 'Konstantin V.',
    'author_email': 'mail@k-vinogradov.ru',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/k-vinogradov/favink',
    'packages': packages,
    'package_data': package_data,
    'python_requires': '>=3.5,<4.0',
}


setup(**setup_kwargs)
