python-statemachine 2.3.6__py3-none-any.whl → 2.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_statemachine-2.3.6.dist-info → python_statemachine-2.4.0.dist-info}/METADATA +9 -9
- python_statemachine-2.4.0.dist-info/RECORD +35 -0
- statemachine/__init__.py +3 -2
- statemachine/callbacks.py +62 -10
- statemachine/contrib/diagram.py +0 -4
- statemachine/dispatcher.py +5 -3
- statemachine/event.py +105 -27
- statemachine/event_data.py +2 -1
- statemachine/events.py +15 -6
- statemachine/exceptions.py +3 -2
- statemachine/factory.py +47 -12
- statemachine/locale/en/LC_MESSAGES/statemachine.po +27 -15
- statemachine/locale/hi_IN/LC_MESSAGES/statemachine.po +93 -0
- statemachine/locale/pt_BR/LC_MESSAGES/statemachine.po +36 -34
- statemachine/locale/zh_CN/LC_MESSAGES/statemachine.po +93 -0
- statemachine/spec_parser.py +79 -0
- statemachine/state.py +7 -0
- statemachine/statemachine.py +10 -19
- statemachine/states.py +2 -2
- statemachine/transition.py +1 -2
- statemachine/transition_list.py +5 -1
- python_statemachine-2.3.6.dist-info/RECORD +0 -32
- {python_statemachine-2.3.6.dist-info → python_statemachine-2.4.0.dist-info}/LICENSE +0 -0
- {python_statemachine-2.3.6.dist-info → python_statemachine-2.4.0.dist-info}/WHEEL +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
msgid ""
|
|
5
5
|
msgstr ""
|
|
6
|
-
"Project-Id-Version: 2.
|
|
6
|
+
"Project-Id-Version: 2.4.0\n"
|
|
7
7
|
"Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
|
|
8
8
|
"POT-Creation-Date: 2023-03-04 16:10-0300\n"
|
|
9
9
|
"PO-Revision-Date: 2024-06-07 17:41-0300\n"
|
|
@@ -13,68 +13,80 @@ msgstr ""
|
|
|
13
13
|
"Content-Transfer-Encoding: 8bit\n"
|
|
14
14
|
"Generated-By: Babel 2.12.1\n"
|
|
15
15
|
|
|
16
|
-
#: statemachine/callbacks.py:
|
|
16
|
+
#: statemachine/callbacks.py:165
|
|
17
|
+
msgid "Failed to parse boolean expression '{}'"
|
|
18
|
+
msgstr ""
|
|
19
|
+
|
|
20
|
+
#: statemachine/callbacks.py:407 statemachine/callbacks.py:412
|
|
17
21
|
msgid "Did not found name '{}' from model or statemachine"
|
|
18
22
|
msgstr ""
|
|
19
23
|
|
|
20
|
-
#: statemachine/exceptions.py:
|
|
24
|
+
#: statemachine/exceptions.py:24
|
|
21
25
|
msgid "{!r} is not a valid state value."
|
|
22
26
|
msgstr ""
|
|
23
27
|
|
|
24
|
-
#: statemachine/exceptions.py:
|
|
28
|
+
#: statemachine/exceptions.py:38
|
|
25
29
|
msgid "Can't {} when in {}."
|
|
26
30
|
msgstr ""
|
|
27
31
|
|
|
28
|
-
#: statemachine/factory.py:
|
|
32
|
+
#: statemachine/factory.py:74
|
|
29
33
|
msgid "There are no states."
|
|
30
34
|
msgstr ""
|
|
31
35
|
|
|
32
|
-
#: statemachine/factory.py:
|
|
36
|
+
#: statemachine/factory.py:77
|
|
33
37
|
msgid "There are no events."
|
|
34
38
|
msgstr ""
|
|
35
39
|
|
|
36
|
-
#: statemachine/factory.py:
|
|
40
|
+
#: statemachine/factory.py:89
|
|
37
41
|
msgid ""
|
|
38
42
|
"There should be one and only one initial state. You currently have these:"
|
|
39
43
|
" {!r}"
|
|
40
44
|
msgstr ""
|
|
41
45
|
|
|
42
|
-
#: statemachine/factory.py:
|
|
46
|
+
#: statemachine/factory.py:102
|
|
43
47
|
msgid "Cannot declare transitions from final state. Invalid state(s): {}"
|
|
44
48
|
msgstr ""
|
|
45
49
|
|
|
46
|
-
#: statemachine/factory.py:
|
|
50
|
+
#: statemachine/factory.py:110
|
|
47
51
|
msgid ""
|
|
48
52
|
"All non-final states should have at least one outgoing transition. These "
|
|
49
53
|
"states have no outgoing transition: {!r}"
|
|
50
54
|
msgstr ""
|
|
51
55
|
|
|
52
|
-
#: statemachine/factory.py:
|
|
56
|
+
#: statemachine/factory.py:124
|
|
53
57
|
msgid ""
|
|
54
58
|
"All non-final states should have at least one path to a final state. "
|
|
55
59
|
"These states have no path to a final state: {!r}"
|
|
56
60
|
msgstr ""
|
|
57
61
|
|
|
58
|
-
#: statemachine/factory.py:
|
|
62
|
+
#: statemachine/factory.py:148
|
|
59
63
|
msgid ""
|
|
60
64
|
"There are unreachable states. The statemachine graph should have a single"
|
|
61
65
|
" component. Disconnected states: {}"
|
|
62
66
|
msgstr ""
|
|
63
67
|
|
|
64
|
-
#: statemachine/
|
|
68
|
+
#: statemachine/factory.py:257
|
|
69
|
+
msgid "An event in the '{}' has no id."
|
|
70
|
+
msgstr ""
|
|
71
|
+
|
|
72
|
+
#: statemachine/mixins.py:26
|
|
65
73
|
msgid "{!r} is not a valid state machine name."
|
|
66
74
|
msgstr ""
|
|
67
75
|
|
|
68
|
-
#: statemachine/state.py:
|
|
76
|
+
#: statemachine/state.py:155
|
|
69
77
|
msgid "State overriding is not allowed. Trying to add '{}' to {}"
|
|
70
78
|
msgstr ""
|
|
71
79
|
|
|
72
|
-
#: statemachine/statemachine.py:
|
|
80
|
+
#: statemachine/statemachine.py:94
|
|
73
81
|
msgid "There are no states or transitions."
|
|
74
82
|
msgstr ""
|
|
75
83
|
|
|
76
|
-
#: statemachine/statemachine.py:
|
|
84
|
+
#: statemachine/statemachine.py:285
|
|
77
85
|
msgid ""
|
|
78
86
|
"There's no current state set. In async code, did you activate the initial"
|
|
79
87
|
" state? (e.g., `await sm.activate_initial_state()`)"
|
|
80
88
|
msgstr ""
|
|
89
|
+
|
|
90
|
+
#: statemachine/engines/async_.py:22
|
|
91
|
+
msgid "Only RTC is supported on async engine"
|
|
92
|
+
msgstr ""
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# This file is distributed under the same license as the project.
|
|
2
|
+
# Fernando Macedo <fgmacedo@gmail.com>, 2024.
|
|
3
|
+
#
|
|
4
|
+
msgid ""
|
|
5
|
+
msgstr ""
|
|
6
|
+
"Project-Id-Version: 2.4.0\n"
|
|
7
|
+
"Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
|
|
8
|
+
"POT-Creation-Date: 2023-03-04 16:10-0300\n"
|
|
9
|
+
"PO-Revision-Date: 2024-06-07 17:41-0300\n"
|
|
10
|
+
"Last-Translator: Fernando Macedo <fgmacedo@gmail.com>\n"
|
|
11
|
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
12
|
+
"MIME-Version: 1.0\n"
|
|
13
|
+
"Content-Type: text/plain; charset=utf-8\n"
|
|
14
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
15
|
+
"Generated-By: Babel 2.14.0\n"
|
|
16
|
+
|
|
17
|
+
#: statemachine/callbacks.py:165
|
|
18
|
+
msgid "Failed to parse boolean expression '{}'"
|
|
19
|
+
msgstr "बूलियन अभिव्यक्ति '{}' को पार्स करने में विफल रहा"
|
|
20
|
+
|
|
21
|
+
#: statemachine/callbacks.py:407 statemachine/callbacks.py:412
|
|
22
|
+
msgid "Did not found name '{}' from model or statemachine"
|
|
23
|
+
msgstr "मॉडल या स्टेटमशीन में नाम '{}' नहीं मिला"
|
|
24
|
+
|
|
25
|
+
#: statemachine/exceptions.py:24
|
|
26
|
+
msgid "{!r} is not a valid state value."
|
|
27
|
+
msgstr "{!r} एक मान्य स्टेट मान नहीं है।"
|
|
28
|
+
|
|
29
|
+
#: statemachine/exceptions.py:38
|
|
30
|
+
msgid "Can't {} when in {}."
|
|
31
|
+
msgstr "{} स्थिति में {} नहीं कर सकते।"
|
|
32
|
+
|
|
33
|
+
#: statemachine/factory.py:74
|
|
34
|
+
msgid "There are no states."
|
|
35
|
+
msgstr "कोई स्टेट नहीं है।"
|
|
36
|
+
|
|
37
|
+
#: statemachine/factory.py:77
|
|
38
|
+
msgid "There are no events."
|
|
39
|
+
msgstr "कोई इवेंट नहीं है।"
|
|
40
|
+
|
|
41
|
+
#: statemachine/factory.py:89
|
|
42
|
+
msgid ""
|
|
43
|
+
"There should be one and only one initial state. You currently have these:"
|
|
44
|
+
" {!r}"
|
|
45
|
+
msgstr "एक और केवल एक प्रारंभिक स्टेट होना चाहिए। वर्तमान में आपके पास ये हैं: {!r}"
|
|
46
|
+
|
|
47
|
+
#: statemachine/factory.py:102
|
|
48
|
+
msgid "Cannot declare transitions from final state. Invalid state(s): {}"
|
|
49
|
+
msgstr "अंतिम स्टेट से ट्रांज़िशन घोषित नहीं कर सकते। अमान्य स्टेट: {}"
|
|
50
|
+
|
|
51
|
+
#: statemachine/factory.py:110
|
|
52
|
+
msgid ""
|
|
53
|
+
"All non-final states should have at least one outgoing transition. These "
|
|
54
|
+
"states have no outgoing transition: {!r}"
|
|
55
|
+
msgstr "सभी गैर-अंतिम स्टेट में कम से कम एक आउटगोइंग ट्रांज़िशन होना चाहिए। इन स्टेट में कोई आउटगोइंग ट्रांज़िशन नहीं है: {!r}"
|
|
56
|
+
|
|
57
|
+
#: statemachine/factory.py:124
|
|
58
|
+
msgid ""
|
|
59
|
+
"All non-final states should have at least one path to a final state. "
|
|
60
|
+
"These states have no path to a final state: {!r}"
|
|
61
|
+
msgstr "सभी गैर-अंतिम स्टेट में अंतिम स्टेट तक कम से कम एक पथ होना चाहिए। इन स्टेट में अंतिम स्टेट तक कोई पथ नहीं है: {!r}"
|
|
62
|
+
|
|
63
|
+
#: statemachine/factory.py:148
|
|
64
|
+
msgid ""
|
|
65
|
+
"There are unreachable states. The statemachine graph should have a single"
|
|
66
|
+
" component. Disconnected states: {}"
|
|
67
|
+
msgstr "कुछ स्टेट पहुंच योग्य नहीं हैं। स्टेटमशीन ग्राफ में एक ही घटक होना चाहिए। डिस्कनेक्टेड स्टेट: {}"
|
|
68
|
+
|
|
69
|
+
#: statemachine/factory.py:257
|
|
70
|
+
msgid "An event in the '{}' has no id."
|
|
71
|
+
msgstr "'{}' में एक इवेंट का आईडी नहीं है।"
|
|
72
|
+
|
|
73
|
+
#: statemachine/mixins.py:26
|
|
74
|
+
msgid "{!r} is not a valid state machine name."
|
|
75
|
+
msgstr "{!r} एक मान्य स्टेटमशीन नाम नहीं है।"
|
|
76
|
+
|
|
77
|
+
#: statemachine/state.py:155
|
|
78
|
+
msgid "State overriding is not allowed. Trying to add '{}' to {}"
|
|
79
|
+
msgstr "स्टेट ओवरराइड करना अनुमति नहीं है। '{}' को {} में जोड़ने की कोशिश कर रहे हैं"
|
|
80
|
+
|
|
81
|
+
#: statemachine/statemachine.py:94
|
|
82
|
+
msgid "There are no states or transitions."
|
|
83
|
+
msgstr "कोई स्टेट या ट्रांज़िशन नहीं हैं।"
|
|
84
|
+
|
|
85
|
+
#: statemachine/statemachine.py:285
|
|
86
|
+
msgid ""
|
|
87
|
+
"There's no current state set. In async code, did you activate the initial"
|
|
88
|
+
" state? (e.g., `await sm.activate_initial_state()`)"
|
|
89
|
+
msgstr "कोई वर्तमान स्टेट सेट नहीं है। असिंक्रोनस कोड में, क्या आपने प्रारंभिक स्टेट को सक्रिय किया? (उदाहरण: `await sm.activate_initial_state()`)"
|
|
90
|
+
|
|
91
|
+
#: statemachine/engines/async_.py:22
|
|
92
|
+
msgid "Only RTC is supported on async engine"
|
|
93
|
+
msgstr "असिंक्रोनस इंजन पर केवल RTC समर्थित है"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
msgid ""
|
|
5
5
|
msgstr ""
|
|
6
|
-
"Project-Id-Version: 2.
|
|
6
|
+
"Project-Id-Version: 2.4.0\n"
|
|
7
7
|
"Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
|
|
8
8
|
"POT-Creation-Date: 2023-03-04 16:10-0300\n"
|
|
9
9
|
"PO-Revision-Date: 2024-06-07 17:41-0300\n"
|
|
@@ -14,78 +14,80 @@ msgstr ""
|
|
|
14
14
|
"Content-Transfer-Encoding: 8bit\n"
|
|
15
15
|
"Generated-By: Babel 2.14.0\n"
|
|
16
16
|
|
|
17
|
-
#: statemachine/callbacks.py:
|
|
17
|
+
#: statemachine/callbacks.py:165
|
|
18
|
+
msgid "Failed to parse boolean expression '{}'"
|
|
19
|
+
msgstr "Falha ao interpretar a expressão booleana '{}'"
|
|
20
|
+
|
|
21
|
+
#: statemachine/callbacks.py:407 statemachine/callbacks.py:412
|
|
18
22
|
msgid "Did not found name '{}' from model or statemachine"
|
|
19
|
-
msgstr "
|
|
23
|
+
msgstr "Nome '{}' não encontrado no modelo ou na máquina de estados"
|
|
20
24
|
|
|
21
|
-
#: statemachine/exceptions.py:
|
|
25
|
+
#: statemachine/exceptions.py:24
|
|
22
26
|
msgid "{!r} is not a valid state value."
|
|
23
27
|
msgstr "{!r} não é um valor de estado válido."
|
|
24
28
|
|
|
25
|
-
#: statemachine/exceptions.py:
|
|
29
|
+
#: statemachine/exceptions.py:38
|
|
26
30
|
msgid "Can't {} when in {}."
|
|
27
|
-
msgstr "Não é possível {} quando
|
|
31
|
+
msgstr "Não é possível {} quando em {}."
|
|
28
32
|
|
|
29
|
-
#: statemachine/factory.py:
|
|
33
|
+
#: statemachine/factory.py:74
|
|
30
34
|
msgid "There are no states."
|
|
31
35
|
msgstr "Não há estados."
|
|
32
36
|
|
|
33
|
-
#: statemachine/factory.py:
|
|
37
|
+
#: statemachine/factory.py:77
|
|
34
38
|
msgid "There are no events."
|
|
35
39
|
msgstr "Não há eventos."
|
|
36
40
|
|
|
37
|
-
#: statemachine/factory.py:
|
|
41
|
+
#: statemachine/factory.py:89
|
|
38
42
|
msgid ""
|
|
39
43
|
"There should be one and only one initial state. You currently have these:"
|
|
40
44
|
" {!r}"
|
|
41
|
-
msgstr "Deve haver um e apenas um estado inicial.
|
|
45
|
+
msgstr "Deve haver um e apenas um estado inicial. Atualmente, você possui estes: {!r}"
|
|
42
46
|
|
|
43
|
-
#: statemachine/factory.py:
|
|
47
|
+
#: statemachine/factory.py:102
|
|
44
48
|
msgid "Cannot declare transitions from final state. Invalid state(s): {}"
|
|
45
|
-
msgstr ""
|
|
46
|
-
"Não é possível declarar transições a partir do estado final. Estado(s) "
|
|
47
|
-
"inválido(s): {}"
|
|
49
|
+
msgstr "Não é possível declarar transições a partir de um estado final. Estado(s) inválido(s): {}"
|
|
48
50
|
|
|
49
|
-
#: statemachine/factory.py:
|
|
51
|
+
#: statemachine/factory.py:110
|
|
50
52
|
msgid ""
|
|
51
53
|
"All non-final states should have at least one outgoing transition. These "
|
|
52
54
|
"states have no outgoing transition: {!r}"
|
|
53
|
-
msgstr ""
|
|
54
|
-
"Todos os estados não finais devem ter pelo menos uma transição de saída. "
|
|
55
|
-
"Esses estados não têm transição de saída: {!r}"
|
|
55
|
+
msgstr "Todos os estados não finais devem ter pelo menos uma transição de saída. Estes estados não possuem transição de saída: {!r}"
|
|
56
56
|
|
|
57
|
-
#: statemachine/factory.py:
|
|
57
|
+
#: statemachine/factory.py:124
|
|
58
58
|
msgid ""
|
|
59
59
|
"All non-final states should have at least one path to a final state. "
|
|
60
60
|
"These states have no path to a final state: {!r}"
|
|
61
|
-
msgstr ""
|
|
62
|
-
"Todos os estados não finais devem ter pelo menos um caminho para um "
|
|
63
|
-
"estado final. Esses estados não têm caminho para um estado final: {!r}"
|
|
61
|
+
msgstr "Todos os estados não finais devem ter pelo menos um caminho para um estado final. Estes estados não possuem caminho para um estado final: {!r}"
|
|
64
62
|
|
|
65
|
-
#: statemachine/factory.py:
|
|
63
|
+
#: statemachine/factory.py:148
|
|
66
64
|
msgid ""
|
|
67
65
|
"There are unreachable states. The statemachine graph should have a single"
|
|
68
66
|
" component. Disconnected states: {}"
|
|
69
|
-
msgstr ""
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
msgstr "Há estados inacessíveis. O grafo da máquina de estados deve ter um único componente. Estados desconectados: {}"
|
|
68
|
+
|
|
69
|
+
#: statemachine/factory.py:257
|
|
70
|
+
msgid "An event in the '{}' has no id."
|
|
71
|
+
msgstr "Um evento em '{}' não possui id."
|
|
72
72
|
|
|
73
|
-
#: statemachine/mixins.py:
|
|
73
|
+
#: statemachine/mixins.py:26
|
|
74
74
|
msgid "{!r} is not a valid state machine name."
|
|
75
|
-
msgstr "{!r} não é um nome
|
|
75
|
+
msgstr "{!r} não é um nome de máquina de estados válido."
|
|
76
76
|
|
|
77
|
-
#: statemachine/state.py:
|
|
77
|
+
#: statemachine/state.py:155
|
|
78
78
|
msgid "State overriding is not allowed. Trying to add '{}' to {}"
|
|
79
79
|
msgstr "Sobrescrever estados não é permitido. Tentando adicionar '{}' a {}"
|
|
80
80
|
|
|
81
|
-
#: statemachine/statemachine.py:
|
|
81
|
+
#: statemachine/statemachine.py:94
|
|
82
82
|
msgid "There are no states or transitions."
|
|
83
83
|
msgstr "Não há estados ou transições."
|
|
84
84
|
|
|
85
|
-
#: statemachine/statemachine.py:
|
|
85
|
+
#: statemachine/statemachine.py:285
|
|
86
86
|
msgid ""
|
|
87
87
|
"There's no current state set. In async code, did you activate the initial"
|
|
88
88
|
" state? (e.g., `await sm.activate_initial_state()`)"
|
|
89
|
-
msgstr ""
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
msgstr "Nenhum estado atual definido. Em código assíncrono, você ativou o estado inicial? (ex.: `await sm.activate_initial_state()`)"
|
|
90
|
+
|
|
91
|
+
#: statemachine/engines/async_.py:22
|
|
92
|
+
msgid "Only RTC is supported on async engine"
|
|
93
|
+
msgstr "Apenas RTC é suportado no motor assíncrono"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# This file is distributed under the same license as the project.
|
|
2
|
+
# Fernando Macedo <fgmacedo@gmail.com>, 2024.
|
|
3
|
+
#
|
|
4
|
+
msgid ""
|
|
5
|
+
msgstr ""
|
|
6
|
+
"Project-Id-Version: 2.4.0\n"
|
|
7
|
+
"Report-Msgid-Bugs-To: fgmacedo@gmail.com\n"
|
|
8
|
+
"POT-Creation-Date: 2023-03-04 16:10-0300\n"
|
|
9
|
+
"PO-Revision-Date: 2024-06-07 17:41-0300\n"
|
|
10
|
+
"Last-Translator: Fernando Macedo <fgmacedo@gmail.com>\n"
|
|
11
|
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
12
|
+
"MIME-Version: 1.0\n"
|
|
13
|
+
"Content-Type: text/plain; charset=utf-8\n"
|
|
14
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
15
|
+
"Generated-By: Babel 2.14.0\n"
|
|
16
|
+
|
|
17
|
+
#: statemachine/callbacks.py:165
|
|
18
|
+
msgid "Failed to parse boolean expression '{}'"
|
|
19
|
+
msgstr "无法解析布尔表达式 '{}'"
|
|
20
|
+
|
|
21
|
+
#: statemachine/callbacks.py:407 statemachine/callbacks.py:412
|
|
22
|
+
msgid "Did not found name '{}' from model or statemachine"
|
|
23
|
+
msgstr "在模型或状态机中未找到名称 '{}'"
|
|
24
|
+
|
|
25
|
+
#: statemachine/exceptions.py:24
|
|
26
|
+
msgid "{!r} is not a valid state value."
|
|
27
|
+
msgstr "{!r} 不是有效的状态值。"
|
|
28
|
+
|
|
29
|
+
#: statemachine/exceptions.py:38
|
|
30
|
+
msgid "Can't {} when in {}."
|
|
31
|
+
msgstr "在 {} 时无法 {}。"
|
|
32
|
+
|
|
33
|
+
#: statemachine/factory.py:74
|
|
34
|
+
msgid "There are no states."
|
|
35
|
+
msgstr "没有状态。"
|
|
36
|
+
|
|
37
|
+
#: statemachine/factory.py:77
|
|
38
|
+
msgid "There are no events."
|
|
39
|
+
msgstr "没有事件。"
|
|
40
|
+
|
|
41
|
+
#: statemachine/factory.py:89
|
|
42
|
+
msgid ""
|
|
43
|
+
"There should be one and only one initial state. You currently have these:"
|
|
44
|
+
" {!r}"
|
|
45
|
+
msgstr "应有且仅有一个初始状态。当前您有这些:{!r}"
|
|
46
|
+
|
|
47
|
+
#: statemachine/factory.py:102
|
|
48
|
+
msgid "Cannot declare transitions from final state. Invalid state(s): {}"
|
|
49
|
+
msgstr "无法从终止状态声明转换。无效状态:{}"
|
|
50
|
+
|
|
51
|
+
#: statemachine/factory.py:110
|
|
52
|
+
msgid ""
|
|
53
|
+
"All non-final states should have at least one outgoing transition. These "
|
|
54
|
+
"states have no outgoing transition: {!r}"
|
|
55
|
+
msgstr "所有非终止状态都应至少有一个外部转换。这些状态没有外部转换:{!r}"
|
|
56
|
+
|
|
57
|
+
#: statemachine/factory.py:124
|
|
58
|
+
msgid ""
|
|
59
|
+
"All non-final states should have at least one path to a final state. "
|
|
60
|
+
"These states have no path to a final state: {!r}"
|
|
61
|
+
msgstr "所有非终止状态应至少有一个到终止状态的路径。这些状态没有到终止状态的路径:{!r}"
|
|
62
|
+
|
|
63
|
+
#: statemachine/factory.py:148
|
|
64
|
+
msgid ""
|
|
65
|
+
"There are unreachable states. The statemachine graph should have a single"
|
|
66
|
+
" component. Disconnected states: {}"
|
|
67
|
+
msgstr "存在不可到达的状态。状态机图应具有单个组件。断开的状态:{}"
|
|
68
|
+
|
|
69
|
+
#: statemachine/factory.py:257
|
|
70
|
+
msgid "An event in the '{}' has no id."
|
|
71
|
+
msgstr "'{}' 中的事件没有 ID。"
|
|
72
|
+
|
|
73
|
+
#: statemachine/mixins.py:26
|
|
74
|
+
msgid "{!r} is not a valid state machine name."
|
|
75
|
+
msgstr "{!r} 不是有效的状态机名称。"
|
|
76
|
+
|
|
77
|
+
#: statemachine/state.py:155
|
|
78
|
+
msgid "State overriding is not allowed. Trying to add '{}' to {}"
|
|
79
|
+
msgstr "不允许覆盖状态。尝试将 '{}' 添加到 {}"
|
|
80
|
+
|
|
81
|
+
#: statemachine/statemachine.py:94
|
|
82
|
+
msgid "There are no states or transitions."
|
|
83
|
+
msgstr "没有状态或转换。"
|
|
84
|
+
|
|
85
|
+
#: statemachine/statemachine.py:285
|
|
86
|
+
msgid ""
|
|
87
|
+
"There's no current state set. In async code, did you activate the initial"
|
|
88
|
+
" state? (e.g., `await sm.activate_initial_state()`)"
|
|
89
|
+
msgstr "没有设置当前状态。在异步代码中,您是否激活了初始状态?(例如,`await sm.activate_initial_state()`)"
|
|
90
|
+
|
|
91
|
+
#: statemachine/engines/async_.py:22
|
|
92
|
+
msgid "Only RTC is supported on async engine"
|
|
93
|
+
msgstr "异步引擎仅支持 RTC"
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
import re
|
|
3
|
+
from typing import Callable
|
|
4
|
+
|
|
5
|
+
replacements = {"!": "not ", "^": " and ", "v": " or "}
|
|
6
|
+
|
|
7
|
+
pattern = re.compile(r"\!|\^|\bv\b")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def replace_operators(expr: str) -> str:
|
|
11
|
+
# preprocess the expression adding support for classical logical operators
|
|
12
|
+
def match_func(match):
|
|
13
|
+
return replacements[match.group(0)]
|
|
14
|
+
|
|
15
|
+
return pattern.sub(match_func, expr)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def custom_not(predicate: Callable) -> Callable:
|
|
19
|
+
def decorated(*args, **kwargs) -> bool:
|
|
20
|
+
return not predicate(*args, **kwargs)
|
|
21
|
+
|
|
22
|
+
decorated.__name__ = f"not({predicate.__name__})"
|
|
23
|
+
unique_key = getattr(predicate, "unique_key", "")
|
|
24
|
+
decorated.unique_key = f"not({unique_key})" # type: ignore[attr-defined]
|
|
25
|
+
return decorated
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _unique_key(left, right, operator) -> str:
|
|
29
|
+
left_key = getattr(left, "unique_key", "")
|
|
30
|
+
right_key = getattr(right, "unique_key", "")
|
|
31
|
+
return f"{left_key} {operator} {right_key}"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def custom_and(left: Callable, right: Callable) -> Callable:
|
|
35
|
+
def decorated(*args, **kwargs) -> bool:
|
|
36
|
+
return left(*args, **kwargs) and right(*args, **kwargs) # type: ignore[no-any-return]
|
|
37
|
+
|
|
38
|
+
decorated.__name__ = f"({left.__name__} and {right.__name__})"
|
|
39
|
+
decorated.unique_key = _unique_key(left, right, "and") # type: ignore[attr-defined]
|
|
40
|
+
return decorated
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def custom_or(left: Callable, right: Callable) -> Callable:
|
|
44
|
+
def decorated(*args, **kwargs) -> bool:
|
|
45
|
+
return left(*args, **kwargs) or right(*args, **kwargs) # type: ignore[no-any-return]
|
|
46
|
+
|
|
47
|
+
decorated.__name__ = f"({left.__name__} or {right.__name__})"
|
|
48
|
+
decorated.unique_key = _unique_key(left, right, "or") # type: ignore[attr-defined]
|
|
49
|
+
return decorated
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def build_expression(node, variable_hook, operator_mapping):
|
|
53
|
+
if isinstance(node, ast.BoolOp):
|
|
54
|
+
# Handle `and` / `or` operations
|
|
55
|
+
operator_fn = operator_mapping[type(node.op)]
|
|
56
|
+
left_expr = build_expression(node.values[0], variable_hook, operator_mapping)
|
|
57
|
+
for right in node.values[1:]:
|
|
58
|
+
right_expr = build_expression(right, variable_hook, operator_mapping)
|
|
59
|
+
left_expr = operator_fn(left_expr, right_expr)
|
|
60
|
+
return left_expr
|
|
61
|
+
elif isinstance(node, ast.UnaryOp) and isinstance(node.op, ast.Not):
|
|
62
|
+
# Handle `not` operation
|
|
63
|
+
operand_expr = build_expression(node.operand, variable_hook, operator_mapping)
|
|
64
|
+
return operator_mapping[type(node.op)](operand_expr)
|
|
65
|
+
elif isinstance(node, ast.Name):
|
|
66
|
+
# Handle variables by calling the variable_hook
|
|
67
|
+
return variable_hook(node.id)
|
|
68
|
+
else:
|
|
69
|
+
raise ValueError(f"Unsupported expression structure: {node.__class__.__name__}")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def parse_boolean_expr(expr, variable_hook, operator_mapping):
|
|
73
|
+
"""Parses the expression into an AST and build a custom expression tree"""
|
|
74
|
+
expr = replace_operators(expr)
|
|
75
|
+
tree = ast.parse(expr, mode="eval")
|
|
76
|
+
return build_expression(tree.body, variable_hook, operator_mapping)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
operator_mapping = {ast.Or: custom_or, ast.And: custom_and, ast.Not: custom_not}
|
statemachine/state.py
CHANGED
|
@@ -92,6 +92,13 @@ class State:
|
|
|
92
92
|
>>> [(t.source.name, t.target.name) for t in transitions]
|
|
93
93
|
[('Draft', 'Draft'), ('Draft', 'Producing'), ('Draft', 'Closed')]
|
|
94
94
|
|
|
95
|
+
Sometimes it's easier to use the :func:`State.from_` method:
|
|
96
|
+
|
|
97
|
+
>>> transitions = closed.from_(draft, producing, closed)
|
|
98
|
+
|
|
99
|
+
>>> [(t.source.name, t.target.name) for t in transitions]
|
|
100
|
+
[('Draft', 'Closed'), ('Producing', 'Closed'), ('Closed', 'Closed')]
|
|
101
|
+
|
|
95
102
|
"""
|
|
96
103
|
|
|
97
104
|
def __init__(
|
statemachine/statemachine.py
CHANGED
|
@@ -18,7 +18,7 @@ from .dispatcher import Listener
|
|
|
18
18
|
from .dispatcher import Listeners
|
|
19
19
|
from .engines.async_ import AsyncEngine
|
|
20
20
|
from .engines.sync import SyncEngine
|
|
21
|
-
from .event import
|
|
21
|
+
from .event import BoundEvent
|
|
22
22
|
from .event_data import TriggerData
|
|
23
23
|
from .exceptions import InvalidDefinition
|
|
24
24
|
from .exceptions import InvalidStateValue
|
|
@@ -101,7 +101,7 @@ class StateMachine(metaclass=StateMachineMetaclass):
|
|
|
101
101
|
if self.current_state_value is None:
|
|
102
102
|
trigger_data = TriggerData(
|
|
103
103
|
machine=self,
|
|
104
|
-
event="__initial__",
|
|
104
|
+
event=BoundEvent("__initial__", _sm=self),
|
|
105
105
|
)
|
|
106
106
|
self._put_nonblocking(trigger_data)
|
|
107
107
|
|
|
@@ -168,17 +168,16 @@ class StateMachine(metaclass=StateMachineMetaclass):
|
|
|
168
168
|
"""Bind the state machine events to the target objects."""
|
|
169
169
|
|
|
170
170
|
for event in self.events:
|
|
171
|
-
trigger = getattr(self, event
|
|
171
|
+
trigger = getattr(self, event)
|
|
172
172
|
for target in targets:
|
|
173
|
-
if hasattr(target, event
|
|
173
|
+
if hasattr(target, event):
|
|
174
174
|
warnings.warn(
|
|
175
|
-
f"Attribute {event
|
|
176
|
-
f"Skipping binding.",
|
|
175
|
+
f"Attribute '{event}' already exists on {target!r}. Skipping binding.",
|
|
177
176
|
UserWarning,
|
|
178
177
|
stacklevel=2,
|
|
179
178
|
)
|
|
180
179
|
continue
|
|
181
|
-
setattr(target, event
|
|
180
|
+
setattr(target, event, trigger)
|
|
182
181
|
|
|
183
182
|
def _add_listener(self, listeners: "Listeners", allowed_references: SpecReference = SPECS_ALL):
|
|
184
183
|
register = partial(
|
|
@@ -316,21 +315,13 @@ class StateMachine(metaclass=StateMachineMetaclass):
|
|
|
316
315
|
See: :ref:`triggering events`.
|
|
317
316
|
|
|
318
317
|
"""
|
|
319
|
-
|
|
318
|
+
event_instance: BoundEvent = getattr(
|
|
319
|
+
self, event, BoundEvent(id=event, name=event, _sm=self)
|
|
320
|
+
)
|
|
321
|
+
result = event_instance(*args, **kwargs)
|
|
320
322
|
if not isawaitable(result):
|
|
321
323
|
return result
|
|
322
324
|
return run_async_from_sync(result)
|
|
323
325
|
|
|
324
|
-
def _async_send(self, event: str, *args, **kwargs):
|
|
325
|
-
"""Send an :ref:`Event` to the state machine.
|
|
326
|
-
|
|
327
|
-
.. seealso::
|
|
328
|
-
|
|
329
|
-
See: :ref:`triggering events`.
|
|
330
|
-
|
|
331
|
-
"""
|
|
332
|
-
event_instance: Event = Event(event)
|
|
333
|
-
return event_instance.trigger(self, *args, **kwargs)
|
|
334
|
-
|
|
335
326
|
def _get_callbacks(self, key) -> CallbacksExecutor:
|
|
336
327
|
return self._callbacks_registry[key]
|
statemachine/states.py
CHANGED
|
@@ -136,14 +136,14 @@ class States:
|
|
|
136
136
|
|
|
137
137
|
.. deprecated:: 2.3.3
|
|
138
138
|
|
|
139
|
-
On the next major release,
|
|
139
|
+
On the next major release, ``use_enum_instance=True`` will be the default.
|
|
140
140
|
|
|
141
141
|
Args:
|
|
142
142
|
enum_type: An enumeration containing the states of the machine.
|
|
143
143
|
initial: The initial state of the machine.
|
|
144
144
|
final: A set of final states of the machine.
|
|
145
145
|
use_enum_instance: If ``True``, the value of the state will be the enum item instance,
|
|
146
|
-
otherwise the enum item value.
|
|
146
|
+
otherwise the enum item value. Defaults to ``False``.
|
|
147
147
|
|
|
148
148
|
Returns:
|
|
149
149
|
A new instance of the :ref:`States (class)`.
|
statemachine/transition.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from .callbacks import CallbackGroup
|
|
2
2
|
from .callbacks import CallbackPriority
|
|
3
3
|
from .callbacks import CallbackSpecList
|
|
4
|
-
from .event import same_event_cond_builder
|
|
5
4
|
from .events import Events
|
|
6
5
|
from .exceptions import InvalidDefinition
|
|
7
6
|
|
|
@@ -87,7 +86,7 @@ class Transition:
|
|
|
87
86
|
on("on_transition", priority=CallbackPriority.GENERIC, is_convention=True)
|
|
88
87
|
|
|
89
88
|
for event in self._events:
|
|
90
|
-
same_event_cond =
|
|
89
|
+
same_event_cond = event.is_same_event
|
|
91
90
|
before(
|
|
92
91
|
f"before_{event}",
|
|
93
92
|
priority=CallbackPriority.NAMING,
|
statemachine/transition_list.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING
|
|
1
2
|
from typing import Callable
|
|
2
3
|
from typing import Iterable
|
|
3
4
|
from typing import List
|
|
@@ -5,6 +6,9 @@ from typing import List
|
|
|
5
6
|
from .transition import Transition
|
|
6
7
|
from .utils import ensure_iterable
|
|
7
8
|
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .events import Event
|
|
11
|
+
|
|
8
12
|
|
|
9
13
|
class TransitionList:
|
|
10
14
|
"""A list-like container of :ref:`transitions` with callback functions."""
|
|
@@ -170,7 +174,7 @@ class TransitionList:
|
|
|
170
174
|
transition.add_event(event)
|
|
171
175
|
|
|
172
176
|
@property
|
|
173
|
-
def unique_events(self) -> List[
|
|
177
|
+
def unique_events(self) -> List["Event"]:
|
|
174
178
|
"""
|
|
175
179
|
Returns a list of unique event names across all transitions in the :ref:`TransitionList`
|
|
176
180
|
instance.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
statemachine/__init__.py,sha256=_tQlx-C4SHRysuQwRTIU3c9C8MJrDlvIVCG0kfuWFBk,192
|
|
2
|
-
statemachine/callbacks.py,sha256=5_WaILrjUvZOYX_LQe4Gd8nsCvkErjw9DaHYG_ggvxs,11101
|
|
3
|
-
statemachine/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
statemachine/contrib/diagram.py,sha256=eK3unncEXNq3e_yfBTZmvgdWWWDZq69r7gsHvCHr5Ys,7208
|
|
5
|
-
statemachine/dispatcher.py,sha256=2DtjCj_kiDF2uk_EEvXxs5NTABOvCr4paxVz77s6mXA,5365
|
|
6
|
-
statemachine/engines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
statemachine/engines/async_.py,sha256=deZ5oYeoIYX9zOsFEOCT4KXsz5V1F9fbaMDOBATnTkE,5572
|
|
8
|
-
statemachine/engines/sync.py,sha256=cGy23Ivx0Ul4NWSix8E8PNA1Ji4V9qvOd3K_yodD_UI,5523
|
|
9
|
-
statemachine/event.py,sha256=LfvO-imBVyVX6krBK0Pz7q-iTRudo_5OjTFaYJpc6IQ,1556
|
|
10
|
-
statemachine/event_data.py,sha256=x9m9Q2q-78kVFnJVJmOAwq6lo9zgSVxko3q4Omwjqxk,2228
|
|
11
|
-
statemachine/events.py,sha256=QgXcxu25WkUaxJvonh0K7hOlYYSQlV0jbhTCAi_gpwc,736
|
|
12
|
-
statemachine/exceptions.py,sha256=RWq1vTjajxt8CzfYCD4DfI2nrgkfCPBL0DjRDOzKkQI,1086
|
|
13
|
-
statemachine/factory.py,sha256=8rRvDXWGjEX6v6mP7YiXOJPTCcm-GhDmuTvyotw1zoc,7948
|
|
14
|
-
statemachine/graph.py,sha256=KtwB1CYckaLjTgQD9tEeuaEzJje9q3fPVpBViW5TgSk,487
|
|
15
|
-
statemachine/i18n.py,sha256=NLvGseaORmQ0G-V_J8tkjoxh_piWMOm2CI6mBQpLamc,362
|
|
16
|
-
statemachine/locale/en/LC_MESSAGES/statemachine.po,sha256=zJYaV2DxrHdPngDOt1bji8-lPOZMSDjWG83Ypru5DOI,2126
|
|
17
|
-
statemachine/locale/pt_BR/LC_MESSAGES/statemachine.po,sha256=SPrt-KaCBCKQq7PoOMtyyqU1bihrw_3MPL_NbqZzTVs,3214
|
|
18
|
-
statemachine/mixins.py,sha256=Y1fa52Cj20JaGkyNk3P7Gpqkt4cGTjJ0YyV_VQyCl0M,1231
|
|
19
|
-
statemachine/model.py,sha256=OylI3FjMiHpYyDl9mtK1zEJMeSvemaN4giQDonpc8kI,211
|
|
20
|
-
statemachine/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
statemachine/registry.py,sha256=HmV9sUGkYVrNUZxJYoZo-trSUis7dIun_WcGktblgc8,922
|
|
22
|
-
statemachine/signature.py,sha256=HwuyWX3p_GZwKKrGbt9wk4-bHpymqs_pgqW7OlDgGRc,7877
|
|
23
|
-
statemachine/state.py,sha256=IKdkMBkXCgcvswMKQZ-hn0-739Hhf6z6q8mSEoevV7o,8262
|
|
24
|
-
statemachine/statemachine.py,sha256=IvvQ9NKQAdfMXD5xc7Henvy3YrLd5vjN1APG-WnhmlM,11574
|
|
25
|
-
statemachine/states.py,sha256=vpRNjiGmTDHvE0fn0gwdq8-WcG32n4ZiPTU-kgZ73rc,4870
|
|
26
|
-
statemachine/transition.py,sha256=R7gfSZjqR59OIdpKePgdr66zTp5azow-tDqqYJsECR4,4711
|
|
27
|
-
statemachine/transition_list.py,sha256=_tdFD1O7hw8xVAU6nRYmGrj6TCAM0SD-Sa0_DYKa88Y,6034
|
|
28
|
-
statemachine/utils.py,sha256=DpcrGqlbrnT-ogh-BogG0L07EG3KirHOsKORHlspDlI,1041
|
|
29
|
-
python_statemachine-2.3.6.dist-info/LICENSE,sha256=zcP7TsJMqaFxuTvLRZPT7nJl3_ppjxR9Z76BE9pL5zc,1074
|
|
30
|
-
python_statemachine-2.3.6.dist-info/METADATA,sha256=Ozs8cZly2wGdAlvS144fRCe_umkG6lbqGpJHZxgpihc,14036
|
|
31
|
-
python_statemachine-2.3.6.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
32
|
-
python_statemachine-2.3.6.dist-info/RECORD,,
|