codeforces 0.0.7__tar.gz → 0.0.8__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.
- {codeforces-0.0.7 → codeforces-0.0.8}/PKG-INFO +1 -1
- {codeforces-0.0.7 → codeforces-0.0.8}/cf/__init__.py +2 -0
- codeforces-0.0.8/cf/edit.py +39 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/cf/submit.py +3 -2
- {codeforces-0.0.7 → codeforces-0.0.8}/codeforces.egg-info/PKG-INFO +1 -1
- {codeforces-0.0.7 → codeforces-0.0.8}/codeforces.egg-info/SOURCES.txt +1 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/setup.cfg +1 -1
- {codeforces-0.0.7 → codeforces-0.0.8}/README.md +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/cf/config.py +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/cf/contests.py +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/cf/parse.py +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/cf/run.py +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/cf/unsolved.py +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/codeforces.egg-info/dependency_links.txt +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/codeforces.egg-info/entry_points.txt +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/codeforces.egg-info/requires.txt +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/codeforces.egg-info/top_level.txt +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/setup.py +0 -0
- {codeforces-0.0.7 → codeforces-0.0.8}/utils.py +0 -0
|
@@ -5,6 +5,7 @@ from .parse import parse
|
|
|
5
5
|
from .submit import submit
|
|
6
6
|
from .run import run
|
|
7
7
|
from .unsolved import unsolved
|
|
8
|
+
from .edit import edit_cmd
|
|
8
9
|
from rich.console import Console
|
|
9
10
|
from rich.table import Table
|
|
10
11
|
from typing import Dict
|
|
@@ -51,3 +52,4 @@ commands.add_command(parse)
|
|
|
51
52
|
commands.add_command(run)
|
|
52
53
|
commands.add_command(submit)
|
|
53
54
|
commands.add_command(unsolved)
|
|
55
|
+
commands.add_command(edit_cmd)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import click
|
|
2
|
+
import os
|
|
3
|
+
import subprocess
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
from utils import get_config
|
|
6
|
+
|
|
7
|
+
console = Console()
|
|
8
|
+
|
|
9
|
+
editor_cmds = {
|
|
10
|
+
"vscode": "code {path}",
|
|
11
|
+
"neovim": "nvim {path}",
|
|
12
|
+
"vim": "vim {path}",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@click.command(name="edit")
|
|
17
|
+
@click.argument("contest_id", required=True)
|
|
18
|
+
@click.option("--editor", type=click.Choice(["vscode", "neovim", "vim"]), prompt="Select an editor: ")
|
|
19
|
+
def edit_cmd(contest_id: str, editor: str):
|
|
20
|
+
conf = get_config(console)
|
|
21
|
+
if conf is None:
|
|
22
|
+
return
|
|
23
|
+
|
|
24
|
+
cf_dir = conf.get("dir")
|
|
25
|
+
if cf_dir is None:
|
|
26
|
+
console.print("[bold red]ERROR: [/]The default directory is not set.\nPlease run the `cf config` command.")
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
if not os.path.isdir(cf_dir):
|
|
30
|
+
console.print("[bold red]ERROR: [/]The default directory does not exist.\nPlease run the `cf config` command.")
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
contest_dir = os.path.join(cf_dir, contest_id)
|
|
34
|
+
if not os.path.isdir(contest_dir):
|
|
35
|
+
console.print(f"\n[bold red]ERROR: [/]The contest directory `{contest_dir}` does not exist.")
|
|
36
|
+
console.print(f"[bold green]TIP: [/]Use `cf parse {contest_id}` to create the directory and parse the contest.")
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
subprocess.run(editor_cmds[editor].format(path=os.path.join(cf_dir, contest_id)), shell=True)
|
|
@@ -127,8 +127,8 @@ Memory: [bold white]{sub_mem.strip()}[/]
|
|
|
127
127
|
sub_data = json.loads(sub['text'])['d']
|
|
128
128
|
live_sub_id = sub_data[1]
|
|
129
129
|
if live_sub_id == sub_id:
|
|
130
|
-
status = sub_data[6]
|
|
131
|
-
test_case = sub_data[8]
|
|
130
|
+
status = sub_data[6].strip()
|
|
131
|
+
test_case = sub_data[8].strip()
|
|
132
132
|
|
|
133
133
|
if status == "OK":
|
|
134
134
|
status_text = "[bold green]ACCEPTED[/]"
|
|
@@ -148,4 +148,5 @@ Memory: [bold]{memory} KB[/]
|
|
|
148
148
|
live.refresh()
|
|
149
149
|
if status != "TESTING":
|
|
150
150
|
live.stop()
|
|
151
|
+
sub_watcher.close()
|
|
151
152
|
break
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|