New Upstream Snapshot - python-fysom
Ready changes
Summary
Merged new upstream version: 2.1.6+git20211026.2.e358619 (was: 2.1.6+git20211026.1.e358619).
Resulting package
Built on 2022-12-19T21:34 (took 5m41s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots python3-fysom
Lintian Result
Diff
diff --git a/PKG-INFO b/PKG-INFO
index 97ad4ba..5a20fa7 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -8,7 +8,6 @@ Author-email: mansour@oxplot.com, jake@codeincomplete.com, maximilien.riehl@gmai
Maintainer:
Maintainer-email:
License: MIT
-Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
@@ -17,5 +16,4 @@ Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
-UNKNOWN
-
+pYthOn Finite State Machine
diff --git a/README b/README
index c088d9f..3c8c3f3 100644
--- a/README
+++ b/README
@@ -11,15 +11,12 @@
:target: https://badge.fury.io/py/fysom
:alt: Latest PyPI version
-
-
License
=======
MIT licensed. All credits go to Jake Gordon for the `original javascript
-implementation <https://github.com/jakesgordon/javascript-state-machine/>`_
-and to Mansour Behabadi for the `python
-port <https://github.com/oxplot/fysom>`_.
+implementation <https://github.com/jakesgordon/javascript-state-machine/>`_ and
+to Mansour Behabadi for the `python port <https://github.com/oxplot/fysom>`_.
Synopsis
========
@@ -42,10 +39,10 @@ Developer setup
---------------
This module uses `PyBuilder <http://pybuilder.github.io>`_.
+
::
- sudo pip install pyb_init
- pyb-init github mriehl : fysom
+ pip install pybuilder
Running the tests
-----------------
@@ -59,10 +56,22 @@ Generating and using a setup.py
::
- pyb
+ pyb package -E linux-release
cd target/dist/fysom-$VERSION
./setup.py bdist_rpm #build RPM
+Publish sdist to PyPI
+-------------------------------
+
+::
+
+ pip install twine
+ pyb package -E linux-release
+ cd target/dist/fysom-$VERSION
+ ./setup.py sdist
+ # requires .pypirc configuration, obviously
+ twine upload -r pypi dist/*
+
Looking at the coverage
-----------------------
@@ -77,7 +86,8 @@ USAGE
Basics
------
-::
+.. code:: python
+ :number-lines:
from fysom import Fysom
@@ -88,32 +98,34 @@ Basics
{'name': 'calm', 'src': 'red', 'dst': 'yellow'},
{'name': 'clear', 'src': 'yellow', 'dst': 'green'} ] })
-... will create an
-object with a method for each event:
+... will create an object with a method for each event:
-- fsm.warn() - transition from 'green' to 'yellow'
-- fsm.panic() - transition from 'yellow' to 'red'
-- fsm.calm() - transition from 'red' to 'yellow'
-- fsm.clear() - transition from 'yellow' to 'green'
+- ``fsm.warn()`` - transition from ``green`` to ``yellow``
+- ``fsm.panic()`` - transition from ``yellow`` to ``red``
+- ``fsm.calm()`` - transition from ``red`` to ``yellow``
+- ``fsm.clear()`` - transition from ``yellow`` to ``green``
along with the following members:
-- fsm.current - contains the current state
-- fsm.isstate(s) - return True if state s is the current state
-- fsm.can(e) - return True if event e can be fired in the current state
-- fsm.cannot(e) - return True if event s cannot be fired in the current
+- ``fsm.current`` - contains the current state
+- ``fsm.isstate(s)`` - return ``True`` if state s is the current state
+- ``fsm.can(e)`` - return ``True`` if event ``e`` can be fired in the current
state
-
+- ``fsm.cannot(e)`` - return ``True`` if event ``s`` cannot be fired in the
+ current state
Shorter Syntax
--------------
-It's possible to define event transitions as 3-tuples (event name,
-source state, destination state) rather than dictionaries.
-``Fysom`` constructor accepts also keyword arguments ``initial``,
-``events``, ``callbacks``, and ``final``.
+It's possible to define event transitions as 3-tuples ``(event name, source
+state, destination state)`` rather than dictionaries. ``Fysom`` constructor
+accepts also keyword arguments ``initial``, ``events``, ``callbacks``, and
+``final``.
+
+This is a shorter version of the previous example:
-This is a shorter version of the previous example::
+.. code:: python
+ :number-lines:
fsm = Fysom(initial='green',
events=[('warn', 'green', 'yellow'),
@@ -121,17 +133,18 @@ This is a shorter version of the previous example::
('calm', 'red', 'yellow'),
('clear', 'yellow', 'green')])
-
Initialization
--------------
How the state machine should initialize can depend on your application
requirements, so the library provides a number of simple options.
-By default, if you don't specify any initial state, the state machine
-will be in the 'none' state and you would need to provide an event to
-take it out of this state:
-::
+By default, if you don't specify any initial state, the state machine will be
+in the ``none`` state and you would need to provide an event to take it out of
+this state:
+
+.. code:: python
+ :number-lines:
fsm = Fysom({'events': [
{'name': 'startup', 'src': 'none', 'dst': 'green'},
@@ -141,10 +154,12 @@ take it out of this state:
fsm.startup()
print fsm.current # "green"
-If you specify the name of your initial event (as in all the earlier
-examples), then an implicit 'startup' event will be created for you and
-fired when the state machine is constructed:
-::
+If you specify the name of your initial event (as in all the earlier examples),
+then an implicit ``startup`` event will be created for you and fired when the
+state machine is constructed:
+
+.. code:: python
+ :number-lines:
fsm = Fysom({'initial': 'green',
'events': [
@@ -152,9 +167,11 @@ fired when the state machine is constructed:
{'name': 'calm', 'src': 'red', 'dst': 'green'}]})
print fsm.current # "green"
-If your object already has a startup method, you can use a different
-name for the initial event:
-::
+If your object already has a startup method, you can use a different name for
+the initial event:
+
+.. code:: python
+ :number-lines:
fsm = Fysom({'initial': {'state': 'green', 'event': 'init'},
'events': [
@@ -162,9 +179,11 @@ name for the initial event:
{'name': 'calm', 'src': 'red', 'dst': 'green'}]})
print fsm.current # "green"
-Finally, if you want to wait to call the initial state transition event
-until a later date, you can defer it:
-::
+Finally, if you want to wait to call the initial state transition event until a
+later date, you can defer it:
+
+.. code:: python
+ :number-lines:
fsm = Fysom({'initial': {'state': 'green', 'event': 'init', 'defer': True},
'events': [
@@ -175,17 +194,19 @@ until a later date, you can defer it:
print fsm.current # "green"
Of course, we have now come full circle, this last example pretty much
-functions the same as the first example in this section where you simply
-define your own startup event.
+functions the same as the first example in this section where you simply define
+your own startup event.
-So you have a number of choices available to you when initializing your
-state machine.
+So you have a number of choices available to you when initializing your state
+machine.
-You can also indicate which state should be considered final.
-This has no effect on the state machine, but lets you use a shorthand
-method is_finished() that returns true if the state machine is in
-this 'final' state:
-::
+You can also indicate which state should be considered final. This has no
+effect on the state machine, but lets you use a shorthand method
+``is_finished()`` that returns ``True`` if the state machine is in this
+``final`` state:
+
+.. code:: python
+ :number-lines:
fsm = Fysom({'initial': 'green',
'final': 'red',
@@ -197,18 +218,18 @@ this 'final' state:
fsm.panic()
fsm.is_finished() # True
-
Dynamically generated event names
---------------------------------
Sometimes you have to compute the name of an event you want to trigger on the
-fly. Instead of relying on `getattr` you can use the `trigger` method, which takes
-a string (the event name) as a parameter, followed by any arguments/keyword
-arguments you want to pass to the event method.
-This is also arguably better if you're not sure if the event exists at all
-(FysomError vs. AttributeError, see below).
+fly. Instead of relying on ``getattr`` you can use the ``trigger`` method,
+which takes a string (the event name) as a parameter, followed by any
+arguments/keyword arguments you want to pass to the event method. This is also
+arguably better if you're not sure if the event exists at all (``FysomError``
+vs. ``AttributeError``, see below).
-::
+.. code:: python
+ :number-lines:
from fysom import Fysom
@@ -226,7 +247,9 @@ This is also arguably better if you're not sure if the event exists at all
Multiple source and destination states for a single event
---------------------------------------------------------
-::
+
+.. code:: python
+ :number-lines:
fsm = Fysom({'initial': 'hungry',
'events': [
@@ -237,19 +260,21 @@ Multiple source and destination states for a single event
This example will create an object with 2 event methods:
-- fsm.eat()
-- fsm.rest()
+- ``fsm.eat()``
+- ``fsm.rest()``
-The rest event will always transition to the hungry state, while the eat
-event will transition to a state that is dependent on the current state.
+The ``rest`` event will always transition to the ``hungry`` state, while the
+``eat`` event will transition to a state that is dependent on the current
+state.
-NOTE the rest event in the above example can also be specified as
-multiple events with the same name if you prefer the verbose approach.
+NOTE the ``rest`` event in the above example can also be specified as multiple
+events with the same name if you prefer the verbose approach.
-NOTE if an event can be triggered from any state, you can specify it
-using the '*' wildcard, or even by omitting the src attribute from its
-definition:
-::
+NOTE if an event can be triggered from any state, you can specify it using the
+``*`` wildcard, or even by omitting the ``src`` attribute from its definition:
+
+.. code:: python
+ :number-lines:
fsm = Fysom({'initial': 'hungry',
'events': [
@@ -259,9 +284,12 @@ definition:
{'name': 'eat_a_lot', 'src': '*', 'dst': 'sick'},
{'name': 'rest', 'dst': 'hungry'}]})
-NOTE if an event will not change the current state, you can specify destination
-using the '=' symbol. It's useful when using wildcard source or multiply sources:
-::
+NOTE if an event will not change the current state, you can specify the
+destination using the ``=`` symbol. It's useful when using wildcard source or
+multiple sources:
+
+.. code:: python
+ :number-lines:
fsm = Fysom({'initial': 'hungry',
'events': [
@@ -276,49 +304,51 @@ using the '=' symbol. It's useful when using wildcard source or multiply sources
Callbacks
---------
-5 callbacks are available if your state machine has methods using the
-following naming conventions:
+5 callbacks are available if your state machine has methods using the following
+naming conventions:
-- onbefore\_event\_ - fired before the *event*
-- onleave\_state\_ - fired when leaving the old *state*
-- onenter\_state\_ - fired when entering the new *state*
-- onreenter\_state\_ - fired when reentering the old *state* (a reflexive transition i.e. src == dst)
-- onafter\_event\_ - fired after the *event*
+- ``onbefore_event`` - fired before the event
+- ``onleave_state`` - fired when leaving the old state
+- ``onenter_state`` - fired when entering the new state
+- ``onreenter_state`` - fired when reentering the old state (a reflexive
+ transition i.e. ``src == dst``)
+- ``onafter_event`` - fired after the *event*
You can affect the event in 2 ways:
-- return False from an onbefore\_event\_ handler to cancel the event.
- This will raise a fysom.Canceled exception.
-- return False from an onleave\_state\_ handler to perform an
- asynchronous state transition (see next section)
+- return ``False`` from an ``onbefore_event`` handler to cancel the event.
+ This will raise a ``fysom.Canceled exception``.
+- return ``False`` from an ``onleave_state`` handler to perform an
+ asynchronous state transition (see next section).
For convenience, the 2 most useful callbacks can be shortened:
-- on\_event\_ - convenience shorthand for onafter\_event\_
-- on\_state\_ - convenience shorthand for onenter\_state\_
+- ``on_event`` - convenience shorthand for ``onafter_event``
+- ``on_state`` - convenience shorthand for ``onenter_state``
-In addition, a generic onchangestate() callback can be used to call a
+In addition, a generic ``onchangestate()`` callback can be used to call a
single function for all state changes.
-All callbacks will be passed one argument 'e' which is an object with
+All callbacks will be passed one argument ``e`` which is an object with
following attributes:
-- fsm Fysom object calling the callback
-- event Event name
-- src Source state
-- dst Destination state
-- (any other keyword arguments you passed into the original event
- method)
-- (any positional argument you passed in the original event method,
- in the 'args' attribute of the event)
+- ``fsm`` - Fysom object calling the callback
+- ``event`` - Event name
+- ``src`` - Source state
+- ``dst`` - Destination state
+- (any other keyword arguments you passed into the original event method)
+- (any positional argument you passed in the original event method, in the
+ ``args`` attribute of the event)
-Note that when you call an event, only one instance of 'e' argument is
-created and passed to all 4 callbacks. This allows you to preserve data
-across a state transition by storing it in 'e'. It also allows you to
-shoot yourself in the foot if you're not careful.
+Note that when you call an event, only one instance of ``e`` argument is
+created and passed to all 4 callbacks. This allows you to preserve data across
+a state transition by storing it in ``e``. It also allows you to shoot yourself
+in the foot if you're not careful.
Callbacks can be specified when the state machine is first created:
-::
+
+.. code:: python
+ :number-lines:
def onpanic(e):
print 'panic! ' + e.msg
@@ -348,7 +378,9 @@ Callbacks can be specified when the state machine is first created:
fsm.calm('bob', msg='sedatives in the honey pots')
Additionally, they can be added and removed from the state machine at any time:
-::
+
+.. code:: python
+ :number-lines:
def printstatechange(e):
print 'event: %s, src: %s, dst: %s' % (e.event, e.src, e.dst)
@@ -361,42 +393,43 @@ Additionally, they can be added and removed from the state machine at any time:
Asynchronous state transitions
------------------------------
-Sometimes, you need to execute some asynchronous code during a state
-transition and ensure the new state is not entered until you code has
-completed.
+Sometimes, you need to execute some asynchronous code during a state transition
+and ensure the new state is not entered until you code has completed.
A good example of this is when you run a background thread to download
-something as result of an event. You only want to transition into the
-new state after the download is complete.
+something as result of an event. You only want to transition into the new state
+after the download is complete.
-You can return False from your onleave\_state\_ handler and the state
-machine will be put on hold until you are ready to trigger the
-transition using the transition() method.
+You can return ``False`` from your ``onleave_state`` handler and the state
+machine will be put on hold until you are ready to trigger the transition using
+the ``transition()`` method.
Use as global machine
---------------------
-To manipulating lots of objects with a small memory footprint, there
-is a FysomGlobal class. Also a useful FysomGlobalMixin class to
-give convenience access for the state machine methods.
+To manipulating lots of objects with a small memory footprint, there is a
+``FysomGlobal`` class. Also a useful ``FysomGlobalMixin`` class to give
+convenience access for the state machine methods.
-A use case is using with Django, which has a cache mechanism holds
-lots of model objects (database records) in memory, using global machine
-can save a lot of memory, `here is a
-compare <https://github.com/pytransitions/transitions/issues/146#issuecomment-325190021>`_.
+A use case is using with Django, which has a cache mechanism holds lots of
+model objects (database records) in memory, using global machine can save a lot
+of memory, `here is a compare
+<https://github.com/pytransitions/transitions/issues/146#issuecomment-325190021>`_.
-The basic usage is same with Fysom, with slit difference and enhancement:
+The basic usage is same with Fysom, with slight differences and enhancements:
-- Initial state will only be automatically triggered for class derived
- from FysomGlobalMixin. Or you need to trigger manually.
+- Initial state will only be automatically triggered for class derived from
+ ``FysomGlobalMixin``. Or you need to trigger manually.
- The snake_case python naming conversion is supported.
- Conditions and conditional transitions are implemented.
-- When an event/transition is canceled, the event object will be
- attached to the raised fysom.Canceled exception. By doing this,
- additional information can be passed through the exception.
+- When an event/transition is canceled, the event object will be attached to
+ the raised ``fysom.Canceled`` exception. By doing this, additional
+ information can be passed through the exception.
Usage example:
-::
+
+.. code:: python
+ :number-lines:
class Model(FysomGlobalMixin, object):
GSM = FysomGlobal(
@@ -435,3 +468,4 @@ Usage example:
obj.panic()
obj.current # 'yellow'
obj.is_finished() # False
+
diff --git a/debian/changelog b/debian/changelog
index fdccd69..3ae4092 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+python-fysom (2.1.6+git20211026.2.e358619-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Mon, 19 Dec 2022 21:31:18 -0000
+
python-fysom (2.1.6-1) unstable; urgency=medium
* Switching to debhelper sequencer
diff --git a/fysom.egg-info/PKG-INFO b/fysom.egg-info/PKG-INFO
index 97ad4ba..5a20fa7 100644
--- a/fysom.egg-info/PKG-INFO
+++ b/fysom.egg-info/PKG-INFO
@@ -8,7 +8,6 @@ Author-email: mansour@oxplot.com, jake@codeincomplete.com, maximilien.riehl@gmai
Maintainer:
Maintainer-email:
License: MIT
-Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
@@ -17,5 +16,4 @@ Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
-UNKNOWN
-
+pYthOn Finite State Machine
diff --git a/fysom.egg-info/SOURCES.txt b/fysom.egg-info/SOURCES.txt
index 126a135..ee8ac5c 100644
--- a/fysom.egg-info/SOURCES.txt
+++ b/fysom.egg-info/SOURCES.txt
@@ -1,6 +1,7 @@
CHANGELOG
MANIFEST.in
README
+pyproject.toml
setup.cfg
setup.py
fysom/__init__.py
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..950f549
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["pybuilder>=0.12.0"]
+build-backend = "pybuilder.pep517"
diff --git a/setup.py b/setup.py
index fca5297..f48418b 100755
--- a/setup.py
+++ b/setup.py
@@ -23,7 +23,7 @@ if __name__ == '__main__':
name = 'fysom',
version = '2.1.6',
description = 'pYthOn Finite State Machine',
- long_description = '',
+ long_description = 'pYthOn Finite State Machine',
long_description_content_type = None,
classifiers = [
'Development Status :: 5 - Production/Stable',
diff --git a/test/test_initialization.py b/test/test_initialization.py
index 02b8dcd..29b8082 100644
--- a/test/test_initialization.py
+++ b/test/test_initialization.py
@@ -65,7 +65,7 @@ class FysomInitializationTests(unittest.TestCase):
{'name': 'calm', 'src': 'red', 'dst': 'green'},
]
})
- self.assertEquals(fsm.current, 'green')
+ self.assertEqual(fsm.current, 'green')
def test_deferred_initial_state_should_be_none_then_state(self):
fsm = Fysom({
diff --git a/test/test_many_to_many.py b/test/test_many_to_many.py
index 81ff586..b9b30ca 100644
--- a/test/test_many_to_many.py
+++ b/test/test_many_to_many.py
@@ -54,19 +54,19 @@ class FysomManyToManyTransitionTests(unittest.TestCase):
def test_rest_should_always_transition_to_hungry_state(self):
fsm = Fysom(self.fsm_descr)
fsm.rest()
- self.assertEquals(fsm.current, 'hungry')
+ self.assertEqual(fsm.current, 'hungry')
fsm = Fysom(self._get_descr('satisfied'))
fsm.rest()
- self.assertEquals(fsm.current, 'hungry')
+ self.assertEqual(fsm.current, 'hungry')
fsm = Fysom(self._get_descr('full'))
fsm.rest()
- self.assertEquals(fsm.current, 'hungry')
+ self.assertEqual(fsm.current, 'hungry')
fsm = Fysom(self._get_descr('sick'))
fsm.rest()
- self.assertEquals(fsm.current, 'hungry')
+ self.assertEqual(fsm.current, 'hungry')
def test_eat_should_transition_to_satisfied_when_hungry(self):
fsm = Fysom(self._get_descr('hungry'))
Debdiff
File lists identical (after any substitutions)
No differences were encountered in the control files