scratchattach 2.1.15b0__py3-none-any.whl → 3.0.0b0__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 +14 -6
- scratchattach/__main__.py +93 -0
- {scratchattach-2.1.15b0.dist-info → scratchattach-3.0.0b0.dist-info}/METADATA +7 -11
- scratchattach-3.0.0b0.dist-info/RECORD +8 -0
- {scratchattach-2.1.15b0.dist-info → scratchattach-3.0.0b0.dist-info}/WHEEL +1 -1
- scratchattach-3.0.0b0.dist-info/entry_points.txt +2 -0
- scratchattach/cloud/__init__.py +0 -2
- scratchattach/cloud/_base.py +0 -458
- scratchattach/cloud/cloud.py +0 -183
- scratchattach/editor/__init__.py +0 -21
- scratchattach/editor/asset.py +0 -253
- scratchattach/editor/backpack_json.py +0 -117
- scratchattach/editor/base.py +0 -193
- scratchattach/editor/block.py +0 -579
- scratchattach/editor/blockshape.py +0 -357
- scratchattach/editor/build_defaulting.py +0 -51
- scratchattach/editor/code_translation/__init__.py +0 -0
- scratchattach/editor/code_translation/parse.py +0 -177
- scratchattach/editor/comment.py +0 -80
- scratchattach/editor/commons.py +0 -273
- scratchattach/editor/extension.py +0 -50
- scratchattach/editor/field.py +0 -99
- scratchattach/editor/inputs.py +0 -135
- scratchattach/editor/meta.py +0 -114
- scratchattach/editor/monitor.py +0 -183
- scratchattach/editor/mutation.py +0 -324
- scratchattach/editor/pallete.py +0 -90
- scratchattach/editor/prim.py +0 -170
- scratchattach/editor/project.py +0 -279
- scratchattach/editor/sprite.py +0 -599
- scratchattach/editor/twconfig.py +0 -114
- scratchattach/editor/vlb.py +0 -134
- scratchattach/eventhandlers/__init__.py +0 -0
- scratchattach/eventhandlers/_base.py +0 -100
- scratchattach/eventhandlers/cloud_events.py +0 -110
- scratchattach/eventhandlers/cloud_recorder.py +0 -26
- scratchattach/eventhandlers/cloud_requests.py +0 -459
- scratchattach/eventhandlers/cloud_server.py +0 -246
- scratchattach/eventhandlers/cloud_storage.py +0 -136
- scratchattach/eventhandlers/combine.py +0 -30
- scratchattach/eventhandlers/filterbot.py +0 -161
- scratchattach/eventhandlers/message_events.py +0 -42
- scratchattach/other/__init__.py +0 -0
- scratchattach/other/other_apis.py +0 -284
- scratchattach/other/project_json_capabilities.py +0 -475
- scratchattach/site/__init__.py +0 -0
- scratchattach/site/_base.py +0 -66
- scratchattach/site/activity.py +0 -382
- scratchattach/site/alert.py +0 -227
- scratchattach/site/backpack_asset.py +0 -118
- scratchattach/site/browser_cookie3_stub.py +0 -17
- scratchattach/site/browser_cookies.py +0 -61
- scratchattach/site/classroom.py +0 -447
- scratchattach/site/cloud_activity.py +0 -107
- scratchattach/site/comment.py +0 -242
- scratchattach/site/forum.py +0 -432
- scratchattach/site/project.py +0 -826
- scratchattach/site/session.py +0 -1238
- scratchattach/site/studio.py +0 -611
- scratchattach/site/user.py +0 -956
- scratchattach/utils/__init__.py +0 -0
- scratchattach/utils/commons.py +0 -255
- scratchattach/utils/encoder.py +0 -158
- scratchattach/utils/enums.py +0 -236
- scratchattach/utils/exceptions.py +0 -243
- scratchattach/utils/requests.py +0 -93
- scratchattach-2.1.15b0.dist-info/RECORD +0 -66
- {scratchattach-2.1.15b0.dist-info → scratchattach-3.0.0b0.dist-info}/licenses/LICENSE +0 -0
- {scratchattach-2.1.15b0.dist-info → scratchattach-3.0.0b0.dist-info}/top_level.txt +0 -0
scratchattach/editor/base.py
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Editor base classes
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
import copy
|
|
8
|
-
import json
|
|
9
|
-
from abc import ABC, abstractmethod
|
|
10
|
-
from io import TextIOWrapper
|
|
11
|
-
from typing import Optional, Any, TYPE_CHECKING, BinaryIO, Union
|
|
12
|
-
|
|
13
|
-
if TYPE_CHECKING:
|
|
14
|
-
from . import project, block, asset
|
|
15
|
-
from . import mutation as module_mutation
|
|
16
|
-
from . import sprite as module_sprite
|
|
17
|
-
from . import commons
|
|
18
|
-
|
|
19
|
-
from . import build_defaulting
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class Base(ABC):
|
|
23
|
-
"""
|
|
24
|
-
Abstract base class for most sa.editor classes. Implements copy functions
|
|
25
|
-
"""
|
|
26
|
-
def dcopy(self):
|
|
27
|
-
"""
|
|
28
|
-
:return: A **deep** copy of self
|
|
29
|
-
"""
|
|
30
|
-
return copy.deepcopy(self)
|
|
31
|
-
|
|
32
|
-
def copy(self):
|
|
33
|
-
"""
|
|
34
|
-
:return: A **shallow** copy of self
|
|
35
|
-
"""
|
|
36
|
-
return copy.copy(self)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class JSONSerializable(Base, ABC):
|
|
40
|
-
"""
|
|
41
|
-
'Interface' for to_json() and from_json() methods
|
|
42
|
-
Also implements save_json() using to_json()
|
|
43
|
-
"""
|
|
44
|
-
@staticmethod
|
|
45
|
-
@abstractmethod
|
|
46
|
-
def from_json(data):
|
|
47
|
-
pass
|
|
48
|
-
|
|
49
|
-
@abstractmethod
|
|
50
|
-
def to_json(self):
|
|
51
|
-
pass
|
|
52
|
-
|
|
53
|
-
def save_json(self, name: str = ''):
|
|
54
|
-
"""
|
|
55
|
-
Save a json file
|
|
56
|
-
"""
|
|
57
|
-
data = self.to_json()
|
|
58
|
-
with open(f"{self.__class__.__name__.lower()}{name}.json", "w") as f:
|
|
59
|
-
json.dump(data, f)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
class JSONExtractable(JSONSerializable, ABC):
|
|
63
|
-
"""
|
|
64
|
-
Interface for objects that can be loaded from zip archives containing json files (sprite/project)
|
|
65
|
-
Only has one method - load_json
|
|
66
|
-
"""
|
|
67
|
-
@staticmethod
|
|
68
|
-
@abstractmethod
|
|
69
|
-
def load_json(data: str | bytes | TextIOWrapper | BinaryIO, load_assets: bool = True, _name: Optional[str] = None) -> tuple[
|
|
70
|
-
str, list[asset.AssetFile], str]:
|
|
71
|
-
"""
|
|
72
|
-
Automatically extracts the JSON data as a string, as well as providing auto naming
|
|
73
|
-
:param data: Either a string of JSON, sb3 file as bytes or as a file object
|
|
74
|
-
:param load_assets: Whether to extract assets as well (if applicable)
|
|
75
|
-
:param _name: Any provided name (will automatically find one otherwise)
|
|
76
|
-
:return: tuple of the name, asset data & json as a string
|
|
77
|
-
"""
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class ProjectSubcomponent(JSONSerializable, ABC):
|
|
81
|
-
"""
|
|
82
|
-
Base class for any class with an associated project
|
|
83
|
-
"""
|
|
84
|
-
def __init__(self, _project: Optional[project.Project] = None):
|
|
85
|
-
self.project = _project
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class SpriteSubComponent(JSONSerializable, ABC):
|
|
89
|
-
"""
|
|
90
|
-
Base class for any class with an associated sprite
|
|
91
|
-
"""
|
|
92
|
-
sprite: module_sprite.Sprite
|
|
93
|
-
def __init__(self, _sprite: "commons.SpriteInput" = build_defaulting.SPRITE_DEFAULT):
|
|
94
|
-
if _sprite is build_defaulting.SPRITE_DEFAULT:
|
|
95
|
-
retrieved_sprite = build_defaulting.current_sprite()
|
|
96
|
-
assert retrieved_sprite is not None, "You don't have any sprites."
|
|
97
|
-
_sprite = retrieved_sprite
|
|
98
|
-
self.sprite = _sprite
|
|
99
|
-
|
|
100
|
-
@property
|
|
101
|
-
def project(self) -> project.Project:
|
|
102
|
-
"""
|
|
103
|
-
Get associated project by proxy of the associated sprite
|
|
104
|
-
"""
|
|
105
|
-
p = self.sprite.project
|
|
106
|
-
assert p is not None
|
|
107
|
-
return p
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
class IDComponent(SpriteSubComponent, ABC):
|
|
111
|
-
"""
|
|
112
|
-
Base class for classes with an id attribute
|
|
113
|
-
"""
|
|
114
|
-
def __init__(self, _id: str, _sprite: "commons.SpriteInput" = build_defaulting.SPRITE_DEFAULT):
|
|
115
|
-
self.id = _id
|
|
116
|
-
super().__init__(_sprite)
|
|
117
|
-
|
|
118
|
-
def __repr__(self):
|
|
119
|
-
return f"<{self.__class__.__name__}: {self.id}>"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
class NamedIDComponent(IDComponent, ABC):
|
|
123
|
-
"""
|
|
124
|
-
Base class for Variables, Lists and Broadcasts (Name + ID + sprite)
|
|
125
|
-
"""
|
|
126
|
-
def __init__(self, _id: str, name: str, _sprite: "commons.SpriteInput" = build_defaulting.SPRITE_DEFAULT):
|
|
127
|
-
self.name = name
|
|
128
|
-
super().__init__(_id, _sprite)
|
|
129
|
-
|
|
130
|
-
def __repr__(self):
|
|
131
|
-
return f"<{self.__class__.__name__} '{self.name}'>"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
class BlockSubComponent(JSONSerializable, ABC):
|
|
135
|
-
"""
|
|
136
|
-
Base class for classes with associated blocks
|
|
137
|
-
"""
|
|
138
|
-
def __init__(self, _block: Optional[block.Block] = None):
|
|
139
|
-
self.block = _block
|
|
140
|
-
|
|
141
|
-
@property
|
|
142
|
-
def sprite(self) -> module_sprite.Sprite:
|
|
143
|
-
"""
|
|
144
|
-
Fetch sprite by proxy of the block
|
|
145
|
-
"""
|
|
146
|
-
b = self.block
|
|
147
|
-
assert b is not None
|
|
148
|
-
return b.sprite
|
|
149
|
-
|
|
150
|
-
@property
|
|
151
|
-
def project(self) -> project.Project:
|
|
152
|
-
"""
|
|
153
|
-
Fetch project by proxy of the sprite (by proxy of the block)
|
|
154
|
-
"""
|
|
155
|
-
p = self.sprite.project
|
|
156
|
-
assert p is not None
|
|
157
|
-
return p
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
class MutationSubComponent(JSONSerializable, ABC):
|
|
161
|
-
"""
|
|
162
|
-
Base class for classes with associated mutations
|
|
163
|
-
"""
|
|
164
|
-
mutation: Optional[module_mutation.Mutation]
|
|
165
|
-
def __init__(self, _mutation: Optional[module_mutation.Mutation] = None):
|
|
166
|
-
self.mutation = _mutation
|
|
167
|
-
|
|
168
|
-
@property
|
|
169
|
-
def block(self) -> block.Block:
|
|
170
|
-
"""
|
|
171
|
-
Fetch block by proxy of mutation
|
|
172
|
-
"""
|
|
173
|
-
m = self.mutation
|
|
174
|
-
assert m is not None
|
|
175
|
-
b = m.block
|
|
176
|
-
assert b is not None
|
|
177
|
-
return b
|
|
178
|
-
|
|
179
|
-
@property
|
|
180
|
-
def sprite(self) -> module_sprite.Sprite:
|
|
181
|
-
"""
|
|
182
|
-
Fetch sprite by proxy of block (by proxy of mutation)
|
|
183
|
-
"""
|
|
184
|
-
return self.block.sprite
|
|
185
|
-
|
|
186
|
-
@property
|
|
187
|
-
def project(self) -> project.Project:
|
|
188
|
-
"""
|
|
189
|
-
Fetch project by proxy of sprite (by proxy of block (by proxy of mutation))
|
|
190
|
-
"""
|
|
191
|
-
p = self.sprite.project
|
|
192
|
-
assert p is not None
|
|
193
|
-
return p
|