mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-05 17:02:32 -05:00
Make some dependency changes, support Python 3.10 and 3.11 (#5611)
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ from copy import deepcopy
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
import appdirs
|
||||
import platformdirs
|
||||
from discord.utils import deprecated
|
||||
|
||||
from . import commands
|
||||
@@ -37,22 +37,30 @@ basic_config_default: Dict[str, Any] = {
|
||||
"CORE_PATH_APPEND": "core",
|
||||
}
|
||||
|
||||
appdir = appdirs.AppDirs("Red-DiscordBot")
|
||||
config_dir = Path(appdir.user_config_dir)
|
||||
appdir = platformdirs.PlatformDirs("Red-DiscordBot")
|
||||
config_dir = appdir.user_config_path
|
||||
_system_user = sys.platform == "linux" and 0 < os.getuid() < 1000
|
||||
if _system_user:
|
||||
if Path.home().exists():
|
||||
# We don't want to break someone just because they created home dir
|
||||
# but were already using the site_data_dir.
|
||||
# but were already using the site_data_path.
|
||||
#
|
||||
# But otherwise, we do want Red to use user_config_dir if home dir exists.
|
||||
_maybe_config_file = Path(appdir.site_data_dir) / "config.json"
|
||||
# But otherwise, we do want Red to use user_config_path if home dir exists.
|
||||
_maybe_config_file = appdir.site_data_path / "config.json"
|
||||
if _maybe_config_file.exists():
|
||||
config_dir = _maybe_config_file.parent
|
||||
else:
|
||||
config_dir = Path(appdir.site_data_dir)
|
||||
config_dir = appdir.site_data_path
|
||||
|
||||
config_file = config_dir / "config.json"
|
||||
if not config_file.exists() and sys.platform == "darwin":
|
||||
# backwards compatibility with the location given by appdirs 1.4.4 (replaced by platformdirs 2)
|
||||
# which was the same as user_data_path
|
||||
# https://platformdirs.readthedocs.io/en/stable/changelog.html#platformdirs-2-0-0
|
||||
_old_config_location = appdir.user_data_path / "config.json"
|
||||
if _old_config_location.exists():
|
||||
config_dir.mkdir(parents=True, exist_ok=True)
|
||||
_old_config_location.rename(config_file)
|
||||
|
||||
|
||||
def load_existing_config():
|
||||
|
||||
Reference in New Issue
Block a user