/usr/share/doc/python-automaton-doc/html/api.html is in python-automaton-doc 1.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>API — automaton documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/tweaks.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="automaton documentation" href="index.html" />
<link rel="next" title="Installation" href="installation.html" />
<link rel="prev" title="Features" href="features.html" />
</head>
<body role="document">
<div id="header">
<h1 id="logo"><a href="http://www.openstack.org/">OpenStack</a></h1>
<ul id="navigation">
<li><a href="http://www.openstack.org/" title="Go to the Home page" class="link">Home</a></li>
<li><a href="http://www.openstack.org/projects/" title="Go to the OpenStack Projects page">Projects</a></li>
<li><a href="http://www.openstack.org/user-stories/" title="Go to the User Stories page" class="link">User Stories</a></li>
<li><a href="http://www.openstack.org/community/" title="Go to the Community page" class="link">Community</a></li>
<li><a href="http://www.openstack.org/blog/" title="Go to the OpenStack Blog">Blog</a></li>
<li><a href="http://wiki.openstack.org/" title="Go to the OpenStack Wiki">Wiki</a></li>
<li><a href="http://docs.openstack.org/" title="Go to OpenStack Documentation" class="current">Documentation</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="api">
<h1>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h1>
<div class="section" id="machines">
<h2>Machines<a class="headerlink" href="#machines" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="automaton.machines.State">
<em class="property">class </em><code class="descclassname">automaton.machines.</code><code class="descname">State</code><span class="sig-paren">(</span><em>name</em>, <em>is_terminal=False</em>, <em>next_states=None</em>, <em>on_enter=None</em>, <em>on_exit=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#State"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.State" title="Permalink to this definition">¶</a></dt>
<dd><p>Container that defines needed components of a single state.</p>
<p>Usage of this and the <a class="reference internal" href="#automaton.machines.FiniteMachine.build" title="automaton.machines.FiniteMachine.build"><code class="xref py py-meth docutils literal"><span class="pre">build()</span></code></a> make creating finite
state machines that much easier.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Variables:</th><td class="field-body"><ul class="first last simple">
<li><strong>name</strong> – The name of the state.</li>
<li><strong>is_terminal</strong> – Whether this state is terminal (or not).</li>
<li><strong>next_states</strong> – Dictionary of ‘event’ -> ‘next state name’ (or none).</li>
<li><strong>on_enter</strong> – callback that will be called when the state is entered.</li>
<li><strong>on_exit</strong> – callback that will be called when the state is exited.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="automaton.machines.FiniteMachine">
<em class="property">class </em><code class="descclassname">automaton.machines.</code><code class="descname">FiniteMachine</code><span class="sig-paren">(</span><em>default_start_state=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine" title="Permalink to this definition">¶</a></dt>
<dd><p>A finite state machine.</p>
<p>This state machine can be used to automatically run a given set of
transitions and states in response to events (either from callbacks or from
generator/iterator send() values, see PEP 342). On each triggered event, a
<code class="docutils literal"><span class="pre">on_enter</span></code> and <code class="docutils literal"><span class="pre">on_exit</span></code> callback can also be provided which will be
called to perform some type of action on leaving a prior state and before
entering a new state.</p>
<p>NOTE(harlowja): reactions will <em>only</em> be called when the generator/iterator
from <a class="reference internal" href="#automaton.runners.Runner.run_iter" title="automaton.runners.Runner.run_iter"><code class="xref py py-meth docutils literal"><span class="pre">run_iter()</span></code></a> does <em>not</em> send
back a new event (they will always be called if the
<a class="reference internal" href="#automaton.runners.Runner.run" title="automaton.runners.Runner.run"><code class="xref py py-meth docutils literal"><span class="pre">run()</span></code></a> method is used). This allows
for two unique ways (these ways can also be intermixed) to use this state
machine when using <a class="reference internal" href="#automaton.runners.Runner.run" title="automaton.runners.Runner.run"><code class="xref py py-meth docutils literal"><span class="pre">run()</span></code></a>; one
where <em>external</em> event trigger the next state transition and one
where <em>internal</em> reaction callbacks trigger the next state
transition. The other way to use this
state machine is to skip using <a class="reference internal" href="#automaton.runners.Runner.run" title="automaton.runners.Runner.run"><code class="xref py py-meth docutils literal"><span class="pre">run()</span></code></a>
or <a class="reference internal" href="#automaton.runners.Runner.run_iter" title="automaton.runners.Runner.run_iter"><code class="xref py py-meth docutils literal"><span class="pre">run_iter()</span></code></a>
completely and use the <a class="reference internal" href="#automaton.machines.FiniteMachine.process_event" title="automaton.machines.FiniteMachine.process_event"><code class="xref py py-meth docutils literal"><span class="pre">process_event()</span></code></a> method
explicitly and trigger the events via
some <em>external</em> functionality/triggers...</p>
<dl class="class">
<dt id="automaton.machines.FiniteMachine.Effect">
<em class="property">class </em><code class="descname">Effect</code><span class="sig-paren">(</span><em>reaction</em>, <em>terminal</em><span class="sig-paren">)</span><a class="headerlink" href="#automaton.machines.FiniteMachine.Effect" title="Permalink to this definition">¶</a></dt>
<dd><p>The result of processing an event (cause and effect...)</p>
<dl class="attribute">
<dt id="automaton.machines.FiniteMachine.Effect.reaction">
<code class="descname">reaction</code><a class="headerlink" href="#automaton.machines.FiniteMachine.Effect.reaction" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for field number 0</p>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.FiniteMachine.Effect.terminal">
<code class="descname">terminal</code><a class="headerlink" href="#automaton.machines.FiniteMachine.Effect.terminal" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for field number 1</p>
</dd></dl>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.__contains__">
<code class="descclassname">FiniteMachine.</code><code class="descname">__contains__</code><span class="sig-paren">(</span><em>state</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.__contains__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.__contains__" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns if this state exists in the machines known states.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.__iter__">
<code class="descclassname">FiniteMachine.</code><code class="descname">__iter__</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.__iter__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.__iter__" title="Permalink to this definition">¶</a></dt>
<dd><p>Iterates over (start, event, end) transition tuples.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.add_reaction">
<code class="descclassname">FiniteMachine.</code><code class="descname">add_reaction</code><span class="sig-paren">(</span><em>state</em>, <em>event</em>, <em>reaction</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.add_reaction"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.add_reaction" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a reaction that may get triggered by the given event & state.</p>
<p>Reaction callbacks may (depending on how the state machine is ran) be
used after an event is processed (and a transition occurs) to cause the
machine to react to the newly arrived at stable state.</p>
<p>These callbacks are expected to accept three default positional
parameters (although more can be passed in via <em>args and **kwargs,
these will automatically get provided to the callback when it is
activated *ontop</em> of the three default). The three default parameters
are the last stable state, the new stable state and the event that
caused the transition to this new stable state to be arrived at.</p>
<p>The expected result of a callback is expected to be a new event that
the callback wants the state machine to react to. This new event
may (depending on how the state machine is ran) get processed (and
this process typically repeats) until the state machine reaches a
terminal state.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.add_state">
<code class="descclassname">FiniteMachine.</code><code class="descname">add_state</code><span class="sig-paren">(</span><em>state</em>, <em>terminal=False</em>, <em>on_enter=None</em>, <em>on_exit=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.add_state"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.add_state" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a given state to the state machine.</p>
<p>The <code class="docutils literal"><span class="pre">on_enter</span></code> and <code class="docutils literal"><span class="pre">on_exit</span></code> callbacks, if provided will be
expected to take two positional parameters, these being the state
being exited (for <code class="docutils literal"><span class="pre">on_exit</span></code>) or the state being entered (for
<code class="docutils literal"><span class="pre">on_enter</span></code>) and a second parameter which is the event that is
being processed that caused the state transition.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.add_transition">
<code class="descclassname">FiniteMachine.</code><code class="descname">add_transition</code><span class="sig-paren">(</span><em>start</em>, <em>end</em>, <em>event</em>, <em>replace=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.add_transition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.add_transition" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds an allowed transition from start -> end for the given event.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>start</strong> – starting state</li>
<li><strong>end</strong> – ending state</li>
<li><strong>event</strong> – event that causes start state to
transition to end state</li>
<li><strong>replace</strong> – replace existing event instead of raising a
<a class="reference internal" href="#automaton.exceptions.Duplicate" title="automaton.exceptions.Duplicate"><code class="xref py py-class docutils literal"><span class="pre">Duplicate</span></code></a> exception
when the transition already exists.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="classmethod">
<dt id="automaton.machines.FiniteMachine.build">
<em class="property">classmethod </em><code class="descclassname">FiniteMachine.</code><code class="descname">build</code><span class="sig-paren">(</span><em>state_space</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.build"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.build" title="Permalink to this definition">¶</a></dt>
<dd><p>Builds a machine from a state space listing.</p>
<p>Each element of this list must be an instance
of <a class="reference internal" href="#automaton.machines.State" title="automaton.machines.State"><code class="xref py py-class docutils literal"><span class="pre">State</span></code></a> or a <code class="docutils literal"><span class="pre">dict</span></code> with equivalent keys that
can be used to construct a <a class="reference internal" href="#automaton.machines.State" title="automaton.machines.State"><code class="xref py py-class docutils literal"><span class="pre">State</span></code></a> instance.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.copy">
<code class="descclassname">FiniteMachine.</code><code class="descname">copy</code><span class="sig-paren">(</span><em>shallow=False</em>, <em>unfreeze=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.copy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Copies the current state machine.</p>
<p>NOTE(harlowja): the copy will be left in an <em>uninitialized</em> state.</p>
<dl class="docutils">
<dt>NOTE(harlowja): when a shallow copy is requested the copy will share</dt>
<dd>the same transition table and state table as the
source; this can be advantageous if you have a machine
and transitions + states that is defined somewhere
and want to use copies to run with (the copies have
the current state that is different between machines).</dd>
</dl>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.FiniteMachine.current_state">
<code class="descclassname">FiniteMachine.</code><code class="descname">current_state</code><a class="headerlink" href="#automaton.machines.FiniteMachine.current_state" title="Permalink to this definition">¶</a></dt>
<dd><p>The current state the machine is in (or none if not initialized).</p>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.FiniteMachine.default_start_state">
<code class="descclassname">FiniteMachine.</code><code class="descname">default_start_state</code><a class="headerlink" href="#automaton.machines.FiniteMachine.default_start_state" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the <em>default</em> start state that the machine should use.</p>
<p>NOTE(harlowja): this will be used by <code class="docutils literal"><span class="pre">initialize</span></code> but only if that
function is not given its own <code class="docutils literal"><span class="pre">start_state</span></code> that overrides this
default.</p>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.FiniteMachine.events">
<code class="descclassname">FiniteMachine.</code><code class="descname">events</code><a class="headerlink" href="#automaton.machines.FiniteMachine.events" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns how many events exist.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.freeze">
<code class="descclassname">FiniteMachine.</code><code class="descname">freeze</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.freeze"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.freeze" title="Permalink to this definition">¶</a></dt>
<dd><p>Freezes & stops addition of states, transitions, reactions...</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.initialize">
<code class="descclassname">FiniteMachine.</code><code class="descname">initialize</code><span class="sig-paren">(</span><em>start_state=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.initialize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.initialize" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets up the state machine (sets current state to start state...).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>start_state</strong> – explicit start state to use to initialize the
state machine to. If <code class="docutils literal"><span class="pre">None</span></code> is provided then
the machine’s default start state will be used
instead.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.is_actionable_event">
<code class="descclassname">FiniteMachine.</code><code class="descname">is_actionable_event</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.is_actionable_event"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.is_actionable_event" title="Permalink to this definition">¶</a></dt>
<dd><p>Check whether the event is actionable in the current state.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.pformat">
<code class="descclassname">FiniteMachine.</code><code class="descname">pformat</code><span class="sig-paren">(</span><em>sort=True</em>, <em>empty='.'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.pformat"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.pformat" title="Permalink to this definition">¶</a></dt>
<dd><p>Pretty formats the state + transition table into a string.</p>
<p>NOTE(harlowja): the sort parameter can be provided to sort the states
and transitions by sort order; with it being provided as false the rows
will be iterated in addition order instead.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.FiniteMachine.process_event">
<code class="descclassname">FiniteMachine.</code><code class="descname">process_event</code><span class="sig-paren">(</span><em>event</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#FiniteMachine.process_event"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.FiniteMachine.process_event" title="Permalink to this definition">¶</a></dt>
<dd><p>Trigger a state change in response to the provided event.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Effect this is either a <a class="reference internal" href="#automaton.machines.FiniteMachine.Effect" title="automaton.machines.FiniteMachine.Effect"><code class="xref py py-class docutils literal"><span class="pre">FiniteMachine.Effect</span></code></a> or
an <code class="docutils literal"><span class="pre">Effect</span></code> from a subclass of <a class="reference internal" href="#automaton.machines.FiniteMachine" title="automaton.machines.FiniteMachine"><code class="xref py py-class docutils literal"><span class="pre">FiniteMachine</span></code></a>.
See the appropriate named tuple for a description of the
actual items in the tuple. For
example, <a class="reference internal" href="#automaton.machines.FiniteMachine.Effect" title="automaton.machines.FiniteMachine.Effect"><code class="xref py py-class docutils literal"><span class="pre">FiniteMachine.Effect</span></code></a>‘s
first item is <code class="docutils literal"><span class="pre">reaction</span></code>: one could invoke this reaction’s
callback to react to the new stable state.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">namedtuple</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.FiniteMachine.states">
<code class="descclassname">FiniteMachine.</code><code class="descname">states</code><a class="headerlink" href="#automaton.machines.FiniteMachine.states" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the state names.</p>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.FiniteMachine.terminated">
<code class="descclassname">FiniteMachine.</code><code class="descname">terminated</code><a class="headerlink" href="#automaton.machines.FiniteMachine.terminated" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns whether the state machine is in a terminal state.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="automaton.machines.HierarchicalFiniteMachine">
<em class="property">class </em><code class="descclassname">automaton.machines.</code><code class="descname">HierarchicalFiniteMachine</code><span class="sig-paren">(</span><em>default_start_state=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#HierarchicalFiniteMachine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.HierarchicalFiniteMachine" title="Permalink to this definition">¶</a></dt>
<dd><p>A fsm that understands how to run in a hierarchical mode.</p>
<dl class="class">
<dt id="automaton.machines.HierarchicalFiniteMachine.Effect">
<em class="property">class </em><code class="descname">Effect</code><span class="sig-paren">(</span><em>reaction</em>, <em>terminal</em>, <em>machine</em><span class="sig-paren">)</span><a class="headerlink" href="#automaton.machines.HierarchicalFiniteMachine.Effect" title="Permalink to this definition">¶</a></dt>
<dd><p>The result of processing an event (cause and effect...)</p>
<dl class="attribute">
<dt id="automaton.machines.HierarchicalFiniteMachine.Effect.machine">
<code class="descname">machine</code><a class="headerlink" href="#automaton.machines.HierarchicalFiniteMachine.Effect.machine" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for field number 2</p>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.HierarchicalFiniteMachine.Effect.reaction">
<code class="descname">reaction</code><a class="headerlink" href="#automaton.machines.HierarchicalFiniteMachine.Effect.reaction" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for field number 0</p>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.HierarchicalFiniteMachine.Effect.terminal">
<code class="descname">terminal</code><a class="headerlink" href="#automaton.machines.HierarchicalFiniteMachine.Effect.terminal" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for field number 1</p>
</dd></dl>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.HierarchicalFiniteMachine.add_state">
<code class="descclassname">HierarchicalFiniteMachine.</code><code class="descname">add_state</code><span class="sig-paren">(</span><em>state</em>, <em>terminal=False</em>, <em>on_enter=None</em>, <em>on_exit=None</em>, <em>machine=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#HierarchicalFiniteMachine.add_state"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.HierarchicalFiniteMachine.add_state" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a given state to the state machine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>machine</strong> (<a class="reference internal" href="#automaton.machines.FiniteMachine" title="automaton.machines.FiniteMachine"><code class="xref py py-class docutils literal"><span class="pre">FiniteMachine</span></code></a>) – the nested state machine that will be transitioned
into when this state is entered</td>
</tr>
</tbody>
</table>
<p>Further arguments are interpreted as
for <a class="reference internal" href="#automaton.machines.FiniteMachine.add_state" title="automaton.machines.FiniteMachine.add_state"><code class="xref py py-meth docutils literal"><span class="pre">FiniteMachine.add_state()</span></code></a>.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.machines.HierarchicalFiniteMachine.initialize">
<code class="descclassname">HierarchicalFiniteMachine.</code><code class="descname">initialize</code><span class="sig-paren">(</span><em>start_state=None</em>, <em>nested_start_state_fetcher=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/machines.html#HierarchicalFiniteMachine.initialize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.machines.HierarchicalFiniteMachine.initialize" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets up the state machine (sets current state to start state...).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>start_state</strong> – explicit start state to use to initialize the
state machine to. If <code class="docutils literal"><span class="pre">None</span></code> is provided then the
machine’s default start state will be used
instead.</li>
<li><strong>nested_start_state_fetcher</strong> – A callback that can return start
states for any nested machines
<strong>only</strong>. If not <code class="docutils literal"><span class="pre">None</span></code> then it
will be provided a single argument,
the machine to provide a starting
state for and it is expected to
return a starting state (or
<code class="docutils literal"><span class="pre">None</span></code>) for each machine called
with. Do note that this callback
will also be passed to other nested
state machines as well, so it will
also be used to initialize any state
machines they contain (recursively).</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="automaton.machines.HierarchicalFiniteMachine.nested_machines">
<code class="descclassname">HierarchicalFiniteMachine.</code><code class="descname">nested_machines</code><a class="headerlink" href="#automaton.machines.HierarchicalFiniteMachine.nested_machines" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary of <strong>all</strong> nested state machines this machine may use.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="runners">
<h2>Runners<a class="headerlink" href="#runners" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="automaton.runners.Runner">
<em class="property">class </em><code class="descclassname">automaton.runners.</code><code class="descname">Runner</code><span class="sig-paren">(</span><em>machine</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/runners.html#Runner"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.runners.Runner" title="Permalink to this definition">¶</a></dt>
<dd><p>Machine runner used to run a state machine.</p>
<p>Only <strong>one</strong> runner per machine should be active at the same time (aka
there should not be multiple runners using the same machine instance at
the same time).</p>
<dl class="method">
<dt id="automaton.runners.Runner.run">
<code class="descname">run</code><span class="sig-paren">(</span><em>event</em>, <em>initialize=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/runners.html#Runner.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.runners.Runner.run" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs the state machine, using reactions only.</p>
</dd></dl>
<dl class="method">
<dt id="automaton.runners.Runner.run_iter">
<code class="descname">run_iter</code><span class="sig-paren">(</span><em>event</em>, <em>initialize=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/runners.html#Runner.run_iter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.runners.Runner.run_iter" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a iterator/generator that will run the state machine.</p>
<p>NOTE(harlowja): only one runner iterator/generator should be active for
a machine, if this is not observed then it is possible for
initialization and other local state to be corrupted and cause issues
when running...</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="automaton.runners.FiniteRunner">
<em class="property">class </em><code class="descclassname">automaton.runners.</code><code class="descname">FiniteRunner</code><span class="sig-paren">(</span><em>machine</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/runners.html#FiniteRunner"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.runners.FiniteRunner" title="Permalink to this definition">¶</a></dt>
<dd><p>Finite machine runner used to run a finite machine.</p>
<p>Only <strong>one</strong> runner per machine should be active at the same time (aka
there should not be multiple runners using the same machine instance at
the same time).</p>
</dd></dl>
<dl class="class">
<dt id="automaton.runners.HierarchicalRunner">
<em class="property">class </em><code class="descclassname">automaton.runners.</code><code class="descname">HierarchicalRunner</code><span class="sig-paren">(</span><em>machine</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/runners.html#HierarchicalRunner"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.runners.HierarchicalRunner" title="Permalink to this definition">¶</a></dt>
<dd><p>Hierarchical machine runner used to run a hierarchical machine.</p>
<p>Only <strong>one</strong> runner per machine should be active at the same time (aka
there should not be multiple runners using the same machine instance at
the same time).</p>
<dl class="method">
<dt id="automaton.runners.HierarchicalRunner.run_iter">
<code class="descname">run_iter</code><span class="sig-paren">(</span><em>event</em>, <em>initialize=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/runners.html#HierarchicalRunner.run_iter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.runners.HierarchicalRunner.run_iter" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a iterator/generator that will run the state machine.</p>
<p>This will keep a stack (hierarchy) of machines active and jumps through
them as needed (depending on which machine handles which event) during
the running lifecycle.</p>
<p>NOTE(harlowja): only one runner iterator/generator should be active for
a machine hierarchy, if this is not observed then it is possible for
initialization and other local state to be corrupted and causes issues
when running...</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-automaton.converters.pydot">
<span id="converters"></span><h2>Converters<a class="headerlink" href="#module-automaton.converters.pydot" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="automaton.converters.pydot.convert">
<code class="descclassname">automaton.converters.pydot.</code><code class="descname">convert</code><span class="sig-paren">(</span><em>machine</em>, <em>graph_name</em>, <em>graph_attrs=None</em>, <em>node_attrs_cb=None</em>, <em>edge_attrs_cb=None</em>, <em>add_start_state=True</em>, <em>name_translations=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/automaton/converters/pydot.html#convert"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.converters.pydot.convert" title="Permalink to this definition">¶</a></dt>
<dd><p>Translates the state machine into a pydot graph.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>machine</strong> (<a class="reference internal" href="#automaton.machines.FiniteMachine" title="automaton.machines.FiniteMachine"><em>FiniteMachine</em></a>) – state machine to convert</li>
<li><strong>graph_name</strong> (<em>string</em>) – name of the graph to be created</li>
<li><strong>graph_attrs</strong> (<em>dict</em>) – any initial graph attributes to set
(see <a class="reference external" href="http://www.graphviz.org/doc/info/attrs.html">http://www.graphviz.org/doc/info/attrs.html</a> for
what these can be)</li>
<li><strong>node_attrs_cb</strong> (<em>callback</em>) – a callback that takes one argument <code class="docutils literal"><span class="pre">state</span></code>
and is expected to return a dict of node attributes
(see <a class="reference external" href="http://www.graphviz.org/doc/info/attrs.html">http://www.graphviz.org/doc/info/attrs.html</a> for
what these can be)</li>
<li><strong>edge_attrs_cb</strong> (<em>callback</em>) – a callback that takes three arguments <code class="docutils literal"><span class="pre">start_state,</span>
<span class="pre">event,</span> <span class="pre">end_state</span></code> and is expected to return a dict
of edge attributes (see
<a class="reference external" href="http://www.graphviz.org/doc/info/attrs.html">http://www.graphviz.org/doc/info/attrs.html</a> for
what these can be)</li>
<li><strong>add_start_state</strong> (<em>bool</em>) – when enabled this creates a <em>private</em> start state
with the name <code class="docutils literal"><span class="pre">__start__</span></code> that will be a point
node that will have a dotted edge to the
<code class="docutils literal"><span class="pre">default_start_state</span></code> that your machine may have
defined (if your machine has no actively defined
<code class="docutils literal"><span class="pre">default_start_state</span></code> then this does nothing,
even if enabled)</li>
<li><strong>name_translations</strong> (<em>dict</em>) – a dict that provides alternative <code class="docutils literal"><span class="pre">state</span></code>
string names for each state</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-automaton.exceptions">
<span id="exceptions"></span><h2>Exceptions<a class="headerlink" href="#module-automaton.exceptions" title="Permalink to this headline">¶</a></h2>
<dl class="exception">
<dt id="automaton.exceptions.AutomatonException">
<em class="property">exception </em><code class="descclassname">automaton.exceptions.</code><code class="descname">AutomatonException</code><a class="reference internal" href="_modules/automaton/exceptions.html#AutomatonException"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.exceptions.AutomatonException" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class for <em>most</em> exceptions emitted from this library.</p>
</dd></dl>
<dl class="exception">
<dt id="automaton.exceptions.Duplicate">
<em class="property">exception </em><code class="descclassname">automaton.exceptions.</code><code class="descname">Duplicate</code><a class="reference internal" href="_modules/automaton/exceptions.html#Duplicate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.exceptions.Duplicate" title="Permalink to this definition">¶</a></dt>
<dd><p>Raised when a duplicate entry is found.</p>
</dd></dl>
<dl class="exception">
<dt id="automaton.exceptions.FrozenMachine">
<em class="property">exception </em><code class="descclassname">automaton.exceptions.</code><code class="descname">FrozenMachine</code><a class="reference internal" href="_modules/automaton/exceptions.html#FrozenMachine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.exceptions.FrozenMachine" title="Permalink to this definition">¶</a></dt>
<dd><p>Exception raised when a frozen machine is modified.</p>
</dd></dl>
<dl class="exception">
<dt id="automaton.exceptions.InvalidState">
<em class="property">exception </em><code class="descclassname">automaton.exceptions.</code><code class="descname">InvalidState</code><a class="reference internal" href="_modules/automaton/exceptions.html#InvalidState"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.exceptions.InvalidState" title="Permalink to this definition">¶</a></dt>
<dd><p>Raised when a invalid state transition is attempted while executing.</p>
</dd></dl>
<dl class="exception">
<dt id="automaton.exceptions.NotFound">
<em class="property">exception </em><code class="descclassname">automaton.exceptions.</code><code class="descname">NotFound</code><a class="reference internal" href="_modules/automaton/exceptions.html#NotFound"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.exceptions.NotFound" title="Permalink to this definition">¶</a></dt>
<dd><p>Raised when some entry in some object doesn’t exist.</p>
</dd></dl>
<dl class="exception">
<dt id="automaton.exceptions.NotInitialized">
<em class="property">exception </em><code class="descclassname">automaton.exceptions.</code><code class="descname">NotInitialized</code><a class="reference internal" href="_modules/automaton/exceptions.html#NotInitialized"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#automaton.exceptions.NotInitialized" title="Permalink to this definition">¶</a></dt>
<dd><p>Error raised when an action is attempted on a not inited machine.</p>
</dd></dl>
<div class="section" id="hierarchy">
<h3>Hierarchy<a class="headerlink" href="#hierarchy" title="Permalink to this headline">¶</a></h3>
<p class="graphviz">
digraph inheritance348b908e00 {
rankdir=LR;
size="8.0, 12.0";
"AutomatonException" [URL="#automaton.exceptions.AutomatonException",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Base class for *most* exceptions emitted from this library."];
"Duplicate" [URL="#automaton.exceptions.Duplicate",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Raised when a duplicate entry is found."];
"AutomatonException" -> "Duplicate" [arrowsize=0.5,style="setlinewidth(0.5)"];
"FrozenMachine" [URL="#automaton.exceptions.FrozenMachine",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Exception raised when a frozen machine is modified."];
"AutomatonException" -> "FrozenMachine" [arrowsize=0.5,style="setlinewidth(0.5)"];
"InvalidState" [URL="#automaton.exceptions.InvalidState",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Raised when a invalid state transition is attempted while executing."];
"AutomatonException" -> "InvalidState" [arrowsize=0.5,style="setlinewidth(0.5)"];
"NotFound" [URL="#automaton.exceptions.NotFound",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Raised when some entry in some object doesn't exist."];
"AutomatonException" -> "NotFound" [arrowsize=0.5,style="setlinewidth(0.5)"];
"NotInitialized" [URL="#automaton.exceptions.NotInitialized",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Error raised when an action is attempted on a not inited machine."];
"AutomatonException" -> "NotInitialized" [arrowsize=0.5,style="setlinewidth(0.5)"];
}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">API</a><ul>
<li><a class="reference internal" href="#machines">Machines</a></li>
<li><a class="reference internal" href="#runners">Runners</a></li>
<li><a class="reference internal" href="#module-automaton.converters.pydot">Converters</a></li>
<li><a class="reference internal" href="#module-automaton.exceptions">Exceptions</a><ul>
<li><a class="reference internal" href="#hierarchy">Hierarchy</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="features.html"
title="previous chapter">Features</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="installation.html"
title="next chapter">Installation</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/api.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="installation.html" title="Installation"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="features.html" title="Features"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">automaton documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2013, OpenStack Foundation.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.6.
</div>
<script type="text/javascript">
try {
//Tracking docs.openstack.org/developer/<projectname> only
//The URL is built from the project variable in conf.py
var pageTracker = _gat._getTracker("UA-17511903-1");
pageTracker._setCookiePath("/developer/automaton");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
|