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/encoder.py
CHANGED
|
@@ -1,157 +1,158 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
None,
|
|
7
|
-
None,
|
|
8
|
-
None,
|
|
9
|
-
None,
|
|
10
|
-
None,
|
|
11
|
-
None,
|
|
12
|
-
None,
|
|
13
|
-
None,
|
|
14
|
-
None,
|
|
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
|
-
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import math
|
|
3
|
+
from . import exceptions
|
|
4
|
+
|
|
5
|
+
letters = [
|
|
6
|
+
None,
|
|
7
|
+
None,
|
|
8
|
+
None,
|
|
9
|
+
None,
|
|
10
|
+
None,
|
|
11
|
+
None,
|
|
12
|
+
None,
|
|
13
|
+
None,
|
|
14
|
+
None,
|
|
15
|
+
None,
|
|
16
|
+
"1",
|
|
17
|
+
"2",
|
|
18
|
+
"3",
|
|
19
|
+
"4",
|
|
20
|
+
"5",
|
|
21
|
+
"6",
|
|
22
|
+
"7",
|
|
23
|
+
"8",
|
|
24
|
+
"9",
|
|
25
|
+
"0",
|
|
26
|
+
" ",
|
|
27
|
+
"a",
|
|
28
|
+
"A",
|
|
29
|
+
"b",
|
|
30
|
+
"B",
|
|
31
|
+
"c",
|
|
32
|
+
"C",
|
|
33
|
+
"d",
|
|
34
|
+
"D",
|
|
35
|
+
"e",
|
|
36
|
+
"E",
|
|
37
|
+
"f",
|
|
38
|
+
"F",
|
|
39
|
+
"g",
|
|
40
|
+
"G",
|
|
41
|
+
"h",
|
|
42
|
+
"H",
|
|
43
|
+
"i",
|
|
44
|
+
"I",
|
|
45
|
+
"j",
|
|
46
|
+
"J",
|
|
47
|
+
"k",
|
|
48
|
+
"K",
|
|
49
|
+
"l",
|
|
50
|
+
"L",
|
|
51
|
+
"m",
|
|
52
|
+
"M",
|
|
53
|
+
"n",
|
|
54
|
+
"N",
|
|
55
|
+
"o",
|
|
56
|
+
"O",
|
|
57
|
+
"p",
|
|
58
|
+
"P",
|
|
59
|
+
"q",
|
|
60
|
+
"Q",
|
|
61
|
+
"r",
|
|
62
|
+
"R",
|
|
63
|
+
"s",
|
|
64
|
+
"S",
|
|
65
|
+
"t",
|
|
66
|
+
"T",
|
|
67
|
+
"u",
|
|
68
|
+
"U",
|
|
69
|
+
"v",
|
|
70
|
+
"V",
|
|
71
|
+
"w",
|
|
72
|
+
"W",
|
|
73
|
+
"x",
|
|
74
|
+
"X",
|
|
75
|
+
"y",
|
|
76
|
+
"Y",
|
|
77
|
+
"z",
|
|
78
|
+
"Z",
|
|
79
|
+
"*",
|
|
80
|
+
"/",
|
|
81
|
+
".",
|
|
82
|
+
",",
|
|
83
|
+
"!",
|
|
84
|
+
'"',
|
|
85
|
+
"§",
|
|
86
|
+
"$",
|
|
87
|
+
"%",
|
|
88
|
+
"_",
|
|
89
|
+
"-",
|
|
90
|
+
"(",
|
|
91
|
+
"´",
|
|
92
|
+
")",
|
|
93
|
+
"`",
|
|
94
|
+
"?",
|
|
95
|
+
"new line",
|
|
96
|
+
"@",
|
|
97
|
+
"#",
|
|
98
|
+
"~",
|
|
99
|
+
";",
|
|
100
|
+
":",
|
|
101
|
+
"+",
|
|
102
|
+
"&",
|
|
103
|
+
"|",
|
|
104
|
+
"^",
|
|
105
|
+
"'"
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class Encoding:
|
|
110
|
+
"""
|
|
111
|
+
Class that contains tools for encoding / decoding strings. The strings encoded / decoded with these functions can be decoded / encoded with Scratch using this sprite: https://scratch3-assets.1tim.repl.co/Encoder.sprite3
|
|
112
|
+
"""
|
|
113
|
+
@staticmethod
|
|
114
|
+
def decode(inp):
|
|
115
|
+
"""
|
|
116
|
+
Args:
|
|
117
|
+
inp (str): The encoded input.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
str: The decoded output.
|
|
121
|
+
"""
|
|
122
|
+
try:
|
|
123
|
+
inp = str(inp)
|
|
124
|
+
except Exception:
|
|
125
|
+
raise(exceptions.InvalidDecodeInput)
|
|
126
|
+
outp = ""
|
|
127
|
+
for i in range(0, math.floor(len(inp) / 2)):
|
|
128
|
+
letter = letters[int(f"{inp[i*2]}{inp[(i*2)+1]}")]
|
|
129
|
+
outp = f"{outp}{letter}"
|
|
130
|
+
return outp
|
|
131
|
+
|
|
132
|
+
@staticmethod
|
|
133
|
+
def encode(inp):
|
|
134
|
+
"""
|
|
135
|
+
Args:
|
|
136
|
+
inp (str): The decoded input.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
str: The encoded output.
|
|
140
|
+
"""
|
|
141
|
+
inp = str(inp)
|
|
142
|
+
outp = ""
|
|
143
|
+
for i in inp:
|
|
144
|
+
if i in letters:
|
|
145
|
+
outp = f"{outp}{letters.index(i)}"
|
|
146
|
+
else:
|
|
147
|
+
outp += str(letters.index(" "))
|
|
148
|
+
return outp
|
|
149
|
+
|
|
150
|
+
@staticmethod
|
|
151
|
+
def replace_char(old_char, new_char):
|
|
152
|
+
"""
|
|
153
|
+
Replaces a character in the list that the encoder uses to encode / decode values.
|
|
154
|
+
You can access this list using `scratchattach.encoder.letters`
|
|
155
|
+
"""
|
|
156
|
+
i = letters.index(old_char)
|
|
157
|
+
letters[i] = new_char
|
|
157
158
|
|