xcpcio 0.74.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.74.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
@@ -82,11 +82,11 @@ class Image(BaseModel):
82
82
  base64: Optional[str] = None
83
83
  type: Optional[Literal["png", "svg", "jpg", "jpeg"]] = None
84
84
 
85
- preset: Optional[ImagePreset] = None
86
-
87
85
  width: Optional[int] = None
88
86
  height: Optional[int] = None
89
87
 
88
+ preset: Optional[ImagePreset] = None
89
+
90
90
 
91
91
  class DataItem(BaseModel):
92
92
  url: UrlString
@@ -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):
@@ -151,6 +153,7 @@ class Submission(BaseModel):
151
153
  is_ignore: Optional[bool] = None
152
154
 
153
155
  reaction: Optional[SubmissionReaction] = None
156
+ missing_reaction: Optional[bool] = None
154
157
 
155
158
 
156
159
  class Submissions(RootModel[List[Submission]]):
@@ -161,7 +164,7 @@ class Team(BaseModel):
161
164
  id: str = ""
162
165
  name: Text = ""
163
166
 
164
- organization: str = ""
167
+ organization: Optional[str] = None
165
168
  organization_id: Optional[str] = None
166
169
 
167
170
  group: List[str] = Field(default_factory=list)
@@ -178,6 +181,8 @@ class Team(BaseModel):
178
181
  location: Optional[str] = None
179
182
  icpc_id: Optional[str] = None
180
183
 
184
+ ip: Optional[str] = None
185
+
181
186
  extra: Dict[str, Any] = Field(default_factory=dict, exclude=True)
182
187
 
183
188
  def add_group(self, group: str):
@@ -194,6 +199,7 @@ class Teams(RootModel[List[Team]]):
194
199
 
195
200
 
196
201
  class ContestOptions(BaseModel):
202
+ enable_organization: Optional[bool] = None
197
203
  calculation_of_penalty: Optional[CalculationOfPenalty] = None
198
204
  submission_timestamp_unit: Optional[TimeUnit] = None
199
205
 
@@ -201,10 +207,20 @@ class ContestOptions(BaseModel):
201
207
  reaction_video_url_template: Optional[str] = None
202
208
 
203
209
  team_photo_url_template: Optional[Image] = None
210
+ team_webcam_stream_url_template: Optional[str] = None
211
+ team_screen_stream_url_template: Optional[str] = None
212
+
213
+ submission_external_url_template: Optional[str] = None
214
+ submission_source_code_url_template: Optional[str] = None
215
+
216
+ realtime_reaction_webcam_stream_url_template: Optional[str] = None
217
+ realtime_reaction_screen_stream_url_template: Optional[str] = None
204
218
 
205
219
 
206
220
  class Contest(BaseModel):
207
221
  contest_name: Text = ""
222
+ description: Optional[Text] = None
223
+ og_image: Optional[Image] = None
208
224
 
209
225
  start_time: Union[int, DateTimeISO8601String] = 0
210
226
  end_time: Union[int, DateTimeISO8601String] = 0
@@ -220,9 +236,6 @@ class Contest(BaseModel):
220
236
 
221
237
  status_time_display: Dict[str, bool] = constants.FULL_STATUS_TIME_DISPLAY
222
238
 
223
- badge: Optional[str] = None
224
- organization: str = "School"
225
-
226
239
  medal: Optional[Union[Dict[str, Dict[str, int]], MedalPreset]] = None
227
240
 
228
241
  group: Optional[Dict[str, str]] = None
@@ -231,14 +244,14 @@ class Contest(BaseModel):
231
244
  logo: Optional[Image] = None
232
245
  banner: Optional[Image] = None
233
246
  banner_mode: Optional[BannerMode] = None
234
- board_link: Optional[str] = None
235
-
236
- version: Optional[str] = None
237
247
 
238
248
  options: Optional[ContestOptions] = None
239
249
 
240
250
  organizations: Optional[Union[DataItem, Organizations]] = None
241
251
 
252
+ board_link: Optional[str] = None
253
+ version: Optional[str] = None
254
+
242
255
  thaw_time: int = Field(default=0x3F3F3F3F3F3F3F3F, exclude=True)
243
256
 
244
257
  def append_balloon_color(self, color: BalloonColor):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xcpcio
3
- Version: 0.74.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=9-FaWjjQZglZF5o70uDxsdSHL9D21XYjVh1N9mugIgw,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=CLhRp_HaVbK9YK8yNOHDNDIis8XOAo5BWz5lZS-qbvw,7927
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.74.1.dist-info/METADATA,sha256=61srz0S3luEblVIB91bq7JoIHs2jrdD-UkDfKBA8L9c,2237
46
- xcpcio-0.74.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
- xcpcio-0.74.1.dist-info/entry_points.txt,sha256=KxviS5TVXlZ9KqS9UNMx3nI15xhEGvkTq86RaPhUhs4,158
48
- xcpcio-0.74.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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any