From 22be0bf5f03afaf45583e3564103ab7cc9975e00 Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 28 Mar 2020 08:01:26 -0400 Subject: [PATCH] MIRAGE_CONFIG_DIR and MIRAGE_DATA_DIR env vars Allow overriding the default path where config files and user data are found --- src/backend/user_files.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/user_files.py b/src/backend/user_files.py index 51657c39..d46dde8d 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -4,6 +4,7 @@ import asyncio import json +import os from dataclasses import dataclass, field from pathlib import Path from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional @@ -45,9 +46,15 @@ class DataFile: """Full path of the file, even if it doesn't exist yet.""" if self.is_config: - return Path(self.backend.appdirs.user_config_dir) / self.filename + return Path( + os.environ.get("MIRAGE_CONFIG_DIR") or + self.backend.appdirs.user_config_dir + ) / self.filename - return Path(self.backend.appdirs.user_data_dir) / self.filename + return Path( + os.environ.get("MIRAGE_DATA_DIR") or + self.backend.appdirs.user_data_dir + ) / self.filename async def default_data(self):