scratchattach 2.1.9__py3-none-any.whl → 2.1.10a0__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.
- scratchattach/__init__.py +28 -25
- scratchattach/cloud/__init__.py +2 -0
- scratchattach/cloud/_base.py +454 -282
- scratchattach/cloud/cloud.py +171 -168
- scratchattach/editor/__init__.py +21 -0
- scratchattach/editor/asset.py +199 -0
- scratchattach/editor/backpack_json.py +117 -0
- scratchattach/editor/base.py +142 -0
- scratchattach/editor/block.py +507 -0
- scratchattach/editor/blockshape.py +353 -0
- scratchattach/editor/build_defaulting.py +47 -0
- scratchattach/editor/comment.py +74 -0
- scratchattach/editor/commons.py +243 -0
- scratchattach/editor/extension.py +43 -0
- scratchattach/editor/field.py +90 -0
- scratchattach/editor/inputs.py +132 -0
- scratchattach/editor/meta.py +106 -0
- scratchattach/editor/monitor.py +175 -0
- scratchattach/editor/mutation.py +317 -0
- scratchattach/editor/pallete.py +91 -0
- scratchattach/editor/prim.py +170 -0
- scratchattach/editor/project.py +273 -0
- scratchattach/editor/sbuild.py +2837 -0
- scratchattach/editor/sprite.py +586 -0
- scratchattach/editor/twconfig.py +113 -0
- scratchattach/editor/vlb.py +134 -0
- scratchattach/eventhandlers/_base.py +99 -92
- scratchattach/eventhandlers/cloud_events.py +110 -103
- scratchattach/eventhandlers/cloud_recorder.py +26 -21
- scratchattach/eventhandlers/cloud_requests.py +460 -452
- scratchattach/eventhandlers/cloud_server.py +246 -244
- scratchattach/eventhandlers/cloud_storage.py +135 -134
- scratchattach/eventhandlers/combine.py +29 -27
- scratchattach/eventhandlers/filterbot.py +160 -159
- scratchattach/eventhandlers/message_events.py +41 -40
- scratchattach/other/other_apis.py +284 -212
- scratchattach/other/project_json_capabilities.py +475 -546
- scratchattach/site/_base.py +64 -46
- scratchattach/site/activity.py +414 -122
- scratchattach/site/backpack_asset.py +118 -84
- scratchattach/site/classroom.py +430 -142
- scratchattach/site/cloud_activity.py +107 -103
- scratchattach/site/comment.py +220 -190
- scratchattach/site/forum.py +400 -399
- scratchattach/site/project.py +806 -787
- scratchattach/site/session.py +1134 -867
- scratchattach/site/studio.py +611 -609
- scratchattach/site/user.py +835 -837
- scratchattach/utils/commons.py +243 -148
- scratchattach/utils/encoder.py +157 -156
- scratchattach/utils/enums.py +197 -190
- scratchattach/utils/exceptions.py +233 -206
- scratchattach/utils/requests.py +67 -59
- {scratchattach-2.1.9.dist-info → scratchattach-2.1.10a0.dist-info}/LICENSE +21 -21
- {scratchattach-2.1.9.dist-info → scratchattach-2.1.10a0.dist-info}/METADATA +154 -146
- scratchattach-2.1.10a0.dist-info/RECORD +62 -0
- {scratchattach-2.1.9.dist-info → scratchattach-2.1.10a0.dist-info}/WHEEL +1 -1
- scratchattach-2.1.9.dist-info/RECORD +0 -40
- {scratchattach-2.1.9.dist-info → scratchattach-2.1.10a0.dist-info}/top_level.txt +0 -0
scratchattach/utils/enums.py
CHANGED
|
@@ -1,190 +1,197 @@
|
|
|
1
|
-
"""
|
|
2
|
-
List of supported languages of scratch's translate and text2speech extensions.
|
|
3
|
-
Adapted from https://translate-service.scratch.mit.edu/supported?language=en
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
the
|
|
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
|
-
|
|
1
|
+
"""
|
|
2
|
+
List of supported languages of scratch's translate and text2speech extensions.
|
|
3
|
+
Adapted from https://translate-service.scratch.mit.edu/supported?language=en
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from enum import Enum
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
|
|
10
|
+
from typing import Optional, Callable, Iterable
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(init=True, repr=True)
|
|
14
|
+
class Language:
|
|
15
|
+
name: str = None
|
|
16
|
+
code: str = None
|
|
17
|
+
locales: list[str] = None
|
|
18
|
+
tts_locale: str = None
|
|
19
|
+
single_gender: bool = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class _EnumWrapper(Enum):
|
|
23
|
+
@classmethod
|
|
24
|
+
def find(cls, value, by: str, apply_func: Optional[Callable] = None):
|
|
25
|
+
"""
|
|
26
|
+
Finds the enum item with the given attribute that is equal to the given value.
|
|
27
|
+
the apply_func will be applied to the attribute of each language object before comparison.
|
|
28
|
+
|
|
29
|
+
i.e. Languages.find("ukranian", "name", str.lower) will return the Ukrainian language dataclass object
|
|
30
|
+
(even though Ukrainian was spelt lowercase, since str.lower will convert the "Ukrainian" string to lowercase)
|
|
31
|
+
"""
|
|
32
|
+
if apply_func is None:
|
|
33
|
+
def apply_func(x):
|
|
34
|
+
return x
|
|
35
|
+
|
|
36
|
+
for item in cls:
|
|
37
|
+
item_obj = item.value
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
if by is None:
|
|
41
|
+
_val = item_obj
|
|
42
|
+
else:
|
|
43
|
+
_val = getattr(item_obj, by)
|
|
44
|
+
|
|
45
|
+
if apply_func(_val) == value:
|
|
46
|
+
return item_obj
|
|
47
|
+
|
|
48
|
+
except TypeError:
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def all_of(cls, attr_name: str, apply_func: Optional[Callable] = None) -> Iterable:
|
|
53
|
+
"""
|
|
54
|
+
Returns the list of each listed enum item's specified attribute by "attr_name"
|
|
55
|
+
|
|
56
|
+
i.e. Languages.all_of("name") will return a list of names:
|
|
57
|
+
["Albanian", "Amharic", ...]
|
|
58
|
+
|
|
59
|
+
The apply_func function will be applied to every list item,
|
|
60
|
+
i.e. Languages.all_of("name", str.lower) will return the same except in lowercase:
|
|
61
|
+
["albanian", "amharic", ...]
|
|
62
|
+
"""
|
|
63
|
+
if apply_func is None:
|
|
64
|
+
def apply_func(x):
|
|
65
|
+
return x
|
|
66
|
+
|
|
67
|
+
for item in cls:
|
|
68
|
+
item_obj = item.value
|
|
69
|
+
attr = getattr(item_obj, attr_name)
|
|
70
|
+
try:
|
|
71
|
+
yield apply_func(attr)
|
|
72
|
+
|
|
73
|
+
except TypeError:
|
|
74
|
+
yield attr
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def find_by_attrs(cls, value, bys: list[str], apply_func: Optional[Callable] = None) -> list:
|
|
78
|
+
"""
|
|
79
|
+
Calls the EnumWrapper.by function multiple times until a match is found, using the provided 'by' attribute names
|
|
80
|
+
"""
|
|
81
|
+
for by in bys:
|
|
82
|
+
ret = cls.find(value, by, apply_func)
|
|
83
|
+
if ret is not None:
|
|
84
|
+
return ret
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Languages(_EnumWrapper):
|
|
88
|
+
Albanian = Language('Albanian', 'sq', None, None, None)
|
|
89
|
+
Amharic = Language('Amharic', 'am', None, None, None)
|
|
90
|
+
Arabic = Language('Arabic', 'ar', ['ar'], 'arb', True)
|
|
91
|
+
Armenian = Language('Armenian', 'hy', None, None, None)
|
|
92
|
+
Azerbaijani = Language('Azerbaijani', 'az', None, None, None)
|
|
93
|
+
Basque = Language('Basque', 'eu', None, None, None)
|
|
94
|
+
Belarusian = Language('Belarusian', 'be', None, None, None)
|
|
95
|
+
Bulgarian = Language('Bulgarian', 'bg', None, None, None)
|
|
96
|
+
Catalan = Language('Catalan', 'ca', None, None, None)
|
|
97
|
+
Chinese_Traditional = Language('Chinese (Traditional)', 'zh-tw', ['zh-cn', 'zh-tw'], 'cmn-CN', True)
|
|
98
|
+
Croatian = Language('Croatian', 'hr', None, None, None)
|
|
99
|
+
Czech = Language('Czech', 'cs', None, None, None)
|
|
100
|
+
Danish = Language('Danish', 'da', ['da'], 'da-DK', False)
|
|
101
|
+
Dutch = Language('Dutch', 'nl', ['nl'], 'nl-NL', False)
|
|
102
|
+
English = Language('English', 'en', ['en'], 'en-US', False)
|
|
103
|
+
Esperanto = Language('Esperanto', 'eo', None, None, None)
|
|
104
|
+
Estonian = Language('Estonian', 'et', None, None, None)
|
|
105
|
+
Finnish = Language('Finnish', 'fi', None, None, None)
|
|
106
|
+
French = Language('French', 'fr', ['fr'], 'fr-FR', False)
|
|
107
|
+
Galician = Language('Galician', 'gl', None, None, None)
|
|
108
|
+
German = Language('German', 'de', ['de'], 'de-DE', False)
|
|
109
|
+
Greek = Language('Greek', 'el', None, None, None)
|
|
110
|
+
Haitian_Creole = Language('Haitian Creole', 'ht', None, None, None)
|
|
111
|
+
Hindi = Language('Hindi', 'hi', ['hi'], 'hi-IN', True)
|
|
112
|
+
Hungarian = Language('Hungarian', 'hu', None, None, None)
|
|
113
|
+
Icelandic = Language('Icelandic', 'is', ['is'], 'is-IS', False)
|
|
114
|
+
Indonesian = Language('Indonesian', 'id', None, None, None)
|
|
115
|
+
Irish = Language('Irish', 'ga', None, None, None)
|
|
116
|
+
Italian = Language('Italian', 'it', ['it'], 'it-IT', False)
|
|
117
|
+
Japanese = Language('Japanese', 'ja', ['ja', 'ja-hira'], 'ja-JP', False)
|
|
118
|
+
Kannada = Language('Kannada', 'kn', None, None, None)
|
|
119
|
+
Korean = Language('Korean', 'ko', ['ko'], 'ko-KR', True)
|
|
120
|
+
Kurdish_Kurmanji = Language('Kurdish (Kurmanji)', 'ku', None, None, None)
|
|
121
|
+
Latin = Language('Latin', 'la', None, None, None)
|
|
122
|
+
Latvian = Language('Latvian', 'lv', None, None, None)
|
|
123
|
+
Lithuanian = Language('Lithuanian', 'lt', None, None, None)
|
|
124
|
+
Macedonian = Language('Macedonian', 'mk', None, None, None)
|
|
125
|
+
Malay = Language('Malay', 'ms', None, None, None)
|
|
126
|
+
Malayalam = Language('Malayalam', 'ml', None, None, None)
|
|
127
|
+
Maltese = Language('Maltese', 'mt', None, None, None)
|
|
128
|
+
Maori = Language('Maori', 'mi', None, None, None)
|
|
129
|
+
Marathi = Language('Marathi', 'mr', None, None, None)
|
|
130
|
+
Mongolian = Language('Mongolian', 'mn', None, None, None)
|
|
131
|
+
Myanmar_Burmese = Language('Myanmar (Burmese)', 'my', None, None, None)
|
|
132
|
+
Persian = Language('Persian', 'fa', None, None, None)
|
|
133
|
+
Polish = Language('Polish', 'pl', ['pl'], 'pl-PL', False)
|
|
134
|
+
Portuguese = Language('Portuguese', 'pt', ['pt'], 'pt-PT', False)
|
|
135
|
+
Romanian = Language('Romanian', 'ro', ['ro'], 'ro-RO', True)
|
|
136
|
+
Russian = Language('Russian', 'ru', ['ru'], 'ru-RU', False)
|
|
137
|
+
Scots_Gaelic = Language('Scots Gaelic', 'gd', None, None, None)
|
|
138
|
+
Serbian = Language('Serbian', 'sr', None, None, None)
|
|
139
|
+
Slovak = Language('Slovak', 'sk', None, None, None)
|
|
140
|
+
Slovenian = Language('Slovenian', 'sl', None, None, None)
|
|
141
|
+
Spanish = Language('Spanish', 'es', None, None, None)
|
|
142
|
+
Swedish = Language('Swedish', 'sv', ['sv'], 'sv-SE', True)
|
|
143
|
+
Telugu = Language('Telugu', 'te', None, None, None)
|
|
144
|
+
Thai = Language('Thai', 'th', None, None, None)
|
|
145
|
+
Turkish = Language('Turkish', 'tr', ['tr'], 'tr-TR', True)
|
|
146
|
+
Ukrainian = Language('Ukrainian', 'uk', None, None, None)
|
|
147
|
+
Uzbek = Language('Uzbek', 'uz', None, None, None)
|
|
148
|
+
Vietnamese = Language('Vietnamese', 'vi', None, None, None)
|
|
149
|
+
Welsh = Language('Welsh', 'cy', ['cy'], 'cy-GB', True)
|
|
150
|
+
Zulu = Language('Zulu', 'zu', None, None, None)
|
|
151
|
+
Hebrew = Language('Hebrew', 'he', None, None, None)
|
|
152
|
+
Chinese_Simplified = Language('Chinese (Simplified)', 'zh-cn', ['zh-cn', 'zh-tw'], 'cmn-CN', True)
|
|
153
|
+
Mandarin = Chinese_Simplified
|
|
154
|
+
|
|
155
|
+
nb_NO = Language(None, None, ['nb', 'nn'], 'nb-NO', True)
|
|
156
|
+
pt_BR = Language(None, None, ['pt-br'], 'pt-BR', False)
|
|
157
|
+
Brazilian = pt_BR
|
|
158
|
+
es_ES = Language(None, None, ['es'], 'es-ES', False)
|
|
159
|
+
es_US = Language(None, None, ['es-419'], 'es-US', False)
|
|
160
|
+
|
|
161
|
+
@classmethod
|
|
162
|
+
def find(cls, value, by: str = "name", apply_func: Optional[Callable] = None) -> Language:
|
|
163
|
+
return super().find(value, by, apply_func)
|
|
164
|
+
|
|
165
|
+
@classmethod
|
|
166
|
+
def all_of(cls, attr_name: str = "name", apply_func: Optional[Callable] = None) -> list:
|
|
167
|
+
return super().all_of(attr_name, apply_func)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@dataclass(init=True, repr=True)
|
|
171
|
+
class TTSVoice:
|
|
172
|
+
name: str
|
|
173
|
+
gender: str
|
|
174
|
+
playback_rate: float | int = 1
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class TTSVoices(_EnumWrapper):
|
|
178
|
+
alto = TTSVoice("alto", "female")
|
|
179
|
+
# female is functionally equal to alto
|
|
180
|
+
female = TTSVoice("female", "female")
|
|
181
|
+
|
|
182
|
+
tenor = TTSVoice("tenor", "male")
|
|
183
|
+
# male is functionally equal to tenor
|
|
184
|
+
male = TTSVoice("male", "male")
|
|
185
|
+
|
|
186
|
+
squeak = TTSVoice("squeak", "female", 1.19)
|
|
187
|
+
giant = TTSVoice("giant", "male", .84)
|
|
188
|
+
kitten = TTSVoice("kitten", "female", 1.41)
|
|
189
|
+
|
|
190
|
+
@classmethod
|
|
191
|
+
def find(cls, value, by: str = "name", apply_func: Optional[Callable] = None) -> TTSVoice:
|
|
192
|
+
return super().find(value, by, apply_func)
|
|
193
|
+
|
|
194
|
+
@classmethod
|
|
195
|
+
def all_of(cls, attr_name: str = "name", apply_func: Optional[Callable] = None) -> Iterable:
|
|
196
|
+
return super().all_of(attr_name, apply_func)
|
|
197
|
+
|