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