18 lines
711 B
Python
18 lines
711 B
Python
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)
|