mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
Renamed various config values to be backwards compatible
This commit is contained in:
parent
f38b2aa95e
commit
051245cf90
6
EDMC.py
6
EDMC.py
@ -41,7 +41,7 @@ from config import appcmdname, appversion, config
|
||||
from monitor import monitor
|
||||
from update import EDMCVersion, Updater
|
||||
|
||||
sys.path.append(config.internal_plugin_dir_str)
|
||||
sys.path.append(config.internal_plugin_dir)
|
||||
# This import must be after the sys.path.append.
|
||||
# The sys.path.append has to be after `import sys` and `from config import config`
|
||||
# isort: off
|
||||
@ -189,9 +189,9 @@ sys.path: {sys.path}'''
|
||||
# Get state from latest Journal file
|
||||
logger.debug('Getting state from latest journal file')
|
||||
try:
|
||||
logdir = config.get_str('journaldir', default=config.default_journal_dir_str)
|
||||
logdir = config.get_str('journaldir', default=config.default_journal_dir)
|
||||
if not logdir:
|
||||
logdir = config.default_journal_dir_str
|
||||
logdir = config.default_journal_dir
|
||||
|
||||
logger.debug(f'logdir = "{logdir}"')
|
||||
logfiles = sorted((x for x in os.listdir(logdir) if JOURNAL_RE.search(x)),
|
||||
|
@ -422,8 +422,8 @@ class EDMCContextFilter(logging.Filter):
|
||||
:return: The munged module_name.
|
||||
"""
|
||||
file_name = pathlib.Path(frame_info.filename).expanduser()
|
||||
plugin_dir = pathlib.Path(config.plugin_dir).expanduser()
|
||||
internal_plugin_dir = pathlib.Path(config.internal_plugin_dir).expanduser()
|
||||
plugin_dir = pathlib.Path(config.plugin_dir_path).expanduser()
|
||||
internal_plugin_dir = pathlib.Path(config.internal_plugin_dir_path).expanduser()
|
||||
# Find the first parent called 'plugins'
|
||||
plugin_top = file_name
|
||||
while plugin_top and plugin_top.name != '':
|
||||
|
@ -415,7 +415,7 @@ class AppWindow(object):
|
||||
|
||||
else:
|
||||
self.w.tk.call('wm', 'iconphoto', self.w, '-default',
|
||||
tk.PhotoImage(file=join(config.respath, 'EDMarketConnector.png')))
|
||||
tk.PhotoImage(file=join(config.respath_path, 'EDMarketConnector.png')))
|
||||
|
||||
# TODO: Export to files and merge from them in future ?
|
||||
self.theme_icon = tk.PhotoImage(
|
||||
@ -1145,7 +1145,7 @@ class AppWindow(object):
|
||||
# Avoid file length limits if possible
|
||||
provider = config.get_str('shipyard_provider', default='EDSY')
|
||||
target = plug.invoke(provider, 'EDSY', 'shipyard_url', monitor.ship(), monitor.is_beta)
|
||||
file_name = join(config.app_dir, "last_shipyard.html")
|
||||
file_name = join(config.app_dir_path, "last_shipyard.html")
|
||||
|
||||
with open(file_name, 'w') as f:
|
||||
print(SHIPYARD_HTML_TEMPLATE.format(
|
||||
|
@ -660,7 +660,7 @@ def fixup(data: CAPIData) -> CAPIData: # noqa: C901, CCR001 # Can't be usefully
|
||||
if not commodity_map:
|
||||
# Lazily populate
|
||||
for f in ('commodity.csv', 'rare_commodity.csv'):
|
||||
with open(join(config.respath, f), 'r') as csvfile:
|
||||
with open(join(config.respath_path, f), 'r') as csvfile:
|
||||
reader = csv.DictReader(csvfile)
|
||||
|
||||
for row in reader:
|
||||
|
96
config.py
96
config.py
@ -107,19 +107,19 @@ class AbstractConfig(abc.ABC):
|
||||
OUT_SYS_EDDN = 2048
|
||||
OUT_SYS_DELAY = 4096
|
||||
|
||||
app_dir: pathlib.Path
|
||||
plugin_dir: pathlib.Path
|
||||
internal_plugin_dir: pathlib.Path
|
||||
respath: pathlib.Path
|
||||
home: pathlib.Path
|
||||
default_journal_dir: pathlib.Path
|
||||
app_dir_path: pathlib.Path
|
||||
plugin_dir_path: pathlib.Path
|
||||
internal_plugin_dir_path: pathlib.Path
|
||||
respath_path: pathlib.Path
|
||||
home_path: pathlib.Path
|
||||
default_journal_dir_path: pathlib.Path
|
||||
|
||||
identifier: str
|
||||
|
||||
__in_shutdown = False # Is the application currently shutting down ?
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.home = pathlib.Path.home()
|
||||
self.home_path = pathlib.Path.home()
|
||||
|
||||
def set_shutdown(self):
|
||||
self.__in_shutdown = True
|
||||
@ -129,34 +129,34 @@ class AbstractConfig(abc.ABC):
|
||||
return self.__in_shutdown
|
||||
|
||||
@property
|
||||
def app_dir_str(self) -> str:
|
||||
def app_dir(self) -> str:
|
||||
"""Return a string version of app_dir."""
|
||||
return str(self.app_dir)
|
||||
return str(self.app_dir_path)
|
||||
|
||||
@property
|
||||
def plugin_dir_str(self) -> str:
|
||||
def plugin_dir(self) -> str:
|
||||
"""Return a string version of plugin_dir."""
|
||||
return str(self.plugin_dir)
|
||||
return str(self.plugin_dir_path)
|
||||
|
||||
@property
|
||||
def internal_plugin_dir_str(self) -> str:
|
||||
def internal_plugin_dir(self) -> str:
|
||||
"""Return a string version of internal_plugin_dir."""
|
||||
return str(self.internal_plugin_dir)
|
||||
return str(self.internal_plugin_dir_path)
|
||||
|
||||
@property
|
||||
def respath_str(self) -> str:
|
||||
def respath(self) -> str:
|
||||
"""Return a string version of respath."""
|
||||
return str(self.respath)
|
||||
return str(self.respath_path)
|
||||
|
||||
@property
|
||||
def home_str(self) -> str:
|
||||
def home(self) -> str:
|
||||
"""Return a string version of home."""
|
||||
return str(self.home)
|
||||
return str(self.home_path)
|
||||
|
||||
@property
|
||||
def default_journal_dir_str(self) -> str:
|
||||
def default_journal_dir(self) -> str:
|
||||
"""Return a string version of default_journal_dir."""
|
||||
return str(self.default_journal_dir)
|
||||
return str(self.default_journal_dir_path)
|
||||
|
||||
@staticmethod
|
||||
def _suppress_call(
|
||||
@ -308,27 +308,27 @@ class WinConfig(AbstractConfig):
|
||||
"""Implementation of AbstractConfig for windows."""
|
||||
|
||||
def __init__(self, do_winsparkle=True) -> None:
|
||||
self.app_dir = pathlib.Path(str(known_folder_path(FOLDERID_LocalAppData))) / appname
|
||||
self.app_dir.mkdir(exist_ok=True)
|
||||
self.app_dir_path = pathlib.Path(str(known_folder_path(FOLDERID_LocalAppData))) / appname
|
||||
self.app_dir_path.mkdir(exist_ok=True)
|
||||
|
||||
self.plugin_dir = self.app_dir / 'plugins'
|
||||
self.plugin_dir.mkdir(exist_ok=True)
|
||||
self.plugin_dir_path = self.app_dir_path / 'plugins'
|
||||
self.plugin_dir_path.mkdir(exist_ok=True)
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
self.respath = pathlib.Path(sys.executable).parent
|
||||
self.internal_plugin_dir = self.respath / 'plugins'
|
||||
self.respath_path = pathlib.Path(sys.executable).parent
|
||||
self.internal_plugin_dir_path = self.respath_path / 'plugins'
|
||||
|
||||
else:
|
||||
self.respath = pathlib.Path(__file__).parent
|
||||
self.internal_plugin_dir = self.respath / 'plugins'
|
||||
self.respath_path = pathlib.Path(__file__).parent
|
||||
self.internal_plugin_dir_path = self.respath_path / 'plugins'
|
||||
|
||||
self.home = pathlib.Path.home()
|
||||
self.home_path = pathlib.Path.home()
|
||||
|
||||
journal_dir_str = known_folder_path(FOLDERID_SavedGames)
|
||||
journaldir = pathlib.Path(journal_dir_str) if journal_dir_str is not None else None
|
||||
self.default_journal_dir = None
|
||||
self.default_journal_dir_path = None
|
||||
if journaldir is not None:
|
||||
self.default_journal_dir = journaldir / 'Frontier Developments' / 'Elite Dangerous'
|
||||
self.default_journal_dir_path = journaldir / 'Frontier Developments' / 'Elite Dangerous'
|
||||
|
||||
create_key_defaults = functools.partial(
|
||||
winreg.CreateKeyEx,
|
||||
@ -350,7 +350,7 @@ class WinConfig(AbstractConfig):
|
||||
self.identifier = applongname
|
||||
if (outdir_str := self.get_str('outdir')) is None or not pathlib.Path(outdir_str).is_dir():
|
||||
docs = known_folder_path(FOLDERID_Documents)
|
||||
self.set('outdir', docs if docs is not None else str(self.home))
|
||||
self.set('outdir', docs if docs is not None else str(self.home_path))
|
||||
|
||||
def __setup_winsparkle(self):
|
||||
create_key_defaults = functools.partial(
|
||||
@ -535,29 +535,29 @@ class MacConfig(AbstractConfig):
|
||||
)[0]
|
||||
)
|
||||
|
||||
self.app_dir = support_path / appname
|
||||
self.app_dir.mkdir(exist_ok=True)
|
||||
self.app_dir_path = support_path / appname
|
||||
self.app_dir_path.mkdir(exist_ok=True)
|
||||
|
||||
self.plugin_dir = self.app_dir / 'plugins'
|
||||
self.plugin_dir.mkdir(exist_ok=True)
|
||||
self.plugin_dir_path = self.app_dir_path / 'plugins'
|
||||
self.plugin_dir_path.mkdir(exist_ok=True)
|
||||
|
||||
# Bundle IDs identify a singled app though out a system
|
||||
|
||||
if getattr(sys, 'frozen', False):
|
||||
exe_dir = pathlib.Path(sys.executable).parent
|
||||
self.internal_plugin_dir = exe_dir.parent / 'Library' / 'plugins'
|
||||
self.respath = exe_dir.parent / 'Resources'
|
||||
self.internal_plugin_dir_path = exe_dir.parent / 'Library' / 'plugins'
|
||||
self.respath_path = exe_dir.parent / 'Resources'
|
||||
self.identifier = NSBundle.mainBundle().bundleIdentifier()
|
||||
|
||||
else:
|
||||
file_dir = pathlib.Path(__file__).parent
|
||||
self.internal_plugin_dir = file_dir / 'plugins'
|
||||
self.respath = file_dir
|
||||
self.internal_plugin_dir_path = file_dir / 'plugins'
|
||||
self.respath_path = file_dir
|
||||
|
||||
self.identifier = f'uk.org.marginal.{appname.lower()}'
|
||||
NSBundle.mainBundle().infoDictionary()['CFBundleIdentifier'] = self.identifier
|
||||
|
||||
self.default_journal_dir = support_path / 'Frontier Developments' / 'Elite Dangerous'
|
||||
self.default_journal_dir_path = support_path / 'Frontier Developments' / 'Elite Dangerous'
|
||||
self._defaults = NSUserDefaults.standardUserDefaults()
|
||||
self._settings: Dict[str, Union[int, str, list]] = dict(
|
||||
self._defaults.persistentDomainForName_(self.identifier) or {}
|
||||
@ -682,16 +682,16 @@ class LinuxConfig(AbstractConfig):
|
||||
super().__init__()
|
||||
# http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html
|
||||
xdg_data_home = pathlib.Path(os.getenv('XDG_DATA_HOME', default='~/.local/share')).expanduser()
|
||||
self.app_dir = xdg_data_home / appname
|
||||
self.app_dir.mkdir(exist_ok=True, parents=True)
|
||||
self.app_dir_path = xdg_data_home / appname
|
||||
self.app_dir_path.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
self.plugin_dir = self.app_dir / 'plugins'
|
||||
self.plugin_dir.mkdir(exist_ok=True)
|
||||
self.plugin_dir_path = self.app_dir_path / 'plugins'
|
||||
self.plugin_dir_path.mkdir(exist_ok=True)
|
||||
|
||||
self.respath = pathlib.Path(__file__).parent
|
||||
self.respath_path = pathlib.Path(__file__).parent
|
||||
|
||||
self.internal_plugin_dir = self.respath / 'plugins'
|
||||
self.default_journal_dir = None
|
||||
self.internal_plugin_dir_path = self.respath_path / 'plugins'
|
||||
self.default_journal_dir_path = None
|
||||
self.identifier = f'uk.org.marginal.{appname.lower()}' # TODO: Unused?
|
||||
|
||||
config_home = pathlib.Path(os.getenv('XDG_CONFIG_HOME', default='~/.config')).expanduser()
|
||||
@ -711,7 +711,7 @@ class LinuxConfig(AbstractConfig):
|
||||
self.config.add_section(self.SECTION)
|
||||
|
||||
if (outdir := self.get_str('outdir')) is None or not pathlib.Path(outdir).is_dir():
|
||||
self.set('outdir', str(self.home))
|
||||
self.set('outdir', str(self.home_path))
|
||||
|
||||
def __escape(self, s: str) -> str:
|
||||
"""
|
||||
|
@ -41,9 +41,9 @@ class Dashboard(FileSystemEventHandler):
|
||||
self.root = root
|
||||
self.session_start = started
|
||||
|
||||
logdir = config.get_str('journaldir', default=config.default_journal_dir_str)
|
||||
logdir = config.get_str('journaldir', default=config.default_journal_dir)
|
||||
if logdir == '':
|
||||
logdir = config.default_journal_dir_str
|
||||
logdir = config.default_journal_dir
|
||||
|
||||
if not logdir or not isdir(logdir):
|
||||
logger.info(f"No logdir, or it isn't a directory: {logdir=}")
|
||||
|
@ -48,7 +48,7 @@ slot_map = {
|
||||
|
||||
# Ship masses
|
||||
# TODO: prefer something other than pickle for this storage (dev readability, security)
|
||||
ships = pickle.load(open(join(config.respath, 'ships.p'), 'rb'))
|
||||
ships = pickle.load(open(join(config.respath_path, 'ships.p'), 'rb'))
|
||||
|
||||
|
||||
# Export ship loadout in E:D Shipyard plain text format
|
||||
|
@ -42,8 +42,8 @@ if platform == 'darwin':
|
||||
|
||||
self.tkProcessKeyEvent_old = None
|
||||
|
||||
self.snd_good = NSSound.alloc().initWithContentsOfFile_byReference_(join(config.respath, 'snd_good.wav'), False)
|
||||
self.snd_bad = NSSound.alloc().initWithContentsOfFile_byReference_(join(config.respath, 'snd_bad.wav'), False)
|
||||
self.snd_good = NSSound.alloc().initWithContentsOfFile_byReference_(join(config.respath_path, 'snd_good.wav'), False)
|
||||
self.snd_bad = NSSound.alloc().initWithContentsOfFile_byReference_(join(config.respath_path, 'snd_bad.wav'), False)
|
||||
|
||||
def register(self, root, keycode, modifiers):
|
||||
self.root = root
|
||||
@ -291,8 +291,8 @@ elif platform == 'win32':
|
||||
def __init__(self):
|
||||
self.root = None
|
||||
self.thread = None
|
||||
self.snd_good = open(join(config.respath, 'snd_good.wav'), 'rb').read()
|
||||
self.snd_bad = open(join(config.respath, 'snd_bad.wav'), 'rb').read()
|
||||
self.snd_good = open(join(config.respath_path, 'snd_good.wav'), 'rb').read()
|
||||
self.snd_bad = open(join(config.respath_path, 'snd_bad.wav'), 'rb').read()
|
||||
atexit.register(self.unregister)
|
||||
|
||||
def register(self, root, keycode, modifiers):
|
||||
|
6
l10n.py
6
l10n.py
@ -113,8 +113,8 @@ class _Translations:
|
||||
return
|
||||
|
||||
self.translations = {None: self.contents(cast(str, lang))}
|
||||
for plugin in os.listdir(config.plugin_dir):
|
||||
plugin_path = join(config.plugin_dir, plugin, LOCALISATION_DIR)
|
||||
for plugin in os.listdir(config.plugin_dir_path):
|
||||
plugin_path = join(config.plugin_dir_path, plugin, LOCALISATION_DIR)
|
||||
if isdir(plugin_path):
|
||||
try:
|
||||
self.translations[plugin] = self.contents(cast(str, lang), str(plugin_path))
|
||||
@ -160,7 +160,7 @@ class _Translations:
|
||||
"""
|
||||
if context:
|
||||
# TODO: There is probably a better way to go about this now.
|
||||
context = context[len(config.plugin_dir_str)+1:].split(os.sep)[0]
|
||||
context = context[len(config.plugin_dir)+1:].split(os.sep)[0]
|
||||
if self.translations[None] and context not in self.translations:
|
||||
logger.debug(f'No translations for {context!r}')
|
||||
|
||||
|
@ -132,7 +132,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
journal_dir = config.get_str('journaldir')
|
||||
|
||||
if journal_dir == '' or journal_dir is None:
|
||||
journal_dir = config.default_journal_dir_str
|
||||
journal_dir = config.default_journal_dir
|
||||
|
||||
# TODO(A_D): this is ignored for type checking due to all the different types config.get returns
|
||||
# When that is refactored, remove the magic comment
|
||||
|
@ -350,7 +350,7 @@ def lookup(module, ship_map, entitled=False):
|
||||
|
||||
# Lazily populate
|
||||
if not moduledata:
|
||||
moduledata.update(pickle.load(open(join(config.respath, 'modules.p'), 'rb')))
|
||||
moduledata.update(pickle.load(open(join(config.respath_path, 'modules.p'), 'rb')))
|
||||
|
||||
# if not module.get('category'): raise AssertionError('%s: Missing category' % module['id']) # only present post 1.3, and not present in ship loadout
|
||||
if not module.get('name'): raise AssertionError('%s: Missing name' % module['id'])
|
||||
|
16
plug.py
16
plug.py
@ -173,10 +173,10 @@ def load_plugins(master):
|
||||
last_error['root'] = master
|
||||
|
||||
internal = []
|
||||
for name in sorted(os.listdir(config.internal_plugin_dir)):
|
||||
for name in sorted(os.listdir(config.internal_plugin_dir_path)):
|
||||
if name.endswith('.py') and not name[0] in ['.', '_']:
|
||||
try:
|
||||
plugin = Plugin(name[:-3], os.path.join(config.internal_plugin_dir, name), logger)
|
||||
plugin = Plugin(name[:-3], os.path.join(config.internal_plugin_dir_path, name), logger)
|
||||
plugin.folder = None # Suppress listing in Plugins prefs tab
|
||||
internal.append(plugin)
|
||||
except Exception as e:
|
||||
@ -184,13 +184,13 @@ def load_plugins(master):
|
||||
PLUGINS.extend(sorted(internal, key=lambda p: operator.attrgetter('name')(p).lower()))
|
||||
|
||||
# Add plugin folder to load path so packages can be loaded from plugin folder
|
||||
sys.path.append(config.plugin_dir_str)
|
||||
sys.path.append(config.plugin_dir)
|
||||
|
||||
found = []
|
||||
# Load any plugins that are also packages first
|
||||
for name in sorted(os.listdir(config.plugin_dir),
|
||||
key = lambda n: (not os.path.isfile(os.path.join(config.plugin_dir, n, '__init__.py')), n.lower())):
|
||||
if not os.path.isdir(os.path.join(config.plugin_dir, name)) or name[0] in ['.', '_']:
|
||||
for name in sorted(os.listdir(config.plugin_dir_path),
|
||||
key = lambda n: (not os.path.isfile(os.path.join(config.plugin_dir_path, n, '__init__.py')), n.lower())):
|
||||
if not os.path.isdir(os.path.join(config.plugin_dir_path, name)) or name[0] in ['.', '_']:
|
||||
pass
|
||||
elif name.endswith('.disabled'):
|
||||
name, discard = name.rsplit('.', 1)
|
||||
@ -198,14 +198,14 @@ def load_plugins(master):
|
||||
else:
|
||||
try:
|
||||
# Add plugin's folder to load path in case plugin has internal package dependencies
|
||||
sys.path.append(os.path.join(config.plugin_dir, name))
|
||||
sys.path.append(os.path.join(config.plugin_dir_path, name))
|
||||
|
||||
# Create a logger for this 'found' plugin. Must be before the
|
||||
# load.py is loaded.
|
||||
import EDMCLogging
|
||||
|
||||
plugin_logger = EDMCLogging.get_plugin_logger(name)
|
||||
found.append(Plugin(name, os.path.join(config.plugin_dir, name, 'load.py'), plugin_logger))
|
||||
found.append(Plugin(name, os.path.join(config.plugin_dir_path, name, 'load.py'), plugin_logger))
|
||||
except Exception as e:
|
||||
logger.exception(f'Failure loading found Plugin "{name}"')
|
||||
pass
|
||||
|
@ -745,7 +745,7 @@ def journal_entry( # noqa: C901
|
||||
|
||||
journaldir = config.get_str('journaldir')
|
||||
if journaldir is None or journaldir == '':
|
||||
journaldir = config.default_journal_dir_str
|
||||
journaldir = config.default_journal_dir
|
||||
|
||||
path = pathlib.Path(journaldir) / f'{entry["event"]}.json'
|
||||
|
||||
|
26
prefs.py
26
prefs.py
@ -408,7 +408,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
row = AutoInc(start=1)
|
||||
|
||||
self.logdir = tk.StringVar()
|
||||
default = config.default_journal_dir_str if config.default_journal_dir is not None else ''
|
||||
default = config.default_journal_dir if config.default_journal_dir_path is not None else ''
|
||||
logdir = config.get_str('journaldir')
|
||||
if logdir is None or logdir == '':
|
||||
logdir = default
|
||||
@ -431,7 +431,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
)
|
||||
self.logbutton.grid(column=3, padx=self.PADX, pady=self.PADY, sticky=tk.EW, row=row.get())
|
||||
|
||||
if config.default_journal_dir:
|
||||
if config.default_journal_dir_path:
|
||||
# Appearance theme and language setting
|
||||
nb.Button(
|
||||
config_frame,
|
||||
@ -800,7 +800,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
plugins_frame = nb.Frame(notebook)
|
||||
plugins_frame.columnconfigure(0, weight=1)
|
||||
plugdir = tk.StringVar()
|
||||
plugdir.set(config.plugin_dir_str)
|
||||
plugdir.set(config.plugin_dir)
|
||||
row = AutoInc(1)
|
||||
|
||||
# Section heading in settings
|
||||
@ -949,7 +949,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
browseInfo.lpszTitle = title
|
||||
browseInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI
|
||||
browseInfo.lpfn = BrowseCallbackProc(browsecallback)
|
||||
browseInfo.lParam = pathvar.get().startswith('~') and join(config.home,
|
||||
browseInfo.lParam = pathvar.get().startswith('~') and join(config.home_path,
|
||||
pathvar.get()[2:]) or pathvar.get()
|
||||
ctypes.windll.ole32.CoInitialize(None)
|
||||
pidl = ctypes.windll.shell32.SHBrowseForFolderW(ctypes.byref(browseInfo))
|
||||
@ -985,7 +985,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
entryfield['state'] = tk.NORMAL # must be writable to update
|
||||
entryfield.delete(0, tk.END)
|
||||
if platform == 'win32':
|
||||
start = len(config.home_str.split('\\')) if pathvar.get().lower().startswith(config.home_str.lower()) else 0
|
||||
start = len(config.home.split('\\')) if pathvar.get().lower().startswith(config.home.lower()) else 0
|
||||
display = []
|
||||
components = normpath(pathvar.get()).split('\\')
|
||||
buf = ctypes.create_unicode_buffer(MAX_PATH)
|
||||
@ -1006,9 +1006,9 @@ class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
# None if path doesn't exist
|
||||
elif platform == 'darwin' and NSFileManager.defaultManager().componentsToDisplayForPath_(pathvar.get()):
|
||||
if pathvar.get().startswith(config.home_str):
|
||||
if pathvar.get().startswith(config.home):
|
||||
display = ['~'] + NSFileManager.defaultManager().componentsToDisplayForPath_(pathvar.get())[
|
||||
len(NSFileManager.defaultManager().componentsToDisplayForPath_(config.home_str)):
|
||||
len(NSFileManager.defaultManager().componentsToDisplayForPath_(config.home)):
|
||||
]
|
||||
|
||||
else:
|
||||
@ -1016,8 +1016,8 @@ class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
entryfield.insert(0, '/'.join(display))
|
||||
else:
|
||||
if pathvar.get().startswith(config.home_str):
|
||||
entryfield.insert(0, '~' + pathvar.get()[len(config.home_str):])
|
||||
if pathvar.get().startswith(config.home):
|
||||
entryfield.insert(0, '~' + pathvar.get()[len(config.home):])
|
||||
|
||||
else:
|
||||
entryfield.insert(0, pathvar.get())
|
||||
@ -1026,8 +1026,8 @@ class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
def logdir_reset(self) -> None:
|
||||
"""Reset the log dir to the default."""
|
||||
if config.default_journal_dir:
|
||||
self.logdir.set(config.default_journal_dir_str)
|
||||
if config.default_journal_dir_path:
|
||||
self.logdir.set(config.default_journal_dir)
|
||||
|
||||
self.outvarchanged()
|
||||
|
||||
@ -1134,11 +1134,11 @@ class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
config.set(
|
||||
'outdir',
|
||||
join(config.home, self.outdir.get()[2:]) if self.outdir.get().startswith('~') else self.outdir.get()
|
||||
join(config.home_path, self.outdir.get()[2:]) if self.outdir.get().startswith('~') else self.outdir.get()
|
||||
)
|
||||
|
||||
logdir = self.logdir.get()
|
||||
if config.default_journal_dir and logdir.lower() == config.default_journal_dir_str.lower():
|
||||
if config.default_journal_dir_path and logdir.lower() == config.default_journal_dir.lower():
|
||||
config.set('journaldir', '') # default location
|
||||
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user