mirror of
https://github.com/szymon-jozef/zutui.git
synced 2026-09-07 12:10:43 +02:00
make xdg dirs more correct!
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
import os
|
||||
import platform
|
||||
|
||||
USER_HOME = os.path.expanduser("~")
|
||||
WINDOWS_PATH = "zutui" # probably should be in %AppData% or something, but I'm not sure, so I won't change it
|
||||
LINUX_PATH = ".config/zutui"
|
||||
|
||||
def get_config_path():
|
||||
system = platform.system()
|
||||
if system == "Windows":
|
||||
APP_DIR = os.path.join(USER_HOME, WINDOWS_PATH)
|
||||
elif system in ["Linux", "Darwin"]:
|
||||
APP_DIR = os.path.join(USER_HOME, LINUX_PATH)
|
||||
else:
|
||||
print(f"System {system} not supported, aborting...")
|
||||
exit(1)
|
||||
if not os.path.exists(APP_DIR):
|
||||
os.makedirs(APP_DIR)
|
||||
return APP_DIR
|
||||
@@ -1,13 +1,18 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import json
|
||||
from appdirs import user_config_dir, user_cache_dir
|
||||
import os
|
||||
|
||||
from .config import get_config_path
|
||||
app_name = "zutui"
|
||||
app_author = "shv187"
|
||||
|
||||
APP_DIR = get_config_path()
|
||||
CONFIG_DIR = user_config_dir(app_name, app_author)
|
||||
CACHE_DIR = user_cache_dir(app_name, app_author)
|
||||
os.makedirs(CACHE_DIR, exist_ok=True)
|
||||
os.makedirs(CONFIG_DIR, exist_ok=True)
|
||||
|
||||
CACHE_FILE = os.path.join(APP_DIR, "grades_cache.json")
|
||||
CACHE_FILE = os.path.join(CACHE_DIR, "grades_cache.json")
|
||||
TIMEOUT = 10
|
||||
|
||||
class ZUT:
|
||||
|
||||
@@ -3,6 +3,7 @@ import os
|
||||
import keyring
|
||||
from keyring.errors import KeyringError
|
||||
from datetime import datetime
|
||||
from appdirs import user_config_dir
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container
|
||||
from textual.widgets import Header, Footer, DataTable, Label, Button, Input
|
||||
@@ -10,9 +11,8 @@ from textual.screen import Screen
|
||||
from textual.binding import Binding
|
||||
|
||||
from .zut_client import ZUT
|
||||
from .config import get_config_path
|
||||
|
||||
APP_DIR = get_config_path()
|
||||
APP_DIR = user_config_dir("zutui", "shv187")
|
||||
|
||||
CONFIG_FILE = os.path.join(APP_DIR, "config.json")
|
||||
REFRESH_INTERVAL = 1800
|
||||
|
||||
Reference in New Issue
Block a user