init: MVP
This commit is contained in:
commit
46e870be42
17 changed files with 1202 additions and 0 deletions
18
codeforces/ui/utils.py
Normal file
18
codeforces/ui/utils.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
CONFIG_FILE = Path(os.path.join(os.environ['XDG_CONFIG_HOME'] if 'XDG_CONFIG_HOME' in os.environ else f"{os.environ['HOME']}/.config", 'codeforces', 'config.json'))
|
||||
SESSION_FILE = Path(os.path.join(os.environ['XDG_STATE_HOME'] if 'XDG_STATE_HOME' in os.environ else f"{os.environ['HOME']}/.local/state", 'codeforces', 'session.json'))
|
||||
|
||||
|
||||
def get_int(options: list[str]) -> int:
|
||||
while True:
|
||||
try:
|
||||
print('\n'.join(options))
|
||||
num = int(input("Enter a number: "))
|
||||
assert num <= len(options)
|
||||
assert num >= 0
|
||||
return num
|
||||
except Exception:
|
||||
print("Invalid input!\n", file=sys.stderr)
|
Loading…
Add table
Add a link
Reference in a new issue