init: MVP

This commit is contained in:
Arthur K. 2025-01-31 17:05:07 +03:00
commit 46e870be42
Signed by: wzray
GPG key ID: B97F30FDC4636357
17 changed files with 1202 additions and 0 deletions

18
codeforces/ui/utils.py Normal file
View 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)