scratchattach 2.1.10a2__py3-none-any.whl → 2.1.11__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/eventhandlers/cloud_requests.py +6 -4
- scratchattach/site/_base.py +3 -2
- scratchattach/site/project.py +0 -2
- scratchattach/site/user.py +13 -14
- {scratchattach-2.1.10a2.dist-info → scratchattach-2.1.11.dist-info}/METADATA +1 -1
- {scratchattach-2.1.10a2.dist-info → scratchattach-2.1.11.dist-info}/RECORD +9 -9
- {scratchattach-2.1.10a2.dist-info → scratchattach-2.1.11.dist-info}/WHEEL +1 -1
- {scratchattach-2.1.10a2.dist-info → scratchattach-2.1.11.dist-info}/licenses/LICENSE +0 -0
- {scratchattach-2.1.10a2.dist-info → scratchattach-2.1.11.dist-info}/top_level.txt +0 -0
|
@@ -23,7 +23,7 @@ class Request:
|
|
|
23
23
|
self.enabled = enabled
|
|
24
24
|
self.response_priority = response_priority
|
|
25
25
|
self.cloud_requests = cloud_requests # the corresponding CloudRequests object
|
|
26
|
-
self.debug = debug
|
|
26
|
+
self.debug = debug or self.cloud_requests.debug
|
|
27
27
|
|
|
28
28
|
def __call__(self, received_request):
|
|
29
29
|
if not self.enabled:
|
|
@@ -63,7 +63,7 @@ class CloudRequests(CloudEvents):
|
|
|
63
63
|
|
|
64
64
|
# The CloudRequests class is built upon CloudEvents, similar to how Filterbot is built upon MessageEvents
|
|
65
65
|
|
|
66
|
-
def __init__(self, cloud, used_cloud_vars=["1", "2", "3", "4", "5", "6", "7", "8", "9"], no_packet_loss=False, respond_order="receive"):
|
|
66
|
+
def __init__(self, cloud, used_cloud_vars=["1", "2", "3", "4", "5", "6", "7", "8", "9"], no_packet_loss=False, respond_order="receive", debug=False):
|
|
67
67
|
super().__init__(cloud)
|
|
68
68
|
# Setup
|
|
69
69
|
self._requests = {}
|
|
@@ -73,6 +73,7 @@ class CloudRequests(CloudEvents):
|
|
|
73
73
|
self.no_packet_loss = no_packet_loss # When enabled, query the clouddata log regularly for missed requests and reconnect after every single request (reduces packet loss a lot, but is spammy and can make response duration longer)
|
|
74
74
|
self.used_cloud_vars = used_cloud_vars
|
|
75
75
|
self.respond_order = respond_order
|
|
76
|
+
self.debug = debug
|
|
76
77
|
|
|
77
78
|
# Lists and dicts for saving request-related stuff
|
|
78
79
|
self.request_parts = {} # Dict (key: request_id) for saving the parts of the requests not fully received yet
|
|
@@ -99,7 +100,7 @@ class CloudRequests(CloudEvents):
|
|
|
99
100
|
|
|
100
101
|
# -- Adding and removing requests --
|
|
101
102
|
|
|
102
|
-
def request(self, function=None, *, enabled=True, name=None, thread=True, response_priority=0):
|
|
103
|
+
def request(self, function=None, *, enabled=True, name=None, thread=True, response_priority=0, debug=False):
|
|
103
104
|
"""
|
|
104
105
|
Decorator function. Adds a request to the request handler.
|
|
105
106
|
"""
|
|
@@ -113,7 +114,8 @@ class CloudRequests(CloudEvents):
|
|
|
113
114
|
thread=thread,
|
|
114
115
|
response_priority=response_priority,
|
|
115
116
|
on_call=function,
|
|
116
|
-
cloud_requests=self
|
|
117
|
+
cloud_requests=self,
|
|
118
|
+
debug=debug
|
|
117
119
|
)
|
|
118
120
|
|
|
119
121
|
if function is None:
|
scratchattach/site/_base.py
CHANGED
|
@@ -4,9 +4,10 @@ from abc import ABC, abstractmethod
|
|
|
4
4
|
|
|
5
5
|
import requests
|
|
6
6
|
from ..utils import exceptions, commons
|
|
7
|
+
from typing import TypeVar
|
|
7
8
|
from types import FunctionType
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
C = TypeVar("C", bound="BaseSiteComponent")
|
|
10
11
|
class BaseSiteComponent(ABC):
|
|
11
12
|
@abstractmethod
|
|
12
13
|
def __init__(self):
|
|
@@ -51,7 +52,7 @@ class BaseSiteComponent(ABC):
|
|
|
51
52
|
raise exceptions.Unauthenticated(
|
|
52
53
|
"You need to use session.connect_xyz (NOT get_xyz) in order to perform this operation.")
|
|
53
54
|
|
|
54
|
-
def _make_linked_object(self, identificator_id, identificator, Class, NotFoundException) ->
|
|
55
|
+
def _make_linked_object(self, identificator_id, identificator, Class: type[C], NotFoundException) -> C:
|
|
55
56
|
"""
|
|
56
57
|
Internal function for making a linked object (authentication kept) based on an identificator (like a project id or username)
|
|
57
58
|
Class must inherit from BaseSiteComponent
|
scratchattach/site/project.py
CHANGED
scratchattach/site/user.py
CHANGED
|
@@ -19,6 +19,17 @@ from . import activity
|
|
|
19
19
|
|
|
20
20
|
from ..utils.requests import Requests as requests
|
|
21
21
|
|
|
22
|
+
class Verificator:
|
|
23
|
+
|
|
24
|
+
def __init__(self, user: User, project_id: int):
|
|
25
|
+
self.project = user._make_linked_object("id", project_id, project.Project, exceptions.ProjectNotFound)
|
|
26
|
+
self.projecturl = self.project.url
|
|
27
|
+
self.code = ''.join(random.choices(string.ascii_letters + string.digits, k=8))
|
|
28
|
+
self.username = user.username
|
|
29
|
+
|
|
30
|
+
def check(self) -> bool:
|
|
31
|
+
return bool(list(filter(lambda x : x.author_name == self.username and (x.content == self.code or x.content.startswith(self.code) or x.content.endswith(self.code)), self.project.comments())))
|
|
32
|
+
|
|
22
33
|
class User(BaseSiteComponent):
|
|
23
34
|
|
|
24
35
|
'''
|
|
@@ -799,20 +810,8 @@ class User(BaseSiteComponent):
|
|
|
799
810
|
It will return True if the user commented the code.
|
|
800
811
|
"""
|
|
801
812
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
def __init__(self, user):
|
|
805
|
-
self.project = user._make_linked_object("id", verification_project_id, project.Project, exceptions.ProjectNotFound)
|
|
806
|
-
self.projecturl = self.project.url
|
|
807
|
-
self.code = ''.join(random.choices(string.ascii_letters + string.digits, k=130))
|
|
808
|
-
self.username = user.username
|
|
809
|
-
|
|
810
|
-
def check(self):
|
|
811
|
-
return list(filter(lambda x : x.author_name == self.username, self.project.comments())) != []
|
|
812
|
-
|
|
813
|
-
v = Verificator(self)
|
|
814
|
-
print(f"{self.username} has to go to {v.projecturl} and comment {v.code} to verify their identity")
|
|
815
|
-
return Verificator(self)
|
|
813
|
+
v = Verificator(self, verification_project_id)
|
|
814
|
+
return v
|
|
816
815
|
|
|
817
816
|
# ------ #
|
|
818
817
|
|
|
@@ -28,7 +28,7 @@ scratchattach/eventhandlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
28
28
|
scratchattach/eventhandlers/_base.py,sha256=8NjYF7qOEhjUFksA0qKg4XDH5aXgEG5PSVgMAYDbGD4,3078
|
|
29
29
|
scratchattach/eventhandlers/cloud_events.py,sha256=iaUFo58D5JUCHstch2VhmhqMPq8WX_xrzPelFMCFRF8,4084
|
|
30
30
|
scratchattach/eventhandlers/cloud_recorder.py,sha256=o4wcWJFCddpcSsPx5YU2DFFMFoKUknKM2RQ36HLpheQ,800
|
|
31
|
-
scratchattach/eventhandlers/cloud_requests.py,sha256=
|
|
31
|
+
scratchattach/eventhandlers/cloud_requests.py,sha256=jW3tLpfNmgsVuac5Y7vqx--qu1nQxytTV71Dx6ejGfU,22191
|
|
32
32
|
scratchattach/eventhandlers/cloud_server.py,sha256=tah77FTr1Kp4DWpux48w8pJNZQL_1qL0hAXaAXlzQ9Y,12266
|
|
33
33
|
scratchattach/eventhandlers/cloud_storage.py,sha256=9dvKPxbPZ_hBhw1HYlTl72YJmBo2OMwrSrMQ7kQwwOE,4660
|
|
34
34
|
scratchattach/eventhandlers/combine.py,sha256=2n5SC6tSpgrmmK04sqsm4eqx26O9haBKA5YgsWNIoso,895
|
|
@@ -38,7 +38,7 @@ scratchattach/other/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
38
38
|
scratchattach/other/other_apis.py,sha256=7EyB3uB-1AYAH7Nb6eZ3VmACGdXvEQ39NJ1iahUoy04,9059
|
|
39
39
|
scratchattach/other/project_json_capabilities.py,sha256=qSlJIJOgAxhSchD3fOIhK57rCe0_GrHadXBs5UXKuFU,22622
|
|
40
40
|
scratchattach/site/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
|
-
scratchattach/site/_base.py,sha256=
|
|
41
|
+
scratchattach/site/_base.py,sha256=S-ynYKe7LslZxaZzE0hZsga0eLB2XlQo5erAfKct8yc,2193
|
|
42
42
|
scratchattach/site/activity.py,sha256=a019lhoUwL9mdZI1Sz9mMg9EsDt2Lp5ziJSSDQ8-BWM,14319
|
|
43
43
|
scratchattach/site/backpack_asset.py,sha256=V_ypvTi-hqf0LF8zks2uHIicraBssc1_eEHVqHMzikc,3286
|
|
44
44
|
scratchattach/site/browser_cookies.py,sha256=aaYLawtifngZ0pgaXHjBiWvYHUfflS8ZcXRjTTrge3A,1566
|
|
@@ -46,18 +46,18 @@ scratchattach/site/classroom.py,sha256=WKMOcmYzKZx_EZNR4qipHOB8nxaggFe84lxqnrWd2
|
|
|
46
46
|
scratchattach/site/cloud_activity.py,sha256=ie_DhChicks_RBagMM6_GfFIi1iAxf6UtJ3VFXC8StM,4159
|
|
47
47
|
scratchattach/site/comment.py,sha256=Yt86iqwKZhCKNTEvB9DNDj9mXRV6A9qXyy1MrE7rMnA,8377
|
|
48
48
|
scratchattach/site/forum.py,sha256=BZ_2jqDW3o-22AG1vP9s1W7l9yBbjBkFqG_DGV9IDuA,14802
|
|
49
|
-
scratchattach/site/project.py,sha256=
|
|
49
|
+
scratchattach/site/project.py,sha256=_yMzacrTiy_LYfyEfWVeoHRHm5t9vBUr88eR_ULcK7Q,30931
|
|
50
50
|
scratchattach/site/session.py,sha256=mP4tTSZUs9dz0e3Zk6JF9RmSizFaYExbbEEYmA5TBnM,48278
|
|
51
51
|
scratchattach/site/studio.py,sha256=Tv7AY1TwvlQpR9VjUEs-qmavrZsLxchkXk59aoH0_EI,22918
|
|
52
|
-
scratchattach/site/user.py,sha256=
|
|
52
|
+
scratchattach/site/user.py,sha256=TCO1QRtPeJdb3p-ziCwa6NqObHSNP0DMmcOl5De-Yl8,34496
|
|
53
53
|
scratchattach/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
54
|
scratchattach/utils/commons.py,sha256=6yCfUvQlQbl2VPhxJiK1MSdBdXpBbkr5uYyB2LLIcdI,8155
|
|
55
55
|
scratchattach/utils/encoder.py,sha256=rqJfQ5gmjf7s8aTiGhR0W1ejYN5tHbAgJlxv7JhGqZQ,2479
|
|
56
56
|
scratchattach/utils/enums.py,sha256=93ylCrxWycunahISSIjBqTIJ2r1Hb2b9RMvvzmUiQ-c,8294
|
|
57
57
|
scratchattach/utils/exceptions.py,sha256=hrnPuXRRwR-kTHnrQVyfAD6PDOg1hZQd-jaXuUSNKSQ,6274
|
|
58
58
|
scratchattach/utils/requests.py,sha256=x_EfcbLdBpQQuH9g4MMSaM8RN3tUm9OtzPEJQQiwilY,2709
|
|
59
|
-
scratchattach-2.1.
|
|
60
|
-
scratchattach-2.1.
|
|
61
|
-
scratchattach-2.1.
|
|
62
|
-
scratchattach-2.1.
|
|
63
|
-
scratchattach-2.1.
|
|
59
|
+
scratchattach-2.1.11.dist-info/licenses/LICENSE,sha256=1PRKLhZU4wYt5M-C9f7q0W3go3u_ojnZMNOdR3g3J-E,1080
|
|
60
|
+
scratchattach-2.1.11.dist-info/METADATA,sha256=mC-Kltdsi4hFeQOpg44My3rIvG831mrvMJJdQGMLngY,5463
|
|
61
|
+
scratchattach-2.1.11.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
62
|
+
scratchattach-2.1.11.dist-info/top_level.txt,sha256=gIwCwW39ohXn0JlnvSzAjV7VtL3qPlRnHiRqBbxsEUE,14
|
|
63
|
+
scratchattach-2.1.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|