scratchattach 2.1.14__py3-none-any.whl → 2.1.15b0__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.
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
 
6
6
  # Perhaps this should be merged with pallete.py
7
7
  from dataclasses import dataclass
8
- from typing import Final
8
+ from typing import Final, Literal
9
9
 
10
10
  from . import commons
11
11
  from scratchattach.utils.enums import _EnumWrapper
@@ -20,7 +20,7 @@ class _MutationDependent(commons.Singleton):
20
20
  raise TypeError("Need mutation data to work out attribute value.")
21
21
 
22
22
 
23
- MUTATION_DEPENDENT: Final[_MutationDependent] = _MutationDependent()
23
+ MUTATION_DEPENDENT: Final[Literal[_MutationDependent]] = _MutationDependent.INSTANCE
24
24
  """Value used when mutation data is required to work out the attribute value"""
25
25
 
26
26
 
@@ -269,38 +269,5 @@ class SingletonMeta(EnumMeta):
269
269
  self.__bases__ = old_bases
270
270
  return result
271
271
 
272
+ Singleton = Enum
272
273
 
273
- if TYPE_CHECKING:
274
- Singleton = Enum
275
- else:
276
- class Singleton(metaclass=SingletonMeta):
277
-
278
- def __new__(cls, val=None):
279
- if cls is Singleton:
280
- raise TypeError("Singleton cannot be created directly.")
281
- if hasattr(cls, "INSTANCE"):
282
- return getattr(cls, "INSTANCE")
283
- if val == 0:
284
- return super().__new__(cls)
285
- raise TypeError("Has no instance.")
286
-
287
- def __init__(self, *args, **kwds):
288
- pass
289
-
290
- def __repr__(self):
291
- return self.__class__.__name__
292
-
293
- def __str__(self):
294
- return self.__class__.__name__
295
-
296
- def __format__(self, format_spec):
297
- return str.__format__(str(self), format_spec)
298
-
299
- def __hash__(self):
300
- return hash(self.__class__)
301
-
302
- def __reduce_ex__(self, proto):
303
- return self.__class__, ()
304
-
305
- def __deepcopy__(self, memo):
306
- return self
@@ -243,7 +243,7 @@ class Project(PartialProject):
243
243
  # Overrides the load_description method that exists for unshared projects
244
244
  self.update()
245
245
 
246
- def download(self, *, filename=None, dir=""):
246
+ def download(self, *, filename=None, dir="."):
247
247
  """
248
248
  Downloads the project json to the given directory.
249
249
 
@@ -255,14 +255,15 @@ class Project(PartialProject):
255
255
  if filename is None:
256
256
  filename = str(self.id)
257
257
  if not (dir.endswith("/") or dir.endswith("\\")):
258
- dir = dir+"/"
258
+ dir += "/"
259
259
  self.update()
260
260
  response = requests.get(
261
261
  f"https://projects.scratch.mit.edu/{self.id}?token={self.project_token}",
262
262
  timeout=10,
263
263
  )
264
- filename = filename.replace(".sb3", "")
265
- open(f"{dir}{filename}.sb3", "wb").write(response.content)
264
+ filename = filename.removesuffix(".sb3")
265
+ with open(f"{dir}{filename}.sb3", "wb") as f:
266
+ f.write(response.content)
266
267
  except Exception:
267
268
  raise (
268
269
  exceptions.FetchError(
@@ -46,7 +46,7 @@ def enforce_ratelimit(__type: str, name: str, amount: int = 5, duration: int = 6
46
46
  cache = ratelimit_cache
47
47
  cache.setdefault(__type, [])
48
48
  uses = cache[__type]
49
- while uses[-1] < time.time() - duration:
49
+ while uses and uses[-1] < time.time() - duration:
50
50
  uses.pop()
51
51
  if len(uses) < amount:
52
52
  uses.insert(0, time.time())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scratchattach
3
- Version: 2.1.14
3
+ Version: 2.1.15b0
4
4
  Summary: A Scratch API Wrapper
5
5
  Author: TimMcCool
6
6
  Author-email:
@@ -7,10 +7,10 @@ scratchattach/editor/asset.py,sha256=8rQmaZCO4tMjnohutfvVha2t5x_ct2Rxn_Q9Dz6DCYI
7
7
  scratchattach/editor/backpack_json.py,sha256=PZGNIFNf0MS3hn8cKZEp9ZeQWdBE-xWq5PEwiN8IzWM,3900
8
8
  scratchattach/editor/base.py,sha256=AP_JktO6NLxpsh00twnKHkXmzLmATFabfmw1tmWh98c,5412
9
9
  scratchattach/editor/block.py,sha256=B7II4ICOLxdN_D_rn3LH4njRmkZLisxcPzg4WAyNIXA,18786
10
- scratchattach/editor/blockshape.py,sha256=DN9aKjd22OdvS4ulThJPFGq9uBAA8DNGwnq5Dv2cLNo,25284
10
+ scratchattach/editor/blockshape.py,sha256=luSl0AKBdkJH_TW_9RhJBiwtRny9_r3DKE99mPmMh9c,25309
11
11
  scratchattach/editor/build_defaulting.py,sha256=BkD81lTaR1LTv8HwwkxGtQ040G2Y6mh1R6fCZIkfkYM,1386
12
12
  scratchattach/editor/comment.py,sha256=G_eFxeaC_vKbCFpDfw4oZxIReUBoBUaCA5q35O-AW6Y,2403
13
- scratchattach/editor/commons.py,sha256=RWynsm3LhPMRRbcFd2kT_CRgsvPx6uvKyK3ISYpNoDg,7638
13
+ scratchattach/editor/commons.py,sha256=ghUuTo_1ATVxeqon5RtErbh5rcxsXwHESTBVhUjeiHY,6698
14
14
  scratchattach/editor/extension.py,sha256=PFVl5SrS66M4Md98I_dsfeL9BLeWwvyWezmhnTRseIQ,1541
15
15
  scratchattach/editor/field.py,sha256=3JUBwj-Mun36Yb7KDeQIWZcuj0e4kjkVAwk_9cKfQPY,3002
16
16
  scratchattach/editor/inputs.py,sha256=JGFKry9m8IHNw9zoyM6iViEbPp1VlHlVPI9fYoiTk3M,4391
@@ -49,8 +49,8 @@ scratchattach/site/classroom.py,sha256=2IDLDljEDLp8Vj5ab94Ti_VVBCv8OPS7qNVr1zFBC
49
49
  scratchattach/site/cloud_activity.py,sha256=x0kbd9Zx1dI4s0lJXWNixQCJeKG1CchXK-9867RiK1A,4207
50
50
  scratchattach/site/comment.py,sha256=733CDTV7227MxrhRM0dQYF06aDbHVFK-_rECz--grvA,9135
51
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
52
+ scratchattach/site/project.py,sha256=kPbAppWTl9QG61C0DXN7MBM5DyjJacY8ooCctyBlHp0,31630
53
+ scratchattach/site/session.py,sha256=XwEr4IF-Ei1nl-ZiMi-CGdV3Q8N7txLDlRDOESDE8zE,50877
54
54
  scratchattach/site/studio.py,sha256=a20fzNq2GGN0SbyC7_d6UqmCqDgofZjdiMucp9KHnYE,22942
55
55
  scratchattach/site/user.py,sha256=v6cLI1t465DHTT2xuWd-pXThL1QPDT7GGDcXgOBxaLE,39483
56
56
  scratchattach/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -59,8 +59,8 @@ scratchattach/utils/encoder.py,sha256=rqJfQ5gmjf7s8aTiGhR0W1ejYN5tHbAgJlxv7JhGqZ
59
59
  scratchattach/utils/enums.py,sha256=GFLI3F0ZWGqicKV_QJwhyz4MiPDdstAJaUBxYDYT9to,11091
60
60
  scratchattach/utils/exceptions.py,sha256=AyM9lU009irxaJvMPB0N0kQaVAJeWHjlmQIS6Njgo78,6528
61
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,,
62
+ scratchattach-2.1.15b0.dist-info/licenses/LICENSE,sha256=1PRKLhZU4wYt5M-C9f7q0W3go3u_ojnZMNOdR3g3J-E,1080
63
+ scratchattach-2.1.15b0.dist-info/METADATA,sha256=ZW7mfiegAGFMu035-K0uhYTUQAs8bQaNdMJggcqd0eQ,5689
64
+ scratchattach-2.1.15b0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
65
+ scratchattach-2.1.15b0.dist-info/top_level.txt,sha256=gIwCwW39ohXn0JlnvSzAjV7VtL3qPlRnHiRqBbxsEUE,14
66
+ scratchattach-2.1.15b0.dist-info/RECORD,,