icpc-api 0.1.0__tar.gz

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.
Files changed (83) hide show
  1. icpc_api-0.1.0/LICENSE +21 -0
  2. icpc_api-0.1.0/MANIFEST.in +2 -0
  3. icpc_api-0.1.0/PKG-INFO +143 -0
  4. icpc_api-0.1.0/README.md +109 -0
  5. icpc_api-0.1.0/THIRD-PARTY-LICENSES.md +220 -0
  6. icpc_api-0.1.0/icpc/__init__.py +32 -0
  7. icpc_api-0.1.0/icpc/api/__init__.py +18 -0
  8. icpc_api-0.1.0/icpc/api/common.py +97 -0
  9. icpc_api-0.1.0/icpc/api/contest.py +253 -0
  10. icpc_api-0.1.0/icpc/api/person.py +139 -0
  11. icpc_api-0.1.0/icpc/api/public.py +65 -0
  12. icpc_api-0.1.0/icpc/api/staff.py +83 -0
  13. icpc_api-0.1.0/icpc/api/team.py +335 -0
  14. icpc_api-0.1.0/icpc/auth/__init__.py +28 -0
  15. icpc_api-0.1.0/icpc/auth/cognito.py +142 -0
  16. icpc_api-0.1.0/icpc/auth/flows.py +314 -0
  17. icpc_api-0.1.0/icpc/auth/provider.py +29 -0
  18. icpc_api-0.1.0/icpc/auth/srp.py +185 -0
  19. icpc_api-0.1.0/icpc/auth/store.py +223 -0
  20. icpc_api-0.1.0/icpc/auth/tokens.py +86 -0
  21. icpc_api-0.1.0/icpc/cli/__init__.py +20 -0
  22. icpc_api-0.1.0/icpc/cli/columns.py +555 -0
  23. icpc_api-0.1.0/icpc/cli/main.py +1156 -0
  24. icpc_api-0.1.0/icpc/cli/render.py +160 -0
  25. icpc_api-0.1.0/icpc/config.py +57 -0
  26. icpc_api-0.1.0/icpc/errors.py +159 -0
  27. icpc_api-0.1.0/icpc/facade/__init__.py +6 -0
  28. icpc_api-0.1.0/icpc/facade/client.py +606 -0
  29. icpc_api-0.1.0/icpc/facade/domain.py +198 -0
  30. icpc_api-0.1.0/icpc/models/__init__.py +60 -0
  31. icpc_api-0.1.0/icpc/models/_generated.py +566 -0
  32. icpc_api-0.1.0/icpc/models/base.py +41 -0
  33. icpc_api-0.1.0/icpc/models/blobs.py +81 -0
  34. icpc_api-0.1.0/icpc/models/common.py +61 -0
  35. icpc_api-0.1.0/icpc/models/entities.py +522 -0
  36. icpc_api-0.1.0/icpc/models/enums.py +192 -0
  37. icpc_api-0.1.0/icpc/models/mixins.py +44 -0
  38. icpc_api-0.1.0/icpc/py.typed +0 -0
  39. icpc_api-0.1.0/icpc/search/__init__.py +99 -0
  40. icpc_api-0.1.0/icpc/search/_generated.py +1814 -0
  41. icpc_api-0.1.0/icpc/search/dsl.py +124 -0
  42. icpc_api-0.1.0/icpc/search/endpoint.py +173 -0
  43. icpc_api-0.1.0/icpc/search/fields.py +59 -0
  44. icpc_api-0.1.0/icpc/transport/__init__.py +29 -0
  45. icpc_api-0.1.0/icpc/transport/_shared.py +121 -0
  46. icpc_api-0.1.0/icpc/transport/async_client.py +120 -0
  47. icpc_api-0.1.0/icpc/transport/operation.py +139 -0
  48. icpc_api-0.1.0/icpc/transport/sync_client.py +121 -0
  49. icpc_api-0.1.0/icpc_api.egg-info/PKG-INFO +143 -0
  50. icpc_api-0.1.0/icpc_api.egg-info/SOURCES.txt +81 -0
  51. icpc_api-0.1.0/icpc_api.egg-info/dependency_links.txt +1 -0
  52. icpc_api-0.1.0/icpc_api.egg-info/entry_points.txt +2 -0
  53. icpc_api-0.1.0/icpc_api.egg-info/requires.txt +6 -0
  54. icpc_api-0.1.0/icpc_api.egg-info/top_level.txt +1 -0
  55. icpc_api-0.1.0/pyproject.toml +101 -0
  56. icpc_api-0.1.0/setup.cfg +4 -0
  57. icpc_api-0.1.0/tests/__init__.py +0 -0
  58. icpc_api-0.1.0/tests/__pycache__/__init__.cpython-312.pyc +0 -0
  59. icpc_api-0.1.0/tests/unit/__init__.py +0 -0
  60. icpc_api-0.1.0/tests/unit/__pycache__/__init__.cpython-312.pyc +0 -0
  61. icpc_api-0.1.0/tests/unit/__pycache__/test_auth.cpython-312-pytest-9.1.1.pyc +0 -0
  62. icpc_api-0.1.0/tests/unit/__pycache__/test_columns.cpython-312-pytest-9.1.1.pyc +0 -0
  63. icpc_api-0.1.0/tests/unit/__pycache__/test_dsl.cpython-312-pytest-9.1.1.pyc +0 -0
  64. icpc_api-0.1.0/tests/unit/__pycache__/test_join.cpython-312-pytest-9.1.1.pyc +0 -0
  65. icpc_api-0.1.0/tests/unit/__pycache__/test_models.cpython-312-pytest-9.1.1.pyc +0 -0
  66. icpc_api-0.1.0/tests/unit/__pycache__/test_paging.cpython-312-pytest-9.1.1.pyc +0 -0
  67. icpc_api-0.1.0/tests/unit/__pycache__/test_reference.cpython-312-pytest-9.1.1.pyc +0 -0
  68. icpc_api-0.1.0/tests/unit/__pycache__/test_srp.cpython-312-pytest-9.1.1.pyc +0 -0
  69. icpc_api-0.1.0/tests/unit/__pycache__/test_transport.cpython-312-pytest-9.1.1.pyc +0 -0
  70. icpc_api-0.1.0/tests/unit/__pycache__/test_transport_parity.cpython-312-pytest-9.1.1.pyc +0 -0
  71. icpc_api-0.1.0/tests/unit/__pycache__/test_typing.cpython-312-pytest-9.1.1.pyc +0 -0
  72. icpc_api-0.1.0/tests/unit/test_auth.py +391 -0
  73. icpc_api-0.1.0/tests/unit/test_columns.py +314 -0
  74. icpc_api-0.1.0/tests/unit/test_dsl.py +71 -0
  75. icpc_api-0.1.0/tests/unit/test_join.py +85 -0
  76. icpc_api-0.1.0/tests/unit/test_models.py +100 -0
  77. icpc_api-0.1.0/tests/unit/test_paging.py +161 -0
  78. icpc_api-0.1.0/tests/unit/test_reference.py +97 -0
  79. icpc_api-0.1.0/tests/unit/test_srp.py +183 -0
  80. icpc_api-0.1.0/tests/unit/test_transport.py +232 -0
  81. icpc_api-0.1.0/tests/unit/test_transport_parity.py +60 -0
  82. icpc_api-0.1.0/tests/unit/test_typing.py +58 -0
  83. icpc_api-0.1.0/uv.lock +504 -0
icpc_api-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nikita Sychev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ graft tests
2
+ include uv.lock
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: icpc-api
3
+ Version: 0.1.0
4
+ Summary: Unofficial Python client and CLI for the icpc.global API
5
+ Author-email: Nikita Sychev <root@nsychev.ru>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/nsychev/icpc-api
8
+ Project-URL: Repository, https://github.com/nsychev/icpc-api
9
+ Project-URL: Issues, https://github.com/nsychev/icpc-api/issues
10
+ Project-URL: Documentation, https://github.com/nsychev/icpc-api/tree/master/docs
11
+ Keywords: icpc,api,client,sdk
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Internet :: WWW/HTTP
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.12
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ License-File: THIRD-PARTY-LICENSES.md
28
+ Requires-Dist: httpx>=0.28
29
+ Requires-Dist: pydantic>=2.9
30
+ Provides-Extra: cli
31
+ Requires-Dist: typer>=0.15; extra == "cli"
32
+ Requires-Dist: rich>=13; extra == "cli"
33
+ Dynamic: license-file
34
+
35
+ # icpc-api
36
+
37
+ An unofficial Python client and CLI for [icpc.global](https://icpc.global) API.
38
+ Supports authentication and customizable search over contest data.
39
+
40
+ **Note:** This project is aimed for regional contest organizers. If you want to
41
+ compete, please [use Regional Finder](https://icpc.global/regionals/finder) to
42
+ find nearest regional competition to you and its schedule.
43
+
44
+ ## Install
45
+
46
+ Use Python 3.12+ and [uv](https://github.com/astral-sh/uv).
47
+
48
+ ```bash
49
+ # add library to your project
50
+ uv add icpc-api
51
+
52
+ # run your script that uses `import icpc`
53
+ uv run --with icpc-api script.py
54
+
55
+ # install CLI into PATH
56
+ uv tool install 'icpc-api[cli]'
57
+ ```
58
+
59
+ If you don't have `uv`, feel free to use `pip` or any other convenient Python package manager.
60
+
61
+ ## Quick start
62
+
63
+ CLI:
64
+
65
+ ```bash
66
+ icpc auth login
67
+ icpc whoami
68
+ icpc contest teams 1234 --status ACCEPTED
69
+ icpc search teams 1234 --proj id,name,status --sort name:asc -o csv > teams.csv
70
+ ```
71
+
72
+ Python synchronous API:
73
+
74
+ ```python
75
+ from icpc import Icpc
76
+ from icpc.search import contest_teams
77
+ from icpc.models import TeamStatus
78
+
79
+ with Icpc.from_store() as icpc:
80
+ # Use DSL to build the request
81
+ teams = contest_teams(1234)
82
+ f = teams.fields
83
+ q = teams.query(
84
+ proj=[f.id.name, f.name.name, f.inst_short_name.name],
85
+ filters=[f.status.eq(TeamStatus.ACCEPTED)],
86
+ sort=[f.name.asc()],
87
+ )
88
+ # `icpc.all` executes search request
89
+ for row in icpc.all(teams, q):
90
+ print(row.id, row.name, row.inst_short_name)
91
+ ```
92
+
93
+ Python asynchronous API:
94
+
95
+ ```python
96
+ import asyncio
97
+ from icpc import AsyncIcpc, Include
98
+
99
+
100
+ async def main() -> None:
101
+ async with AsyncIcpc.from_store() as icpc:
102
+ view = await icpc.load_contest(1234, Include.DEFAULT)
103
+ for team in view.teams:
104
+ print(team.name, len(team.contestants), team.institution.inst_name)
105
+
106
+
107
+ asyncio.run(main())
108
+ ```
109
+
110
+ `load_contest` is the unified search: it fetches the team, team-member, institution
111
+ and contest tables concurrently, then joins them — teams indexed by id, rosters
112
+ bucketed by team, institutions attached by `instId`, participants by `personId`, and
113
+ the JSON-in-a-string `teamMembers` and `extraField` columns parsed into real objects.
114
+
115
+ ## Authentication
116
+
117
+ ```python
118
+ Icpc.from_password("me@example.com", "…") # SRP login
119
+ Icpc.from_store() # use `icpc auth login` to authenticate
120
+ Icpc.from_token("eyJ…") # a borrowed id token from localStorage
121
+ Icpc.anonymous() # /contest/public/* only
122
+ ```
123
+
124
+ When using store, token and credentials are written to `~/.config/icpc/credentials.json`.
125
+ You can also use `ICPC_USERNAME` and `ICPC_PASSWORD` or `ICPC_ID_TOKEN` environment
126
+ variables. ID Token is valid only for one hour.
127
+
128
+ ## Documentation
129
+
130
+ Read detailed guides on how to use:
131
+
132
+ - [Python API](docs/api.md) — guide, with worked examples
133
+ - [CLI](docs/cli.md) — every command, with worked examples
134
+ - [API reference](docs/reference.md) — every endpoint this client wraps
135
+
136
+ ## Development
137
+
138
+ ```bash
139
+ uv sync --extra cli
140
+ uv run pytest
141
+ uv run ruff check . && uv run ruff format --check .
142
+ uv run ty check icpc tests
143
+ ```
@@ -0,0 +1,109 @@
1
+ # icpc-api
2
+
3
+ An unofficial Python client and CLI for [icpc.global](https://icpc.global) API.
4
+ Supports authentication and customizable search over contest data.
5
+
6
+ **Note:** This project is aimed for regional contest organizers. If you want to
7
+ compete, please [use Regional Finder](https://icpc.global/regionals/finder) to
8
+ find nearest regional competition to you and its schedule.
9
+
10
+ ## Install
11
+
12
+ Use Python 3.12+ and [uv](https://github.com/astral-sh/uv).
13
+
14
+ ```bash
15
+ # add library to your project
16
+ uv add icpc-api
17
+
18
+ # run your script that uses `import icpc`
19
+ uv run --with icpc-api script.py
20
+
21
+ # install CLI into PATH
22
+ uv tool install 'icpc-api[cli]'
23
+ ```
24
+
25
+ If you don't have `uv`, feel free to use `pip` or any other convenient Python package manager.
26
+
27
+ ## Quick start
28
+
29
+ CLI:
30
+
31
+ ```bash
32
+ icpc auth login
33
+ icpc whoami
34
+ icpc contest teams 1234 --status ACCEPTED
35
+ icpc search teams 1234 --proj id,name,status --sort name:asc -o csv > teams.csv
36
+ ```
37
+
38
+ Python synchronous API:
39
+
40
+ ```python
41
+ from icpc import Icpc
42
+ from icpc.search import contest_teams
43
+ from icpc.models import TeamStatus
44
+
45
+ with Icpc.from_store() as icpc:
46
+ # Use DSL to build the request
47
+ teams = contest_teams(1234)
48
+ f = teams.fields
49
+ q = teams.query(
50
+ proj=[f.id.name, f.name.name, f.inst_short_name.name],
51
+ filters=[f.status.eq(TeamStatus.ACCEPTED)],
52
+ sort=[f.name.asc()],
53
+ )
54
+ # `icpc.all` executes search request
55
+ for row in icpc.all(teams, q):
56
+ print(row.id, row.name, row.inst_short_name)
57
+ ```
58
+
59
+ Python asynchronous API:
60
+
61
+ ```python
62
+ import asyncio
63
+ from icpc import AsyncIcpc, Include
64
+
65
+
66
+ async def main() -> None:
67
+ async with AsyncIcpc.from_store() as icpc:
68
+ view = await icpc.load_contest(1234, Include.DEFAULT)
69
+ for team in view.teams:
70
+ print(team.name, len(team.contestants), team.institution.inst_name)
71
+
72
+
73
+ asyncio.run(main())
74
+ ```
75
+
76
+ `load_contest` is the unified search: it fetches the team, team-member, institution
77
+ and contest tables concurrently, then joins them — teams indexed by id, rosters
78
+ bucketed by team, institutions attached by `instId`, participants by `personId`, and
79
+ the JSON-in-a-string `teamMembers` and `extraField` columns parsed into real objects.
80
+
81
+ ## Authentication
82
+
83
+ ```python
84
+ Icpc.from_password("me@example.com", "…") # SRP login
85
+ Icpc.from_store() # use `icpc auth login` to authenticate
86
+ Icpc.from_token("eyJ…") # a borrowed id token from localStorage
87
+ Icpc.anonymous() # /contest/public/* only
88
+ ```
89
+
90
+ When using store, token and credentials are written to `~/.config/icpc/credentials.json`.
91
+ You can also use `ICPC_USERNAME` and `ICPC_PASSWORD` or `ICPC_ID_TOKEN` environment
92
+ variables. ID Token is valid only for one hour.
93
+
94
+ ## Documentation
95
+
96
+ Read detailed guides on how to use:
97
+
98
+ - [Python API](docs/api.md) — guide, with worked examples
99
+ - [CLI](docs/cli.md) — every command, with worked examples
100
+ - [API reference](docs/reference.md) — every endpoint this client wraps
101
+
102
+ ## Development
103
+
104
+ ```bash
105
+ uv sync --extra cli
106
+ uv run pytest
107
+ uv run ruff check . && uv run ruff format --check .
108
+ uv run ty check icpc tests
109
+ ```
@@ -0,0 +1,220 @@
1
+ # Third-Party Licenses
2
+
3
+ ## `icpc/auth/srp.py`
4
+
5
+ ### warrant
6
+
7
+ https://github.com/capless/warrant
8
+
9
+ Copyright (c) Capless.io, Apache License, Version 2.0
10
+
11
+ ### amplify-js
12
+
13
+ https://github.com/aws-amplify/amplify-js
14
+
15
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved, Apache License, Version 2.0
16
+
17
+ ```
18
+
19
+ Apache License
20
+ Version 2.0, January 2004
21
+ http://www.apache.org/licenses/
22
+
23
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
24
+
25
+ 1. Definitions.
26
+
27
+ "License" shall mean the terms and conditions for use, reproduction,
28
+ and distribution as defined by Sections 1 through 9 of this document.
29
+
30
+ "Licensor" shall mean the copyright owner or entity authorized by
31
+ the copyright owner that is granting the License.
32
+
33
+ "Legal Entity" shall mean the union of the acting entity and all
34
+ other entities that control, are controlled by, or are under common
35
+ control with that entity. For the purposes of this definition,
36
+ "control" means (i) the power, direct or indirect, to cause the
37
+ direction or management of such entity, whether by contract or
38
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
39
+ outstanding shares, or (iii) beneficial ownership of such entity.
40
+
41
+ "You" (or "Your") shall mean an individual or Legal Entity
42
+ exercising permissions granted by this License.
43
+
44
+ "Source" form shall mean the preferred form for making modifications,
45
+ including but not limited to software source code, documentation
46
+ source, and configuration files.
47
+
48
+ "Object" form shall mean any form resulting from mechanical
49
+ transformation or translation of a Source form, including but
50
+ not limited to compiled object code, generated documentation,
51
+ and conversions to other media types.
52
+
53
+ "Work" shall mean the work of authorship, whether in Source or
54
+ Object form, made available under the License, as indicated by a
55
+ copyright notice that is included in or attached to the work
56
+ (an example is provided in the Appendix below).
57
+
58
+ "Derivative Works" shall mean any work, whether in Source or Object
59
+ form, that is based on (or derived from) the Work and for which the
60
+ editorial revisions, annotations, elaborations, or other modifications
61
+ represent, as a whole, an original work of authorship. For the purposes
62
+ of this License, Derivative Works shall not include works that remain
63
+ separable from, or merely link (or bind by name) to the interfaces of,
64
+ the Work and Derivative Works thereof.
65
+
66
+ "Contribution" shall mean any work of authorship, including
67
+ the original version of the Work and any modifications or additions
68
+ to that Work or Derivative Works thereof, that is intentionally
69
+ submitted to Licensor for inclusion in the Work by the copyright owner
70
+ or by an individual or Legal Entity authorized to submit on behalf of
71
+ the copyright owner. For the purposes of this definition, "submitted"
72
+ means any form of electronic, verbal, or written communication sent
73
+ to the Licensor or its representatives, including but not limited to
74
+ communication on electronic mailing lists, source code control systems,
75
+ and issue tracking systems that are managed by, or on behalf of, the
76
+ Licensor for the purpose of discussing and improving the Work, but
77
+ excluding communication that is conspicuously marked or otherwise
78
+ designated in writing by the copyright owner as "Not a Contribution."
79
+
80
+ "Contributor" shall mean Licensor and any individual or Legal Entity
81
+ on behalf of whom a Contribution has been received by Licensor and
82
+ subsequently incorporated within the Work.
83
+
84
+ 2. Grant of Copyright License. Subject to the terms and conditions of
85
+ this License, each Contributor hereby grants to You a perpetual,
86
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
87
+ copyright license to reproduce, prepare Derivative Works of,
88
+ publicly display, publicly perform, sublicense, and distribute the
89
+ Work and such Derivative Works in Source or Object form.
90
+
91
+ 3. Grant of Patent License. Subject to the terms and conditions of
92
+ this License, each Contributor hereby grants to You a perpetual,
93
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
94
+ (except as stated in this section) patent license to make, have made,
95
+ use, offer to sell, sell, import, and otherwise transfer the Work,
96
+ where such license applies only to those patent claims licensable
97
+ by such Contributor that are necessarily infringed by their
98
+ Contribution(s) alone or by combination of their Contribution(s)
99
+ with the Work to which such Contribution(s) was submitted. If You
100
+ institute patent litigation against any entity (including a
101
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
102
+ or a Contribution incorporated within the Work constitutes direct
103
+ or contributory patent infringement, then any patent licenses
104
+ granted to You under this License for that Work shall terminate
105
+ as of the date such litigation is filed.
106
+
107
+ 4. Redistribution. You may reproduce and distribute copies of the
108
+ Work or Derivative Works thereof in any medium, with or without
109
+ modifications, and in Source or Object form, provided that You
110
+ meet the following conditions:
111
+
112
+ (a) You must give any other recipients of the Work or
113
+ Derivative Works a copy of this License; and
114
+
115
+ (b) You must cause any modified files to carry prominent notices
116
+ stating that You changed the files; and
117
+
118
+ (c) You must retain, in the Source form of any Derivative Works
119
+ that You distribute, all copyright, patent, trademark, and
120
+ attribution notices from the Source form of the Work,
121
+ excluding those notices that do not pertain to any part of
122
+ the Derivative Works; and
123
+
124
+ (d) If the Work includes a "NOTICE" text file as part of its
125
+ distribution, then any Derivative Works that You distribute must
126
+ include a readable copy of the attribution notices contained
127
+ within such NOTICE file, excluding those notices that do not
128
+ pertain to any part of the Derivative Works, in at least one
129
+ of the following places: within a NOTICE text file distributed
130
+ as part of the Derivative Works; within the Source form or
131
+ documentation, if provided along with the Derivative Works; or,
132
+ within a display generated by the Derivative Works, if and
133
+ wherever such third-party notices normally appear. The contents
134
+ of the NOTICE file are for informational purposes only and
135
+ do not modify the License. You may add Your own attribution
136
+ notices within Derivative Works that You distribute, alongside
137
+ or as an addendum to the NOTICE text from the Work, provided
138
+ that such additional attribution notices cannot be construed
139
+ as modifying the License.
140
+
141
+ You may add Your own copyright statement to Your modifications and
142
+ may provide additional or different license terms and conditions
143
+ for use, reproduction, or distribution of Your modifications, or
144
+ for any such Derivative Works as a whole, provided Your use,
145
+ reproduction, and distribution of the Work otherwise complies with
146
+ the conditions stated in this License.
147
+
148
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
149
+ any Contribution intentionally submitted for inclusion in the Work
150
+ by You to the Licensor shall be under the terms and conditions of
151
+ this License, without any additional terms or conditions.
152
+ Notwithstanding the above, nothing herein shall supersede or modify
153
+ the terms of any separate license agreement you may have executed
154
+ with Licensor regarding such Contributions.
155
+
156
+ 6. Trademarks. This License does not grant permission to use the trade
157
+ names, trademarks, service marks, or product names of the Licensor,
158
+ except as required for reasonable and customary use in describing the
159
+ origin of the Work and reproducing the content of the NOTICE file.
160
+
161
+ 7. Disclaimer of Warranty. Unless required by applicable law or
162
+ agreed to in writing, Licensor provides the Work (and each
163
+ Contributor provides its Contributions) on an "AS IS" BASIS,
164
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
165
+ implied, including, without limitation, any warranties or conditions
166
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
167
+ PARTICULAR PURPOSE. You are solely responsible for determining the
168
+ appropriateness of using or redistributing the Work and assume any
169
+ risks associated with Your exercise of permissions under this License.
170
+
171
+ 8. Limitation of Liability. In no event and under no legal theory,
172
+ whether in tort (including negligence), contract, or otherwise,
173
+ unless required by applicable law (such as deliberate and grossly
174
+ negligent acts) or agreed to in writing, shall any Contributor be
175
+ liable to You for damages, including any direct, indirect, special,
176
+ incidental, or consequential damages of any character arising as a
177
+ result of this License or out of the use or inability to use the
178
+ Work (including but not limited to damages for loss of goodwill,
179
+ work stoppage, computer failure or malfunction, or any and all
180
+ other commercial damages or losses), even if such Contributor
181
+ has been advised of the possibility of such damages.
182
+
183
+ 9. Accepting Warranty or Additional Liability. While redistributing
184
+ the Work or Derivative Works thereof, You may choose to offer,
185
+ and charge a fee for, acceptance of support, warranty, indemnity,
186
+ or other liability obligations and/or rights consistent with this
187
+ License. However, in accepting such obligations, You may act only
188
+ on Your own behalf and on Your sole responsibility, not on behalf
189
+ of any other Contributor, and only if You agree to indemnify,
190
+ defend, and hold each Contributor harmless for any liability
191
+ incurred by, or claims asserted against, such Contributor by reason
192
+ of your accepting any such warranty or additional liability.
193
+
194
+ END OF TERMS AND CONDITIONS
195
+
196
+ APPENDIX: How to apply the Apache License to your work.
197
+
198
+ To apply the Apache License to your work, attach the following
199
+ boilerplate notice, with the fields enclosed by brackets "[]"
200
+ replaced with your own identifying information. (Don't include
201
+ the brackets!) The text should be enclosed in the appropriate
202
+ comment syntax for the file format. We also recommend that a
203
+ file or class name and description of purpose be included on the
204
+ same "printed page" as the copyright notice for easier
205
+ identification within third-party archives.
206
+
207
+ Copyright [yyyy] [name of copyright owner]
208
+
209
+ Licensed under the Apache License, Version 2.0 (the "License");
210
+ you may not use this file except in compliance with the License.
211
+ You may obtain a copy of the License at
212
+
213
+ http://www.apache.org/licenses/LICENSE-2.0
214
+
215
+ Unless required by applicable law or agreed to in writing, software
216
+ distributed under the License is distributed on an "AS IS" BASIS,
217
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
218
+ See the License for the specific language governing permissions and
219
+ limitations under the License.
220
+ ```
@@ -0,0 +1,32 @@
1
+ """Unofficial client for the icpc.global API.
2
+
3
+ Read a whole contest in one call::
4
+
5
+ from icpc import Icpc
6
+
7
+ with Icpc.from_store() as icpc:
8
+ teams = icpc.load_contest(1234)
9
+ print(len(teams.teams), "teams")
10
+ """
11
+
12
+ from icpc.config import Settings
13
+ from icpc.errors import ApiError, AuthError, IcpcError, SearchError
14
+ from icpc.facade.client import AsyncIcpc, Icpc, Include
15
+ from icpc.facade.domain import ContestView, Member, Team
16
+
17
+ __version__ = "0.1.0"
18
+
19
+ __all__ = [
20
+ "ApiError",
21
+ "AsyncIcpc",
22
+ "AuthError",
23
+ "ContestView",
24
+ "Icpc",
25
+ "IcpcError",
26
+ "Include",
27
+ "Member",
28
+ "SearchError",
29
+ "Settings",
30
+ "Team",
31
+ "__version__",
32
+ ]
@@ -0,0 +1,18 @@
1
+ """Low-level endpoints.
2
+
3
+ Each function is pure: it builds an :class:`~icpc.transport.operation.Operation`
4
+ and performs no I/O. Send one with ``client.send(...)``::
5
+
6
+ from icpc import Icpc
7
+ from icpc.api import team
8
+
9
+ with Icpc.from_store() as icpc:
10
+ roster = icpc.send(team.members(1234567))
11
+
12
+ Not all endpoints are wrapped here. Please fill an issue for missing ones or use
13
+ `icpc raw`.
14
+ """
15
+
16
+ from icpc.api import common, contest, person, public, staff, team
17
+
18
+ __all__ = ["common", "contest", "person", "public", "staff", "team"]
@@ -0,0 +1,97 @@
1
+ """``/common``, ``/icpcprofile`` and the ``/aspectfaces`` schema registry."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from icpc.models.base import Row
6
+ from icpc.models.entities import Globals, InstitutionSuggestion
7
+ from icpc.transport.operation import Operation, Request, list_op, model_op, scalar_op
8
+
9
+ __all__ = [
10
+ "AspectFacesField",
11
+ "AspectFacesSchema",
12
+ "globals_",
13
+ "institution_suggest",
14
+ "schema",
15
+ "wf_year",
16
+ ]
17
+
18
+
19
+ def globals_() -> Operation[Globals]:
20
+ """Site-wide settings: the current World Finals and regionals years."""
21
+ return model_op(Request("GET", "/common/globals/all"), Globals)
22
+
23
+
24
+ def wf_year() -> Operation[int]:
25
+ """The current World Finals year."""
26
+ return scalar_op(Request("GET", "/common/globals/WFYear"), int)
27
+
28
+
29
+ def suggested_institution(institution_id: int) -> Operation[dict[str, object]]:
30
+ """A suggested-institution record."""
31
+ return model_op(
32
+ Request("GET", f"/common/suggestedinstitution/{institution_id}"), dict[str, object]
33
+ )
34
+
35
+
36
+ class AspectFacesField(Row):
37
+ """One field of a server-side form definition."""
38
+
39
+ name: str | None = None
40
+ tag: str | None = None
41
+ label: str | None = None
42
+ label_key: str | None = None
43
+ placeholder: str | None = None
44
+ order: int | None = None
45
+ #: Allowed values, when the field is a choice — the closest thing to an enum
46
+ #: definition this API publishes.
47
+ options: list[object] | None = None
48
+ constraints: object | None = None
49
+ tooltip: str | None = None
50
+
51
+
52
+ class AspectFacesSchema(Row):
53
+ """``GET /aspectfaces/<java.class.Name>`` — a form definition."""
54
+
55
+ name: str | None = None
56
+ fields: list[AspectFacesField] | None = None
57
+ obj: object | None = None
58
+
59
+
60
+ def schema(java_class: str, *associations: str) -> Operation[AspectFacesSchema]:
61
+ """Fetch a server-side form definition.
62
+
63
+ This is the only schema the API exposes. It is the authoritative source for
64
+ enum option lists and required-field constraints, and therefore the right place
65
+ to look before constructing a write payload::
66
+
67
+ schema("global.icpc.base.model.team.businessobjects.Team", "teamInfo")
68
+ """
69
+ path = f"/aspectfaces/{java_class}"
70
+ if associations:
71
+ path += "->" + ",".join(associations)
72
+ return model_op(Request("GET", path), AspectFacesSchema)
73
+
74
+
75
+ def countries() -> Operation[list[dict[str, object]]]:
76
+ """The country list used by the registration forms."""
77
+ return list_op(Request("GET", "/common/country/all"), dict[str, object])
78
+
79
+
80
+ def institution_suggest(
81
+ name: str, *, page: int = 1, size: int = 10
82
+ ) -> Operation[list[InstitutionSuggestion]]:
83
+ """Look an institution up by name, as the UI's picker does.
84
+
85
+ The ``id`` it returns is the ``institutionUnitId`` that
86
+ :func:`icpc.api.team.register` expects. Take care: it is a different number
87
+ from both the ``instId`` and the ``instUnitId`` columns of the institution
88
+ search grid, which are ids in other tables entirely.
89
+ """
90
+ return list_op(
91
+ Request(
92
+ "GET",
93
+ "/common/institutionunit/suggest",
94
+ params={"name": name, "page": page, "size": size},
95
+ ),
96
+ InstitutionSuggestion,
97
+ )