xcpcio 0.77.1__py3-none-any.whl → 0.82.1__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.
xcpcio/__version__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is auto-generated by Hatchling. As such, do not:
2
2
  # - modify
3
3
  # - track in version control e.g. be sure to add to .gitignore
4
- __version__ = VERSION = '0.77.1'
4
+ __version__ = VERSION = '0.82.1'
@@ -1,5 +1,6 @@
1
1
  from dataclasses import dataclass
2
2
  from pathlib import Path
3
+ from typing import Optional
3
4
 
4
5
 
5
6
  @dataclass
@@ -7,3 +8,12 @@ class FileAttr:
7
8
  path: Path
8
9
  media_type: str
9
10
  name: str
11
+
12
+
13
+ @dataclass
14
+ class Image:
15
+ base64: str
16
+
17
+ mime_type: Optional[str] = None
18
+ width: Optional[int] = None
19
+ height: Optional[int] = None
@@ -1,3 +1,4 @@
1
+ import base64
1
2
  import bisect
2
3
  import json
3
4
  import logging
@@ -7,12 +8,20 @@ from typing import Any, Dict, List, Optional, Union
7
8
 
8
9
  from fastapi import HTTPException
9
10
 
10
- from xcpcio.clics.base.types import FileAttr
11
+ from xcpcio.clics.base.types import FileAttr, Image
11
12
  from xcpcio.clics.reader.interface import BaseContestReader
12
13
 
13
14
  logger = logging.getLogger(__name__)
14
15
 
15
16
 
17
+ def image_to_base64(image_path: Path):
18
+ with open(image_path, "rb") as image_file:
19
+ binary_data = image_file.read()
20
+ base64_bytes = base64.b64encode(binary_data)
21
+ base64_string = base64_bytes.decode("utf-8")
22
+ return base64_string
23
+
24
+
16
25
  class ContestPackageReader(BaseContestReader):
17
26
  def __init__(self, contest_package_dir: Path):
18
27
  self.contest_package_dir = contest_package_dir
@@ -239,6 +248,19 @@ class ContestPackageReader(BaseContestReader):
239
248
  detail=f"Organization logo not found. [contest_id={self.contest_id}] [organization_id={organization_id}] [err={e}]",
240
249
  )
241
250
 
251
+ def get_organization_logo_image(self, organization_id: str) -> Optional[Image]:
252
+ org_list = self.get_organization(organization_id).get("logo", [])
253
+ if len(org_list) == 0:
254
+ return None
255
+
256
+ org: Dict = org_list[0]
257
+ return Image(
258
+ base64=image_to_base64(self.contest_package_dir / f"organizations/{organization_id}/{org['filename']}"),
259
+ mime_type=str(org.get("mime")),
260
+ width=int(org.get("width")),
261
+ height=int(org.get("height")),
262
+ )
263
+
242
264
  # Group operations
243
265
  def get_groups(self) -> List[Dict[str, Any]]:
244
266
  return self.groups
@@ -1,7 +1,7 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from typing import Any, Dict, List, Optional
3
3
 
4
- from xcpcio.clics.base.types import FileAttr
4
+ from xcpcio.clics.base.types import FileAttr, Image
5
5
 
6
6
 
7
7
  class BaseContestReader(ABC):
@@ -83,6 +83,10 @@ class BaseContestReader(ABC):
83
83
  def get_organization_logo(self, organization_id: str) -> FileAttr:
84
84
  pass
85
85
 
86
+ @abstractmethod
87
+ def get_organization_logo_image(self, organization_id: str) -> Optional[Image]:
88
+ pass
89
+
86
90
  # Group operations
87
91
  @abstractmethod
88
92
  def get_groups(self) -> List[Dict[str, Any]]:
xcpcio/types.py CHANGED
@@ -98,9 +98,11 @@ class Organization(BaseModel):
98
98
  name: Text
99
99
 
100
100
  logo: Optional[Image] = None
101
+ icpc_id: Optional[str] = None
101
102
 
102
103
 
103
- Organizations = List[Organization]
104
+ class Organizations(RootModel[List[Organization]]):
105
+ pass
104
106
 
105
107
 
106
108
  class BalloonColor(BaseModel):
@@ -162,7 +164,7 @@ class Team(BaseModel):
162
164
  id: str = ""
163
165
  name: Text = ""
164
166
 
165
- organization: str = ""
167
+ organization: Optional[str] = None
166
168
  organization_id: Optional[str] = None
167
169
 
168
170
  group: List[str] = Field(default_factory=list)
@@ -197,6 +199,7 @@ class Teams(RootModel[List[Team]]):
197
199
 
198
200
 
199
201
  class ContestOptions(BaseModel):
202
+ enable_organization: Optional[bool] = None
200
203
  calculation_of_penalty: Optional[CalculationOfPenalty] = None
201
204
  submission_timestamp_unit: Optional[TimeUnit] = None
202
205
 
@@ -207,8 +210,12 @@ class ContestOptions(BaseModel):
207
210
  team_webcam_stream_url_template: Optional[str] = None
208
211
  team_screen_stream_url_template: Optional[str] = None
209
212
 
213
+ submission_external_url_template: Optional[str] = None
210
214
  submission_source_code_url_template: Optional[str] = None
211
215
 
216
+ realtime_reaction_webcam_stream_url_template: Optional[str] = None
217
+ realtime_reaction_screen_stream_url_template: Optional[str] = None
218
+
212
219
 
213
220
  class Contest(BaseModel):
214
221
  contest_name: Text = ""
@@ -229,9 +236,6 @@ class Contest(BaseModel):
229
236
 
230
237
  status_time_display: Dict[str, bool] = constants.FULL_STATUS_TIME_DISPLAY
231
238
 
232
- badge: Optional[str] = None
233
- organization: str = "School"
234
-
235
239
  medal: Optional[Union[Dict[str, Dict[str, int]], MedalPreset]] = None
236
240
 
237
241
  group: Optional[Dict[str, str]] = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xcpcio
3
- Version: 0.77.1
3
+ Version: 0.82.1
4
4
  Summary: xcpcio python lib
5
5
  Project-URL: homepage, https://github.com/xcpcio/xcpcio
6
6
  Project-URL: documentation, https://github.com/xcpcio/xcpcio
@@ -1,7 +1,7 @@
1
1
  xcpcio/__init__.py,sha256=NB6wpVr5JUrOx2vLIQSVtYuCz0d7kNFE39TSQlvoENk,125
2
- xcpcio/__version__.py,sha256=cegZjbArInW0-hiNKHPa3iiHIzx--Z32kVElNSSS5uE,172
2
+ xcpcio/__version__.py,sha256=UDXTg6gwUXRTSIg8RWbAOyIKL3Rf_Z37L8tollwF_Bc,172
3
3
  xcpcio/constants.py,sha256=MjpAgNXiBlUsx1S09m7JNT-nekNDR-aE6ggvGL3fg0I,2297
4
- xcpcio/types.py,sha256=JYt4-KwNp95cKJUyCtJI-2EYJ1rcdGelZb8OVUbQ6n0,8256
4
+ xcpcio/types.py,sha256=Eemic_dUJo2TfMCOh6rerOk-SmXSTI978fQp42ut4hQ,8511
5
5
  xcpcio/api/__init__.py,sha256=fFRUU0d_cUG-uzG2rLgirqRng8Z3UoV5ZCkBiYuXdu0,302
6
6
  xcpcio/api/client.py,sha256=TEcf3tjLu537HHhyBBVHlQ3fFL7_abjG3IrQtp39oks,2389
7
7
  xcpcio/api/models.py,sha256=DBS9TjtPSX32TpwO3gYnnGo7RFHLHrxYpRIAhxCHmLs,1258
@@ -35,14 +35,14 @@ xcpcio/clics/api_server/routes/teams.py,sha256=euDs-GDHLqmJS3zPTNxm9LfKXQYEuhwAl
35
35
  xcpcio/clics/api_server/services/__init__.py,sha256=yQqrH72olLFG9KEivWNYmaIES_vi8mnzZGX2frdB5cQ,177
36
36
  xcpcio/clics/api_server/services/contest_service.py,sha256=1vnt9NB0ZOKJjjParbudHrpnC8_kQRFVuOVxNVR9Drs,7477
37
37
  xcpcio/clics/base/__init__.py,sha256=JYKVtcQG-VGM2OfCg6VhxcXCeCp7r2zxpg_7s9AThS0,39
38
- xcpcio/clics/base/types.py,sha256=NfAG-XJjex7p2DfFTRecLWhmwpeO8Ul42nNMnZH39sM,137
38
+ xcpcio/clics/base/types.py,sha256=pWCdrZFu7GhGv6fgsJkrbiWoVQ6PNgjZWvjbTpb-LH8,309
39
39
  xcpcio/clics/model/__init__.py,sha256=cZE1q5JY-iHDEKZpsx0UZaMhH-23H4oAHaYOkW7dZ5s,43
40
40
  xcpcio/clics/model/model_2023_06/__init__.py,sha256=VzBaFcAwYw9G18p0Lh7rNPrvchyaYx_jgw6YE4W1yNg,168
41
41
  xcpcio/clics/model/model_2023_06/model.py,sha256=bVMDWpJTwPSpz1fHPxWrWerxCBIboH3LKVZpIZGQ2pY,15287
42
42
  xcpcio/clics/reader/__init__.py,sha256=Nfi78X8J1tJPh7WeSRPLMRUprlS2JYelYJHW4DfyJ7U,162
43
- xcpcio/clics/reader/contest_package_reader.py,sha256=W9pNAl6Za1LXG_OjDYj-szVPXczeHBUhL-ajOApL7BU,15089
44
- xcpcio/clics/reader/interface.py,sha256=lK2JXU1n8GJ4PecXnfFBijMaCVLYk404e4QwV_Ti2Hk,3918
45
- xcpcio-0.77.1.dist-info/METADATA,sha256=7vdgPvt58AvtthUt4MLs3wtK00OCDOrVJbPQ4LSdvbk,2237
46
- xcpcio-0.77.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
47
- xcpcio-0.77.1.dist-info/entry_points.txt,sha256=KxviS5TVXlZ9KqS9UNMx3nI15xhEGvkTq86RaPhUhs4,158
48
- xcpcio-0.77.1.dist-info/RECORD,,
43
+ xcpcio/clics/reader/contest_package_reader.py,sha256=o6NOMdwTCzmkomChZl7hkdPLgKFqXFAYeG73EfStQRM,15897
44
+ xcpcio/clics/reader/interface.py,sha256=OAV_OaBVRXWf5FBq-mwhPpqVMWVZmaldJzUP_s259nY,4043
45
+ xcpcio-0.82.1.dist-info/METADATA,sha256=fg9H5ttYsSptfOpGD7M63_v9iksywO4cYCLYRQeV0pY,2237
46
+ xcpcio-0.82.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
47
+ xcpcio-0.82.1.dist-info/entry_points.txt,sha256=KxviS5TVXlZ9KqS9UNMx3nI15xhEGvkTq86RaPhUhs4,158
48
+ xcpcio-0.82.1.dist-info/RECORD,,