scratchattach 2.1.13__py3-none-any.whl → 2.1.14__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/cloud/_base.py +12 -8
- scratchattach/cloud/cloud.py +19 -7
- scratchattach/editor/asset.py +59 -5
- scratchattach/editor/base.py +82 -31
- scratchattach/editor/block.py +86 -15
- scratchattach/editor/blockshape.py +8 -4
- scratchattach/editor/build_defaulting.py +6 -2
- scratchattach/editor/code_translation/__init__.py +0 -0
- scratchattach/editor/code_translation/parse.py +177 -0
- scratchattach/editor/comment.py +6 -0
- scratchattach/editor/commons.py +82 -19
- scratchattach/editor/extension.py +10 -3
- scratchattach/editor/field.py +9 -0
- scratchattach/editor/inputs.py +4 -1
- scratchattach/editor/meta.py +11 -3
- scratchattach/editor/monitor.py +46 -38
- scratchattach/editor/mutation.py +11 -4
- scratchattach/editor/pallete.py +24 -25
- scratchattach/editor/prim.py +2 -2
- scratchattach/editor/project.py +9 -3
- scratchattach/editor/sprite.py +19 -6
- scratchattach/editor/twconfig.py +2 -1
- scratchattach/editor/vlb.py +1 -1
- scratchattach/eventhandlers/_base.py +2 -2
- scratchattach/eventhandlers/cloud_events.py +2 -2
- scratchattach/eventhandlers/cloud_requests.py +3 -3
- scratchattach/eventhandlers/cloud_server.py +3 -3
- scratchattach/eventhandlers/message_events.py +1 -1
- scratchattach/other/other_apis.py +4 -4
- scratchattach/other/project_json_capabilities.py +3 -3
- scratchattach/site/_base.py +13 -12
- scratchattach/site/activity.py +11 -43
- scratchattach/site/alert.py +227 -0
- scratchattach/site/backpack_asset.py +2 -2
- scratchattach/site/browser_cookie3_stub.py +17 -0
- scratchattach/site/browser_cookies.py +27 -21
- scratchattach/site/classroom.py +51 -34
- scratchattach/site/cloud_activity.py +4 -4
- scratchattach/site/comment.py +30 -8
- scratchattach/site/forum.py +101 -69
- scratchattach/site/project.py +37 -17
- scratchattach/site/session.py +169 -79
- scratchattach/site/studio.py +4 -4
- scratchattach/site/user.py +179 -64
- scratchattach/utils/commons.py +35 -23
- scratchattach/utils/enums.py +44 -5
- scratchattach/utils/exceptions.py +10 -0
- scratchattach/utils/requests.py +57 -31
- {scratchattach-2.1.13.dist-info → scratchattach-2.1.14.dist-info}/METADATA +8 -3
- scratchattach-2.1.14.dist-info/RECORD +66 -0
- {scratchattach-2.1.13.dist-info → scratchattach-2.1.14.dist-info}/WHEEL +1 -1
- scratchattach/editor/sbuild.py +0 -2837
- scratchattach-2.1.13.dist-info/RECORD +0 -63
- {scratchattach-2.1.13.dist-info → scratchattach-2.1.14.dist-info}/licenses/LICENSE +0 -0
- {scratchattach-2.1.13.dist-info → scratchattach-2.1.14.dist-info}/top_level.txt +0 -0
scratchattach/utils/requests.py
CHANGED
|
@@ -1,67 +1,93 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
from
|
|
3
|
+
from collections.abc import MutableMapping, Iterator
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from contextlib import contextmanager
|
|
6
|
+
|
|
7
|
+
from typing_extensions import override
|
|
8
|
+
from requests import Session as HTTPSession
|
|
9
|
+
from requests import Response
|
|
5
10
|
|
|
6
|
-
|
|
11
|
+
from . import exceptions
|
|
7
12
|
|
|
13
|
+
proxies: Optional[MutableMapping[str, str]] = None
|
|
8
14
|
|
|
9
|
-
class Requests:
|
|
15
|
+
class Requests(HTTPSession):
|
|
10
16
|
"""
|
|
11
17
|
Centralized HTTP request handler (for better error handling and proxies)
|
|
12
18
|
"""
|
|
19
|
+
error_handling: bool = True
|
|
13
20
|
|
|
14
|
-
|
|
15
|
-
def check_response(r: requests.Response):
|
|
21
|
+
def check_response(self, r: Response):
|
|
16
22
|
if r.status_code == 403 or r.status_code == 401:
|
|
17
|
-
raise exceptions.Unauthorized(f"Request content: {r.content}")
|
|
23
|
+
raise exceptions.Unauthorized(f"Request content: {r.content!r}")
|
|
18
24
|
if r.status_code == 500:
|
|
19
25
|
raise exceptions.APIError("Internal Scratch server error")
|
|
20
26
|
if r.status_code == 429:
|
|
21
27
|
raise exceptions.Response429("You are being rate-limited (or blocked) by Scratch")
|
|
22
|
-
if r.
|
|
23
|
-
raise exceptions.BadRequest("Make sure all provided arguments are valid")
|
|
24
|
-
if r.text == '{"code":"BadRequest","message":""}':
|
|
28
|
+
if r.json() == {"code":"BadRequest","message":""}:
|
|
25
29
|
raise exceptions.BadRequest("Make sure all provided arguments are valid")
|
|
26
30
|
|
|
27
|
-
@
|
|
28
|
-
def get(
|
|
31
|
+
@override
|
|
32
|
+
def get(self, *args, **kwargs):
|
|
33
|
+
kwargs.setdefault("proxies", proxies)
|
|
29
34
|
try:
|
|
30
|
-
r =
|
|
31
|
-
timeout=timeout, proxies=proxies)
|
|
35
|
+
r = super().get(*args, **kwargs)
|
|
32
36
|
except Exception as e:
|
|
33
37
|
raise exceptions.FetchError(e)
|
|
34
|
-
|
|
38
|
+
if self.error_handling:
|
|
39
|
+
self.check_response(r)
|
|
35
40
|
return r
|
|
36
41
|
|
|
37
|
-
@
|
|
38
|
-
def post(
|
|
42
|
+
@override
|
|
43
|
+
def post(self, *args, **kwargs):
|
|
44
|
+
kwargs.setdefault("proxies", proxies)
|
|
39
45
|
try:
|
|
40
|
-
r =
|
|
41
|
-
timeout=timeout, proxies=proxies, files=files)
|
|
46
|
+
r = super().post(*args, **kwargs)
|
|
42
47
|
except Exception as e:
|
|
43
48
|
raise exceptions.FetchError(e)
|
|
44
|
-
if
|
|
45
|
-
|
|
49
|
+
if self.error_handling:
|
|
50
|
+
self.check_response(r)
|
|
46
51
|
return r
|
|
47
52
|
|
|
48
|
-
@
|
|
49
|
-
def delete(
|
|
53
|
+
@override
|
|
54
|
+
def delete(self, *args, **kwargs):
|
|
55
|
+
kwargs.setdefault("proxies", proxies)
|
|
50
56
|
try:
|
|
51
|
-
r =
|
|
52
|
-
timeout=timeout, proxies=proxies)
|
|
57
|
+
r = super().delete(*args, **kwargs)
|
|
53
58
|
except Exception as e:
|
|
54
59
|
raise exceptions.FetchError(e)
|
|
55
|
-
|
|
60
|
+
if self.error_handling:
|
|
61
|
+
self.check_response(r)
|
|
56
62
|
return r
|
|
57
63
|
|
|
58
|
-
@
|
|
59
|
-
def put(
|
|
64
|
+
@override
|
|
65
|
+
def put(self, *args, **kwargs):
|
|
66
|
+
kwargs.setdefault("proxies", proxies)
|
|
60
67
|
try:
|
|
61
|
-
r =
|
|
62
|
-
timeout=timeout, proxies=proxies)
|
|
68
|
+
r = super().put(*args, **kwargs)
|
|
63
69
|
except Exception as e:
|
|
64
70
|
raise exceptions.FetchError(e)
|
|
65
|
-
|
|
71
|
+
if self.error_handling:
|
|
72
|
+
self.check_response(r)
|
|
66
73
|
return r
|
|
74
|
+
|
|
75
|
+
@contextmanager
|
|
76
|
+
def no_error_handling(self) -> Iterator[None]:
|
|
77
|
+
val_before = self.error_handling
|
|
78
|
+
self.error_handling = False
|
|
79
|
+
try:
|
|
80
|
+
yield
|
|
81
|
+
finally:
|
|
82
|
+
self.error_handling = val_before
|
|
83
|
+
|
|
84
|
+
@contextmanager
|
|
85
|
+
def yes_error_handling(self) -> Iterator[None]:
|
|
86
|
+
val_before = self.error_handling
|
|
87
|
+
self.error_handling = True
|
|
88
|
+
try:
|
|
89
|
+
yield
|
|
90
|
+
finally:
|
|
91
|
+
self.error_handling = val_before
|
|
67
92
|
|
|
93
|
+
requests = Requests()
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scratchattach
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.14
|
|
4
4
|
Summary: A Scratch API Wrapper
|
|
5
|
-
Home-page: https://scratchattach.tim1de.net
|
|
6
5
|
Author: TimMcCool
|
|
7
6
|
Author-email:
|
|
7
|
+
Project-URL: Source, https://github.com/timmccool/scratchattach
|
|
8
|
+
Project-URL: Homepage, https://scratchattach.tim1de.net
|
|
8
9
|
Keywords: scratch api,scratchattach,scratch api python,scratch python,scratch for python,scratch,scratch cloud,scratch cloud variables,scratch bot
|
|
9
10
|
Classifier: Development Status :: 5 - Production/Stable
|
|
10
11
|
Classifier: Intended Audience :: Developers
|
|
@@ -19,13 +20,17 @@ Requires-Dist: requests
|
|
|
19
20
|
Requires-Dist: bs4
|
|
20
21
|
Requires-Dist: SimpleWebSocketServer
|
|
21
22
|
Requires-Dist: typing-extensions
|
|
23
|
+
Requires-Dist: browser_cookie3
|
|
24
|
+
Provides-Extra: lark
|
|
25
|
+
Requires-Dist: lark; extra == "lark"
|
|
22
26
|
Dynamic: author
|
|
23
27
|
Dynamic: classifier
|
|
24
28
|
Dynamic: description
|
|
25
29
|
Dynamic: description-content-type
|
|
26
|
-
Dynamic: home-page
|
|
27
30
|
Dynamic: keywords
|
|
28
31
|
Dynamic: license-file
|
|
32
|
+
Dynamic: project-url
|
|
33
|
+
Dynamic: provides-extra
|
|
29
34
|
Dynamic: requires-dist
|
|
30
35
|
Dynamic: summary
|
|
31
36
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
scratchattach/__init__.py,sha256=2iiV0SghFUyJJrJYt668cSoDrxSjLCWNtzMdhttnMdA,1532
|
|
2
|
+
scratchattach/cloud/__init__.py,sha256=MN7s4grQcciqUO7TiFjTbU2sC69m6XXlwOHNRbN3FKo,41
|
|
3
|
+
scratchattach/cloud/_base.py,sha256=wQDBIjrEtGSleKnAghluvZGX1L7U0wpUry_3MD8-VkY,18060
|
|
4
|
+
scratchattach/cloud/cloud.py,sha256=f3qGy7rhpyuhOlVfki3l8FdMpyFtcVTBg9ql6l0J-jI,8167
|
|
5
|
+
scratchattach/editor/__init__.py,sha256=gfTQrtyQ-oZJBanp-5eNae72cwm4WoKHzNtZ4rn1dqg,727
|
|
6
|
+
scratchattach/editor/asset.py,sha256=8rQmaZCO4tMjnohutfvVha2t5x_ct2Rxn_Q9Dz6DCYI,7734
|
|
7
|
+
scratchattach/editor/backpack_json.py,sha256=PZGNIFNf0MS3hn8cKZEp9ZeQWdBE-xWq5PEwiN8IzWM,3900
|
|
8
|
+
scratchattach/editor/base.py,sha256=AP_JktO6NLxpsh00twnKHkXmzLmATFabfmw1tmWh98c,5412
|
|
9
|
+
scratchattach/editor/block.py,sha256=B7II4ICOLxdN_D_rn3LH4njRmkZLisxcPzg4WAyNIXA,18786
|
|
10
|
+
scratchattach/editor/blockshape.py,sha256=DN9aKjd22OdvS4ulThJPFGq9uBAA8DNGwnq5Dv2cLNo,25284
|
|
11
|
+
scratchattach/editor/build_defaulting.py,sha256=BkD81lTaR1LTv8HwwkxGtQ040G2Y6mh1R6fCZIkfkYM,1386
|
|
12
|
+
scratchattach/editor/comment.py,sha256=G_eFxeaC_vKbCFpDfw4oZxIReUBoBUaCA5q35O-AW6Y,2403
|
|
13
|
+
scratchattach/editor/commons.py,sha256=RWynsm3LhPMRRbcFd2kT_CRgsvPx6uvKyK3ISYpNoDg,7638
|
|
14
|
+
scratchattach/editor/extension.py,sha256=PFVl5SrS66M4Md98I_dsfeL9BLeWwvyWezmhnTRseIQ,1541
|
|
15
|
+
scratchattach/editor/field.py,sha256=3JUBwj-Mun36Yb7KDeQIWZcuj0e4kjkVAwk_9cKfQPY,3002
|
|
16
|
+
scratchattach/editor/inputs.py,sha256=JGFKry9m8IHNw9zoyM6iViEbPp1VlHlVPI9fYoiTk3M,4391
|
|
17
|
+
scratchattach/editor/meta.py,sha256=aTP5Imz2cFI_RDA4Lufa5UV64lgk3-TP3B4fd7t0zio,3202
|
|
18
|
+
scratchattach/editor/monitor.py,sha256=q-RrycEpYa3rHZ0_9RZobIS8Sfbmpx7_cdUFEaoA7Yk,5788
|
|
19
|
+
scratchattach/editor/mutation.py,sha256=NKLVae0A6J0CKl1Xm7jpdNNoyGFtwcmU-LiBfYpvtlU,10399
|
|
20
|
+
scratchattach/editor/pallete.py,sha256=-CbTRHsgpiVomal1ohW0ouuSP-hCsPTApgRohfxRPfI,2348
|
|
21
|
+
scratchattach/editor/prim.py,sha256=WAXMQ5C5FYIk-gNLwH1cnhsMQJpxH0yl_YH0Tcju9IU,5877
|
|
22
|
+
scratchattach/editor/project.py,sha256=D6gtmfGu0y3_Wzyhq-bjPRzVERFGH_b1DCUVHS9HBtY,9138
|
|
23
|
+
scratchattach/editor/sprite.py,sha256=BG8--SNvj2HYre3pGKEpvnq2Qpl3h_qDseKxIxfWL38,20862
|
|
24
|
+
scratchattach/editor/twconfig.py,sha256=iE6ylAsZzniAfhL09GkZSFn1XacYtCQPzRCUSPIBzDA,3324
|
|
25
|
+
scratchattach/editor/vlb.py,sha256=ZUlrA52ZoK5znGkBUw10UGejpvBlpkH635pTl9sUAmM,4170
|
|
26
|
+
scratchattach/editor/code_translation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
scratchattach/editor/code_translation/parse.py,sha256=FjuHVg_tNzkGcGSNwgH6MzAHcf5YCvaEUSYukyJkwbk,4932
|
|
28
|
+
scratchattach/eventhandlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
+
scratchattach/eventhandlers/_base.py,sha256=XGsGzsmUBy5IV3Cl0akEmwBsaSyfVNs0YbNS7lktxrw,3099
|
|
30
|
+
scratchattach/eventhandlers/cloud_events.py,sha256=B0Ce0y8HKP2fOJ3zIUdJg8tHGYoGpc42e4ktuLL_bRw,4108
|
|
31
|
+
scratchattach/eventhandlers/cloud_recorder.py,sha256=o4wcWJFCddpcSsPx5YU2DFFMFoKUknKM2RQ36HLpheQ,800
|
|
32
|
+
scratchattach/eventhandlers/cloud_requests.py,sha256=B_ybgcQ3S861KUNIYv3kOc0siO8BP1Ez57zE1GypTJg,22121
|
|
33
|
+
scratchattach/eventhandlers/cloud_server.py,sha256=rgY0lcXO-E_iAu4oVvbshIfG7eMw0Ekz4_GOLTxCzmM,12302
|
|
34
|
+
scratchattach/eventhandlers/cloud_storage.py,sha256=9dvKPxbPZ_hBhw1HYlTl72YJmBo2OMwrSrMQ7kQwwOE,4660
|
|
35
|
+
scratchattach/eventhandlers/combine.py,sha256=YiWI6WI1BySioXpfYaMv8noBM14EjZa7dtsJsMTshEU,894
|
|
36
|
+
scratchattach/eventhandlers/filterbot.py,sha256=RvGCm-2iaC8SAC4nDMlDv0MPp80CsRr4CFGmnIuEfg8,7462
|
|
37
|
+
scratchattach/eventhandlers/message_events.py,sha256=KvznXAeNGk1WWCxd7PI95yovX-58TyCBNDdXbrYgb8Q,1776
|
|
38
|
+
scratchattach/other/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
|
+
scratchattach/other/other_apis.py,sha256=iJXytVgAIARWQ_z7t99Lv2oB6DdwrFBmkFxiaHQRKLI,9095
|
|
40
|
+
scratchattach/other/project_json_capabilities.py,sha256=07t1iMgWm4Qd06jHyQ3vK7tROguvc2RQCo78enrdSlA,22646
|
|
41
|
+
scratchattach/site/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
|
+
scratchattach/site/_base.py,sha256=v2U0V-2T5QnDGtUDVPR1e4qg9R7rpNYmO8YKA5fIXfg,2249
|
|
43
|
+
scratchattach/site/activity.py,sha256=4fohsjeVJFaMnKE6_Ew8DcDpFfDzwPeZ7XGp5NnCMW8,13786
|
|
44
|
+
scratchattach/site/alert.py,sha256=TX_Py5L7IKmXEPFGIOFIGvqlT8aSigywsR5nODkvwFY,9277
|
|
45
|
+
scratchattach/site/backpack_asset.py,sha256=8AKvDTvaTvN2ntqE3Ygkl0mvu6-ZR-DbLkCszv2h70o,3298
|
|
46
|
+
scratchattach/site/browser_cookie3_stub.py,sha256=codk0knOP5C0YThaRazvqsqX7X7WnrD2UwFd1nFG7mg,1422
|
|
47
|
+
scratchattach/site/browser_cookies.py,sha256=uQyjJJ4HCu46R4tPWCcTUqDMXSXhQ4KQUobqCSxScSA,1864
|
|
48
|
+
scratchattach/site/classroom.py,sha256=2IDLDljEDLp8Vj5ab94Ti_VVBCv8OPS7qNVr1zFBCME,16884
|
|
49
|
+
scratchattach/site/cloud_activity.py,sha256=x0kbd9Zx1dI4s0lJXWNixQCJeKG1CchXK-9867RiK1A,4207
|
|
50
|
+
scratchattach/site/comment.py,sha256=733CDTV7227MxrhRM0dQYF06aDbHVFK-_rECz--grvA,9135
|
|
51
|
+
scratchattach/site/forum.py,sha256=Y7sh3-wcEjRBfKEHOcusudSudCJFe4MuQFd-EB4FccQ,16417
|
|
52
|
+
scratchattach/site/project.py,sha256=jc6NpzCdC4ATTfCvsAKWlRqj-cTv_B7ZnWHxOn2-qyI,31602
|
|
53
|
+
scratchattach/site/session.py,sha256=SQd6om7jxTrmQ5BjFrwGucYAWaBspn24rVunnepf760,50868
|
|
54
|
+
scratchattach/site/studio.py,sha256=a20fzNq2GGN0SbyC7_d6UqmCqDgofZjdiMucp9KHnYE,22942
|
|
55
|
+
scratchattach/site/user.py,sha256=v6cLI1t465DHTT2xuWd-pXThL1QPDT7GGDcXgOBxaLE,39483
|
|
56
|
+
scratchattach/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
|
+
scratchattach/utils/commons.py,sha256=BKH-zz2A5e1d5qEtvZvAmK5fXyVq-FGRRw3Wx-StG5E,8213
|
|
58
|
+
scratchattach/utils/encoder.py,sha256=rqJfQ5gmjf7s8aTiGhR0W1ejYN5tHbAgJlxv7JhGqZQ,2479
|
|
59
|
+
scratchattach/utils/enums.py,sha256=GFLI3F0ZWGqicKV_QJwhyz4MiPDdstAJaUBxYDYT9to,11091
|
|
60
|
+
scratchattach/utils/exceptions.py,sha256=AyM9lU009irxaJvMPB0N0kQaVAJeWHjlmQIS6Njgo78,6528
|
|
61
|
+
scratchattach/utils/requests.py,sha256=vf7OaASbC9_qp4ygOGcU2PjWvf7dwgGbsluZiKGyRMg,2832
|
|
62
|
+
scratchattach-2.1.14.dist-info/licenses/LICENSE,sha256=1PRKLhZU4wYt5M-C9f7q0W3go3u_ojnZMNOdR3g3J-E,1080
|
|
63
|
+
scratchattach-2.1.14.dist-info/METADATA,sha256=gFk55C4GbrDmgPuq7qfJel_qezQF5jtydFt8T_zO_co,5687
|
|
64
|
+
scratchattach-2.1.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
65
|
+
scratchattach-2.1.14.dist-info/top_level.txt,sha256=gIwCwW39ohXn0JlnvSzAjV7VtL3qPlRnHiRqBbxsEUE,14
|
|
66
|
+
scratchattach-2.1.14.dist-info/RECORD,,
|