Ravenports generated: 11 Mar 2023 18:07
[ravenports.git] / bucket_CD / python-transitions
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               python-transitions
4 VERSION=                0.9.0
5 KEYWORDS=               python
6 VARIANTS=               py310 v11
7 SDESC[py310]=           Extensible state machine implementation (3.10)
8 SDESC[v11]=             Extensible state machine implementation (3.11)
9 HOMEPAGE=               https://github.com/pytransitions/transitions
10 CONTACT=                Python_Automaton[python@ironwolf.systems]
11
12 DOWNLOAD_GROUPS=        main
13 SITES[main]=            PYPIWHL/ee/35/77e8f975da682e14e1581ae0f47f4e3beed29871794f26ce7c9d4dd32b14
14 DISTFILE[1]=            transitions-0.9.0-py2.py3-none-any.whl:main
15 DF_INDEX=               1
16 SPKGS[py310]=           single
17 SPKGS[v11]=             single
18
19 OPTIONS_AVAILABLE=      PY310 PY311
20 OPTIONS_STANDARD=       none
21 VOPTS[py310]=           PY310=ON PY311=OFF
22 VOPTS[v11]=             PY310=OFF PY311=ON
23
24 DISTNAME=               transitions-0.9.0.dist-info
25
26 GENERATED=              yes
27
28 [PY310].RUN_DEPENDS_ON=                 python-six:single:py310
29 [PY310].USES_ON=                        python:py310,wheel
30
31 [PY311].RUN_DEPENDS_ON=                 python-six:single:v11
32 [PY311].USES_ON=                        python:v11,wheel
33
34 [FILE:3186:descriptions/desc.single]
35 ## Quickstart
36
37 They say [a good example is worth] 100 pages of API documentation, a
38 million directives, or a thousand words.
39
40 Well, "they" probably lie... but here's an example anyway:
41
42 ```python
43 from transitions import Machine
44 import random
45
46 class NarcolepticSuperhero(object):
47
48     # Define some states. Most of the time, narcoleptic superheroes are
49 just like
50     # everyone else. Except for...
51     states = ['asleep', 'hanging out', 'hungry', 'sweaty', 'saving the
52 world']
53
54     def __init__(self, name):
55
56         # No anonymous superheroes on my watch! Every narcoleptic superhero
57 gets
58         # a name. Any name at all. SleepyMan. SlumberGirl. You get the
59 idea.
60         self.name = name
61
62         # What have we accomplished today?
63         self.kittens_rescued = 0
64
65         # Initialize the state machine
66         self.machine = Machine(model=self,
67 states=NarcolepticSuperhero.states, initial='asleep')
68
69         # Add some transitions. We could also define these using a static
70 list of
71         # dictionaries, as we did with states above, and then pass the list
72 to
73         # the Machine initializer as the transitions= argument.
74
75         # At some point, every superhero must rise and shine.
76         self.machine.add_transition(trigger='wake_up', source='asleep',
77 dest='hanging out')
78
79         # Superheroes need to keep in shape.
80         self.machine.add_transition('work_out', 'hanging out', 'hungry')
81
82         # Those calories won't replenish themselves!
83         self.machine.add_transition('eat', 'hungry', 'hanging out')
84
85         # Superheroes are always on call. ALWAYS. But they're not always
86         # dressed in work-appropriate clothing.
87         self.machine.add_transition('distress_call', '*', 'saving the
88 world',
89                          before='change_into_super_secret_costume')
90
91         # When they get off work, they're all sweaty and disgusting. But
92 before
93         # they do anything else, they have to meticulously log their latest
94         # escapades. Because the legal department says so.
95         self.machine.add_transition('complete_mission', 'saving the world',
96 'sweaty',
97                          after='update_journal')
98
99         # Sweat is a disorder that can be remedied with water.
100         # Unless you've had a particularly long day, in which case... bed
101 time!
102         self.machine.add_transition('clean_up', 'sweaty', 'asleep',
103 conditions=['is_exhausted'])
104         self.machine.add_transition('clean_up', 'sweaty', 'hanging out')
105
106         # Our NarcolepticSuperhero can fall asleep at pretty much any time.
107         self.machine.add_transition('nap', '*', 'asleep')
108
109     def update_journal(self):
110         """ Dear Diary, today I saved Mr. Whiskers. Again. """
111         self.kittens_rescued += 1
112
113     @property
114     def is_exhausted(self):
115         """ Basically a coin toss. """
116         return random.random() < 0.5
117
118     def change_into_super_secret_costume(self):
119         print("Beauty, eh?")
120 ```
121
122 There, now you've baked a state machine into `NarcolepticSuperhero`. Let's
123 take him/her/it out for a spin...
124
125 ```python
126 >>> batman = NarcolepticSuperhero("Batman")
127 >>> batman.state
128 'asleep'
129
130 >>> batman.wake_up()
131 >>> batman.state
132 'hanging out'
133
134 >>> batman.nap()
135
136
137 [FILE:117:distinfo]
138 5687ee8c6a3200830e44f988d16b0045f53293f7a873002d7bff70852331a078        97706 transitions-0.9.0-py2.py3-none-any.whl
139