appdirs<1.4.4 compatibility fix

This commit is contained in:
jack1142
2020-06-18 01:19:32 +02:00
parent 3595a91964
commit cc5299d987
2 changed files with 14 additions and 0 deletions

View File

@@ -44,6 +44,13 @@ if sys.platform == "linux":
if not config_dir:
config_dir = Path(appdir.user_config_dir)
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
# which was the same as user_data_dir
# https://github.com/ActiveState/appdirs/issues/63
_old_config_location = Path(appdir.user_data_dir) / "config.json"
if _old_config_location.exists():
_old_config_location.rename(config_file)
def create_temp_config():

View File

@@ -32,6 +32,13 @@ except PermissionError:
print("You don't have permission to write to '{}'\nExiting...".format(config_dir))
sys.exit(1)
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
# which was the same as user_data_dir
# https://github.com/ActiveState/appdirs/issues/63
_old_config_location = Path(appdir.user_data_dir) / "config.json"
if _old_config_location.exists():
_old_config_location.rename(config_file)
def load_existing_config():