slave-cp 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.
- slave-cp-0.1.0/LICENSE +21 -0
- slave-cp-0.1.0/PKG-INFO +298 -0
- slave-cp-0.1.0/README.md +284 -0
- slave-cp-0.1.0/pyproject.toml +3 -0
- slave-cp-0.1.0/setup.cfg +4 -0
- slave-cp-0.1.0/setup.py +44 -0
- slave-cp-0.1.0/slave_cp/__init__.py +10 -0
- slave-cp-0.1.0/slave_cp/cli.py +184 -0
- slave-cp-0.1.0/slave_cp/config.py +75 -0
- slave-cp-0.1.0/slave_cp/fetcher.py +256 -0
- slave-cp-0.1.0/slave_cp/runner.py +609 -0
- slave-cp-0.1.0/slave_cp/submitter.py +429 -0
- slave-cp-0.1.0/slave_cp/utils.py +308 -0
- slave-cp-0.1.0/slave_cp.egg-info/PKG-INFO +298 -0
- slave-cp-0.1.0/slave_cp.egg-info/SOURCES.txt +20 -0
- slave-cp-0.1.0/slave_cp.egg-info/dependency_links.txt +1 -0
- slave-cp-0.1.0/slave_cp.egg-info/entry_points.txt +2 -0
- slave-cp-0.1.0/slave_cp.egg-info/requires.txt +10 -0
- slave-cp-0.1.0/slave_cp.egg-info/top_level.txt +1 -0
- slave-cp-0.1.0/tests/test_config.py +130 -0
- slave-cp-0.1.0/tests/test_fetcher.py +153 -0
- slave-cp-0.1.0/tests/test_runner.py +229 -0
slave-cp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 block-plant
|
|
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.
|
slave-cp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: slave-cp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A CLI tool to automate competitive programming workflow
|
|
5
|
+
Home-page: https://github.com/block-plant/slave-cp
|
|
6
|
+
Author: block-plant
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
|
|
15
|
+
# ⚡ slave-cp
|
|
16
|
+
|
|
17
|
+
> Your competitive programming workflow, automated.
|
|
18
|
+
|
|
19
|
+
[](https://github.com/block-plant/slave-cp/actions)
|
|
20
|
+
[](https://pypi.org/project/slave-cp/)
|
|
21
|
+
[](https://pypi.org/project/slave-cp/)
|
|
22
|
+
[](LICENSE)
|
|
23
|
+
|
|
24
|
+
**slave-cp** is a command-line tool that automates the repetitive parts of competitive programming — fetching problems, running test cases with rich diffs, and submitting — so you can focus entirely on solving.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## ✨ Features
|
|
29
|
+
|
|
30
|
+
- 📥 **Fetch** problems and sample test cases from Codeforces in one command
|
|
31
|
+
- 🗂️ **Auto-generates** a clean folder structure and solution templates
|
|
32
|
+
- ▶️ **Run** your solution against all test cases with colored pass/fail output
|
|
33
|
+
- 🔍 **Diff view** — see exactly where your output differs from expected
|
|
34
|
+
- 🚀 **Auto-submit** — triggered automatically when all test cases pass
|
|
35
|
+
- 🌐 **23 languages** supported — C++, Python, Java, Rust, Go, Kotlin, and more
|
|
36
|
+
- 🔒 **Credentials stored locally** — no third-party servers, ever
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📦 Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install slave-cp
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Requires Python 3.7+.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 🚀 Quick Start
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# 1. Set your workspace and save credentials (one-time setup)
|
|
54
|
+
slave-cp init ~/competitive
|
|
55
|
+
|
|
56
|
+
# 2. Fetch a contest
|
|
57
|
+
slave-cp fetch CF1234
|
|
58
|
+
|
|
59
|
+
# 3. Solve problem A (edit A.cpp, A.py, A.java — whatever language you like)
|
|
60
|
+
vim ~/competitive/CF1234/A.cpp
|
|
61
|
+
|
|
62
|
+
# 4. Run against sample test cases
|
|
63
|
+
slave-cp run A
|
|
64
|
+
|
|
65
|
+
# 5. If all pass, you'll be asked to submit automatically
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 📁 Folder Structure
|
|
71
|
+
|
|
72
|
+
After `slave-cp fetch CF1234`:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
~/competitive/
|
|
76
|
+
└── CF1234/
|
|
77
|
+
├── A.cpp ← pre-created solution template
|
|
78
|
+
├── A/
|
|
79
|
+
│ ├── input1.txt
|
|
80
|
+
│ ├── output1.txt
|
|
81
|
+
│ ├── input2.txt
|
|
82
|
+
│ └── output2.txt
|
|
83
|
+
├── B.cpp
|
|
84
|
+
├── B/
|
|
85
|
+
│ └── ...
|
|
86
|
+
└── ...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 🖥️ Commands
|
|
92
|
+
|
|
93
|
+
### `slave-cp init <path>`
|
|
94
|
+
Set your workspace folder and save credentials for Codeforces and CodeChef. Run this once before anything else.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
slave-cp init ~/competitive
|
|
98
|
+
# ✔ Workspace set to: ~/competitive
|
|
99
|
+
# Codeforces handle: tourist
|
|
100
|
+
# Codeforces password: ••••••••
|
|
101
|
+
# ✔ Codeforces credentials saved.
|
|
102
|
+
# Default extension: .cpp
|
|
103
|
+
# ✔ slave-cp is ready! Happy coding.
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### `slave-cp fetch <contest-id>`
|
|
109
|
+
Scrapes all problems and sample test cases for a contest. Supports Codeforces (`CF<id>`) and CodeChef (`CC-<id>`).
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
slave-cp fetch CF1234 # Codeforces contest 1234
|
|
113
|
+
slave-cp fetch CC-START001 # CodeChef contest
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### `slave-cp run <problem>`
|
|
119
|
+
Compiles and runs your solution against all sample test cases. If all pass, you'll be prompted to submit.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
slave-cp run A
|
|
123
|
+
slave-cp run A --contest CF1234 # specify contest explicitly
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Output:**
|
|
127
|
+
```
|
|
128
|
+
Language detected: C++
|
|
129
|
+
Compiling: A.cpp ... OK
|
|
130
|
+
Running 3 test case(s)...
|
|
131
|
+
|
|
132
|
+
✔ Test 1 → ACCEPTED
|
|
133
|
+
✘ Test 2 → WRONG ANSWER
|
|
134
|
+
|
|
135
|
+
╭───┬─────────┬─────────────────┬──────────────╮
|
|
136
|
+
│ │ Input │ Expected Output │ Your Output │
|
|
137
|
+
├───┼─────────┼─────────────────┼──────────────┤
|
|
138
|
+
│ 1 │ 3 5 │ 4 │ 3 │
|
|
139
|
+
╰───┴─────────┴─────────────────┴──────────────╯
|
|
140
|
+
|
|
141
|
+
✔ Test 3 → ACCEPTED
|
|
142
|
+
|
|
143
|
+
─────────────────────────────────────────────
|
|
144
|
+
✘ 2/3 passed — 1 failed
|
|
145
|
+
─────────────────────────────────────────────
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
If all test cases pass:
|
|
149
|
+
```
|
|
150
|
+
─────────────────────────────────────────────
|
|
151
|
+
✔ All 3/3 test cases passed!
|
|
152
|
+
─────────────────────────────────────────────
|
|
153
|
+
Do you want to submit to the judge? [y/N]:
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
If multiple language files exist for the same problem (e.g. `A.cpp` and `A.py`), slave-cp will ask which one to run.
|
|
157
|
+
|
|
158
|
+
When all tests pass and you confirm submit, slave-cp logs in and polls for the verdict:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
✔ Logged in successfully.
|
|
162
|
+
Submitting problem A (.cpp) ...
|
|
163
|
+
✔ Solution submitted successfully!
|
|
164
|
+
|
|
165
|
+
Waiting for verdict.........
|
|
166
|
+
|
|
167
|
+
✔ ACCEPTED 🎉
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Possible verdicts: `ACCEPTED`, `WRONG ANSWER`, `TIME LIMIT EXCEEDED`, `MEMORY LIMIT EXCEEDED`, `RUNTIME ERROR`, `COMPILATION ERROR`.
|
|
171
|
+
|
|
172
|
+
> **Note:** CodeChef submission uses Selenium with headless Chrome, same as `slave-cp fetch`.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### `slave-cp config`
|
|
177
|
+
Show your current configuration.
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
slave-cp config
|
|
181
|
+
# Workspace : ~/competitive
|
|
182
|
+
# Extension : .cpp
|
|
183
|
+
# CF Handle : tourist
|
|
184
|
+
# CC Handle : chef
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
### `slave-cp list`
|
|
190
|
+
List all contests in your workspace.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
slave-cp list
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### `slave-cp check`
|
|
199
|
+
Check which compilers and interpreters are installed on your system.
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
slave-cp check
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 🌐 Supported Languages
|
|
208
|
+
|
|
209
|
+
| Language | Extension | Compiled |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| C++ | `.cpp` | ✅ `g++ -O2 -std=c++17` |
|
|
212
|
+
| C | `.c` | ✅ `gcc -O2` |
|
|
213
|
+
| Python 3 | `.py` | ❌ |
|
|
214
|
+
| PyPy 3 | `.pypy` | ❌ |
|
|
215
|
+
| Java | `.java` | ✅ `javac` |
|
|
216
|
+
| Kotlin | `.kt` | ✅ `kotlinc` |
|
|
217
|
+
| Go | `.go` | ✅ `go build` |
|
|
218
|
+
| Rust | `.rs` | ✅ `rustc -O` |
|
|
219
|
+
| C# | `.cs` | ❌ `dotnet-script` |
|
|
220
|
+
| Ruby | `.rb` | ❌ |
|
|
221
|
+
| JavaScript | `.js` | ❌ |
|
|
222
|
+
| TypeScript | `.ts` | ✅ `tsc` |
|
|
223
|
+
| Haskell | `.hs` | ✅ `ghc -O2` |
|
|
224
|
+
| Scala | `.scala` | ✅ `scalac` |
|
|
225
|
+
| D | `.d` | ✅ `dmd -O` |
|
|
226
|
+
| Pascal | `.pas` | ✅ `fpc` |
|
|
227
|
+
| Perl | `.pl` | ❌ |
|
|
228
|
+
| PHP | `.php` | ❌ |
|
|
229
|
+
| Swift | `.swift` | ✅ `swiftc` |
|
|
230
|
+
| Lua | `.lua` | ❌ |
|
|
231
|
+
| R | `.r` | ❌ |
|
|
232
|
+
| Dart | `.dart` | ❌ |
|
|
233
|
+
| F# | `.fs` | ❌ `dotnet-fsi` |
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## ⚙️ Configuration
|
|
238
|
+
|
|
239
|
+
Config is stored at `~/.slave-cp/config.json`:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"workspace": "~/competitive",
|
|
244
|
+
"extension": ".cpp",
|
|
245
|
+
"codeforces": { "handle": "tourist" },
|
|
246
|
+
"codechef": { "handle": "chef" }
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
To update, just re-run `slave-cp init` or edit the file directly.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 🧪 Running Tests
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# Install dev dependencies
|
|
258
|
+
pip install -e ".[dev]"
|
|
259
|
+
|
|
260
|
+
# Run all tests
|
|
261
|
+
pytest tests/ -v
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Tests cover:
|
|
265
|
+
- `test_config.py` — init, save/load, workspace, credentials
|
|
266
|
+
- `test_fetcher.py` — write test cases, templates, CF scraping (mocked HTTP)
|
|
267
|
+
- `test_runner.py` — load test cases, detect solution, run (AC / WA / TLE / RE), summary
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 🗺️ Roadmap
|
|
272
|
+
|
|
273
|
+
- [x] Phase 1 — Fetch + folder setup (Codeforces)
|
|
274
|
+
- [x] Phase 2 — Run & test locally with diff output
|
|
275
|
+
- [x] Phase 3 — Auto-submit to Codeforces
|
|
276
|
+
- [x] Phase 4 — CodeChef support
|
|
277
|
+
- [x] Phase 5 — Published on PyPI
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 🤝 Contributing
|
|
282
|
+
|
|
283
|
+
Pull requests are welcome! For major changes, open an issue first.
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
git clone https://github.com/block-plant/slave-cp
|
|
287
|
+
cd slave-cp
|
|
288
|
+
pip install -e ".[dev]"
|
|
289
|
+
pytest tests/
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Please make sure tests pass and code is formatted with `black` before submitting a PR.
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## 📄 License
|
|
297
|
+
|
|
298
|
+
[MIT](LICENSE) © block-plant
|
slave-cp-0.1.0/README.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# ⚡ slave-cp
|
|
2
|
+
|
|
3
|
+
> Your competitive programming workflow, automated.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/block-plant/slave-cp/actions)
|
|
6
|
+
[](https://pypi.org/project/slave-cp/)
|
|
7
|
+
[](https://pypi.org/project/slave-cp/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
**slave-cp** is a command-line tool that automates the repetitive parts of competitive programming — fetching problems, running test cases with rich diffs, and submitting — so you can focus entirely on solving.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## ✨ Features
|
|
15
|
+
|
|
16
|
+
- 📥 **Fetch** problems and sample test cases from Codeforces in one command
|
|
17
|
+
- 🗂️ **Auto-generates** a clean folder structure and solution templates
|
|
18
|
+
- ▶️ **Run** your solution against all test cases with colored pass/fail output
|
|
19
|
+
- 🔍 **Diff view** — see exactly where your output differs from expected
|
|
20
|
+
- 🚀 **Auto-submit** — triggered automatically when all test cases pass
|
|
21
|
+
- 🌐 **23 languages** supported — C++, Python, Java, Rust, Go, Kotlin, and more
|
|
22
|
+
- 🔒 **Credentials stored locally** — no third-party servers, ever
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 📦 Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install slave-cp
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Requires Python 3.7+.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🚀 Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# 1. Set your workspace and save credentials (one-time setup)
|
|
40
|
+
slave-cp init ~/competitive
|
|
41
|
+
|
|
42
|
+
# 2. Fetch a contest
|
|
43
|
+
slave-cp fetch CF1234
|
|
44
|
+
|
|
45
|
+
# 3. Solve problem A (edit A.cpp, A.py, A.java — whatever language you like)
|
|
46
|
+
vim ~/competitive/CF1234/A.cpp
|
|
47
|
+
|
|
48
|
+
# 4. Run against sample test cases
|
|
49
|
+
slave-cp run A
|
|
50
|
+
|
|
51
|
+
# 5. If all pass, you'll be asked to submit automatically
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 📁 Folder Structure
|
|
57
|
+
|
|
58
|
+
After `slave-cp fetch CF1234`:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
~/competitive/
|
|
62
|
+
└── CF1234/
|
|
63
|
+
├── A.cpp ← pre-created solution template
|
|
64
|
+
├── A/
|
|
65
|
+
│ ├── input1.txt
|
|
66
|
+
│ ├── output1.txt
|
|
67
|
+
│ ├── input2.txt
|
|
68
|
+
│ └── output2.txt
|
|
69
|
+
├── B.cpp
|
|
70
|
+
├── B/
|
|
71
|
+
│ └── ...
|
|
72
|
+
└── ...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 🖥️ Commands
|
|
78
|
+
|
|
79
|
+
### `slave-cp init <path>`
|
|
80
|
+
Set your workspace folder and save credentials for Codeforces and CodeChef. Run this once before anything else.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
slave-cp init ~/competitive
|
|
84
|
+
# ✔ Workspace set to: ~/competitive
|
|
85
|
+
# Codeforces handle: tourist
|
|
86
|
+
# Codeforces password: ••••••••
|
|
87
|
+
# ✔ Codeforces credentials saved.
|
|
88
|
+
# Default extension: .cpp
|
|
89
|
+
# ✔ slave-cp is ready! Happy coding.
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### `slave-cp fetch <contest-id>`
|
|
95
|
+
Scrapes all problems and sample test cases for a contest. Supports Codeforces (`CF<id>`) and CodeChef (`CC-<id>`).
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
slave-cp fetch CF1234 # Codeforces contest 1234
|
|
99
|
+
slave-cp fetch CC-START001 # CodeChef contest
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
### `slave-cp run <problem>`
|
|
105
|
+
Compiles and runs your solution against all sample test cases. If all pass, you'll be prompted to submit.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
slave-cp run A
|
|
109
|
+
slave-cp run A --contest CF1234 # specify contest explicitly
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Output:**
|
|
113
|
+
```
|
|
114
|
+
Language detected: C++
|
|
115
|
+
Compiling: A.cpp ... OK
|
|
116
|
+
Running 3 test case(s)...
|
|
117
|
+
|
|
118
|
+
✔ Test 1 → ACCEPTED
|
|
119
|
+
✘ Test 2 → WRONG ANSWER
|
|
120
|
+
|
|
121
|
+
╭───┬─────────┬─────────────────┬──────────────╮
|
|
122
|
+
│ │ Input │ Expected Output │ Your Output │
|
|
123
|
+
├───┼─────────┼─────────────────┼──────────────┤
|
|
124
|
+
│ 1 │ 3 5 │ 4 │ 3 │
|
|
125
|
+
╰───┴─────────┴─────────────────┴──────────────╯
|
|
126
|
+
|
|
127
|
+
✔ Test 3 → ACCEPTED
|
|
128
|
+
|
|
129
|
+
─────────────────────────────────────────────
|
|
130
|
+
✘ 2/3 passed — 1 failed
|
|
131
|
+
─────────────────────────────────────────────
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
If all test cases pass:
|
|
135
|
+
```
|
|
136
|
+
─────────────────────────────────────────────
|
|
137
|
+
✔ All 3/3 test cases passed!
|
|
138
|
+
─────────────────────────────────────────────
|
|
139
|
+
Do you want to submit to the judge? [y/N]:
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
If multiple language files exist for the same problem (e.g. `A.cpp` and `A.py`), slave-cp will ask which one to run.
|
|
143
|
+
|
|
144
|
+
When all tests pass and you confirm submit, slave-cp logs in and polls for the verdict:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
✔ Logged in successfully.
|
|
148
|
+
Submitting problem A (.cpp) ...
|
|
149
|
+
✔ Solution submitted successfully!
|
|
150
|
+
|
|
151
|
+
Waiting for verdict.........
|
|
152
|
+
|
|
153
|
+
✔ ACCEPTED 🎉
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Possible verdicts: `ACCEPTED`, `WRONG ANSWER`, `TIME LIMIT EXCEEDED`, `MEMORY LIMIT EXCEEDED`, `RUNTIME ERROR`, `COMPILATION ERROR`.
|
|
157
|
+
|
|
158
|
+
> **Note:** CodeChef submission uses Selenium with headless Chrome, same as `slave-cp fetch`.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### `slave-cp config`
|
|
163
|
+
Show your current configuration.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
slave-cp config
|
|
167
|
+
# Workspace : ~/competitive
|
|
168
|
+
# Extension : .cpp
|
|
169
|
+
# CF Handle : tourist
|
|
170
|
+
# CC Handle : chef
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
### `slave-cp list`
|
|
176
|
+
List all contests in your workspace.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
slave-cp list
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### `slave-cp check`
|
|
185
|
+
Check which compilers and interpreters are installed on your system.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
slave-cp check
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 🌐 Supported Languages
|
|
194
|
+
|
|
195
|
+
| Language | Extension | Compiled |
|
|
196
|
+
|---|---|---|
|
|
197
|
+
| C++ | `.cpp` | ✅ `g++ -O2 -std=c++17` |
|
|
198
|
+
| C | `.c` | ✅ `gcc -O2` |
|
|
199
|
+
| Python 3 | `.py` | ❌ |
|
|
200
|
+
| PyPy 3 | `.pypy` | ❌ |
|
|
201
|
+
| Java | `.java` | ✅ `javac` |
|
|
202
|
+
| Kotlin | `.kt` | ✅ `kotlinc` |
|
|
203
|
+
| Go | `.go` | ✅ `go build` |
|
|
204
|
+
| Rust | `.rs` | ✅ `rustc -O` |
|
|
205
|
+
| C# | `.cs` | ❌ `dotnet-script` |
|
|
206
|
+
| Ruby | `.rb` | ❌ |
|
|
207
|
+
| JavaScript | `.js` | ❌ |
|
|
208
|
+
| TypeScript | `.ts` | ✅ `tsc` |
|
|
209
|
+
| Haskell | `.hs` | ✅ `ghc -O2` |
|
|
210
|
+
| Scala | `.scala` | ✅ `scalac` |
|
|
211
|
+
| D | `.d` | ✅ `dmd -O` |
|
|
212
|
+
| Pascal | `.pas` | ✅ `fpc` |
|
|
213
|
+
| Perl | `.pl` | ❌ |
|
|
214
|
+
| PHP | `.php` | ❌ |
|
|
215
|
+
| Swift | `.swift` | ✅ `swiftc` |
|
|
216
|
+
| Lua | `.lua` | ❌ |
|
|
217
|
+
| R | `.r` | ❌ |
|
|
218
|
+
| Dart | `.dart` | ❌ |
|
|
219
|
+
| F# | `.fs` | ❌ `dotnet-fsi` |
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## ⚙️ Configuration
|
|
224
|
+
|
|
225
|
+
Config is stored at `~/.slave-cp/config.json`:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"workspace": "~/competitive",
|
|
230
|
+
"extension": ".cpp",
|
|
231
|
+
"codeforces": { "handle": "tourist" },
|
|
232
|
+
"codechef": { "handle": "chef" }
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
To update, just re-run `slave-cp init` or edit the file directly.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 🧪 Running Tests
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# Install dev dependencies
|
|
244
|
+
pip install -e ".[dev]"
|
|
245
|
+
|
|
246
|
+
# Run all tests
|
|
247
|
+
pytest tests/ -v
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Tests cover:
|
|
251
|
+
- `test_config.py` — init, save/load, workspace, credentials
|
|
252
|
+
- `test_fetcher.py` — write test cases, templates, CF scraping (mocked HTTP)
|
|
253
|
+
- `test_runner.py` — load test cases, detect solution, run (AC / WA / TLE / RE), summary
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 🗺️ Roadmap
|
|
258
|
+
|
|
259
|
+
- [x] Phase 1 — Fetch + folder setup (Codeforces)
|
|
260
|
+
- [x] Phase 2 — Run & test locally with diff output
|
|
261
|
+
- [x] Phase 3 — Auto-submit to Codeforces
|
|
262
|
+
- [x] Phase 4 — CodeChef support
|
|
263
|
+
- [x] Phase 5 — Published on PyPI
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## 🤝 Contributing
|
|
268
|
+
|
|
269
|
+
Pull requests are welcome! For major changes, open an issue first.
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
git clone https://github.com/block-plant/slave-cp
|
|
273
|
+
cd slave-cp
|
|
274
|
+
pip install -e ".[dev]"
|
|
275
|
+
pytest tests/
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Please make sure tests pass and code is formatted with `black` before submitting a PR.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 📄 License
|
|
283
|
+
|
|
284
|
+
[MIT](LICENSE) © block-plant
|
slave-cp-0.1.0/setup.cfg
ADDED
slave-cp-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as f:
|
|
4
|
+
long_description = f.read()
|
|
5
|
+
|
|
6
|
+
install_requires = [
|
|
7
|
+
"requests",
|
|
8
|
+
"beautifulsoup4",
|
|
9
|
+
"click",
|
|
10
|
+
"rich",
|
|
11
|
+
"selenium",
|
|
12
|
+
"webdriver-manager",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
dev_requires = [
|
|
16
|
+
"pytest",
|
|
17
|
+
"pytest-requests-mock",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
setup(
|
|
21
|
+
name="slave-cp",
|
|
22
|
+
version="0.1.0",
|
|
23
|
+
author="block-plant",
|
|
24
|
+
description="A CLI tool to automate competitive programming workflow",
|
|
25
|
+
long_description=long_description,
|
|
26
|
+
long_description_content_type="text/markdown",
|
|
27
|
+
url="https://github.com/block-plant/slave-cp",
|
|
28
|
+
packages=find_packages(),
|
|
29
|
+
install_requires=install_requires,
|
|
30
|
+
extras_require={
|
|
31
|
+
"dev": dev_requires,
|
|
32
|
+
},
|
|
33
|
+
python_requires=">=3.7",
|
|
34
|
+
entry_points={
|
|
35
|
+
"console_scripts": [
|
|
36
|
+
"slave-cp=slave_cp.cli:main",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
classifiers=[
|
|
40
|
+
"Programming Language :: Python :: 3",
|
|
41
|
+
"License :: OSI Approved :: MIT License",
|
|
42
|
+
"Operating System :: OS Independent",
|
|
43
|
+
],
|
|
44
|
+
)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
2
|
+
__author__ = "block-plant"
|
|
3
|
+
__email__ = "https://github.com/block-plant"
|
|
4
|
+
__license__ = "MIT"
|
|
5
|
+
__url__ = "https://github.com/block-plant/slave-cp"
|
|
6
|
+
|
|
7
|
+
from slave_cp.config import load_config, save_config, get_workspace, set_workspace, set_credentials, get_credentials
|
|
8
|
+
from slave_cp.utils import print_banner, print_success, print_error, print_warning, print_info
|
|
9
|
+
|
|
10
|
+
# tests/__init__.py
|