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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codeforces
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: A simple command line tool to move your competitive programming workflow to your terminal.
5
5
  Home-page: https://github.com/Nirlep5252/codeforces-cli
6
6
  Author: Nirlep5252
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: codeforces
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: A simple command line tool to move your competitive programming workflow to your terminal.
5
5
  Home-page: https://github.com/Nirlep5252/codeforces-cli
6
6
  Author: Nirlep5252
@@ -5,6 +5,7 @@ utils.py
5
5
  cf/__init__.py
6
6
  cf/config.py
7
7
  cf/contests.py
8
+ cf/edit.py
8
9
  cf/parse.py
9
10
  cf/run.py
10
11
  cf/submit.py
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = codeforces
3
- version = 0.0.7
3
+ version = 0.0.8
4
4
  url = https://github.com/Nirlep5252/codeforces-cli
5
5
  author = Nirlep5252
6
6
  description = A simple command line tool to move your competitive programming workflow to your terminal.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes