semvec/pypi-packages huggingface dataset:
infinite-state-machine 0.1.1
An Infinite State Machine
Requires Python: >=3.7

# python_state_machine
An Infinite State Machine implemented in python

Why "Infinite"?

Finite state machines are a great method for implementing event driven applications and operating systems. 
However, when implemented, they become fixed implementations of an application that do not easily lend themselves
to refactoring into another application.

The Infinite State Machine implemented here uses "Action Packs" that can be easily shared with other 
 State Machines. By abstracting the actions required to implement specific functions, such as a message queue or 
an automation framework, developing a state machine becomes as simple and familiar as writing a Python application that 
imports its functionality in packages.

# Unit Tests
Run the unit tests from the package root using this syntax:

```commandline
python3 -m unittest -v ism.tests.test_ism.TestISM
```

To clean down the unit test mysql databases created  log into mysql using the -s option to give clean result sets, then:

```commandline
mysql> SELECT CONCAT('DROP DATABASE ', SCHEMA_NAME, ';') FROM 
information_schema.schemata WHERE SCHEMA_NAME LIKE '%ism_default_%'; 

CONCAT('DROP DATABASE `', SCHEMA_NAME, '`;')
DROP DATABASE `ism_default_1611855489819`;
DROP DATABASE `ism_default_1611855533770`;
DROP DATABASE `ism_default_1611856233213`;
DROP DATABASE `ism_default_1611856253150`;
DROP DATABASE `ism_default_1611856264937`;
```
Then copy and paste the drop statements into the command line.
py-deprecate 0.0.4
Python Deprecation Toolkit
Requires Python: >=3.5

# Python Deprecation Toolkit


Python code deprecation toolkit for deprecating your Python code using a
[shitlist](https://sirupsen.com/shitlists/) approach.


## Installation

Install using `pip install py-deprecate`.

## Example

```py
from py_deprecate import deprecated
from py_deprecate.exceptions import DeprecationIntroduced

def allowed_sum_caller() -> int:
    return sum(5, 10)

def forbidden_sum_caller() -> int:
    return sum(5, 10)

# Only allowed_sum_caller is allowed to use sum.
@deprecated(
    allowed_deprecations=[allowed_sum_caller],
    message="sum is no longer supported."
)
def sum(a: int, b: int) -> int:
    return a + b

assert allowed_sum_caller() == 15

# Now, try with the function that's not whitelisted
try:
    forbidden_sum_caller()
except DeprecationIntroduced as exc:
    print("Caught deprecated exception!")
#> Caught deprecated exception!
```

## Behaviour

`py_deprcate` will raise an exception by default if a deprecated method
or function is called where it's not supposed to be called. This can be
overridden by specifying a behavior. Continuing from the example above:

```py
from py_deprecate import deprecated, Disabled

@deprecated(
    allowed_deprecations=[allowed_sum_caller],
    message="sum is no longer supported.",
    behavior=Disabled
)
def sum(a: int, b: int) -> int:
    return a + b

assert forbidden_sum_caller() == 15
```

Here we've disabled all the side effects by using `Disabled` behavior. By default
three behaviors are present: `Disabled`, `RaiseExeption`, and `Log`. You can also
write your own behaviors like this:

```py
from typing import Callable
from py_deprecate.behaviors.base import BaseBehavior

class CustomBehavior(BaseBehavior):
    def execute(self, message: str, func: Callable, *args, **kwargs):
        print("Custom behavior that will print this and raise Exception.")
        raise Exception

@deprecated(
    allowed_deprecations=[allowed_sum_caller],
    message="sum is no longer supported.",
    behavior=CustomBehavior
)
def sum(a: int, b: int) -> int:
    return a + b

forbidden_sum_caller()

#> Custom behavior that will print this and raise Exception.
#> Traceback (most recent call last):
#>  ...
#>  File "<stdin>", line 4, in execute
#> Exception
```

## Tests

Run the tests using `python -m unittest`.


## Resources

[Shitlist Driven Development](https://sirupsen.com/shitlists/) \
[This awesome Ruby gem that inspired me to create py_deprecate!](https://github.com/Shopify/deprecation_toolkit)

## License

Python Deprecation Toolkit is licensed under the [MIT License](https://github.com/multi-vac/py-deprecate/blob/master/LICENSE).