mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-03 00:51:11 +03:00
use _str versions of paths for string ops
This commit is contained in:
parent
41f7391e42
commit
00629b7420
6
EDMC.py
6
EDMC.py
@ -41,7 +41,7 @@ from config import appcmdname, appversion, config
|
|||||||
from monitor import monitor
|
from monitor import monitor
|
||||||
from update import EDMCVersion, Updater
|
from update import EDMCVersion, Updater
|
||||||
|
|
||||||
sys.path.append(config.internal_plugin_dir)
|
sys.path.append(config.internal_plugin_dir_str)
|
||||||
# This import must be after the sys.path.append.
|
# This import must be after the sys.path.append.
|
||||||
# The sys.path.append has to be after `import sys` and `from config import config`
|
# The sys.path.append has to be after `import sys` and `from config import config`
|
||||||
# isort: off
|
# isort: off
|
||||||
@ -189,9 +189,9 @@ sys.path: {sys.path}'''
|
|||||||
# Get state from latest Journal file
|
# Get state from latest Journal file
|
||||||
logger.debug('Getting state from latest journal file')
|
logger.debug('Getting state from latest journal file')
|
||||||
try:
|
try:
|
||||||
logdir = config.get_str('journaldir', default=str(config.default_journal_dir))
|
logdir = config.get_str('journaldir', default=config.default_journal_dir_str)
|
||||||
if not logdir:
|
if not logdir:
|
||||||
logdir = str(config.default_journal_dir)
|
logdir = config.default_journal_dir_str
|
||||||
|
|
||||||
logger.debug(f'logdir = "{logdir}"')
|
logger.debug(f'logdir = "{logdir}"')
|
||||||
logfiles = sorted((x for x in os.listdir(logdir) if JOURNAL_RE.search(x)),
|
logfiles = sorted((x for x in os.listdir(logdir) if JOURNAL_RE.search(x)),
|
||||||
|
@ -41,10 +41,10 @@ class Dashboard(FileSystemEventHandler):
|
|||||||
self.root = root
|
self.root = root
|
||||||
self.session_start = started
|
self.session_start = started
|
||||||
|
|
||||||
logdir = config.get_str('journaldir', default=str(config.default_journal_dir))
|
logdir = config.get_str('journaldir', default=config.default_journal_dir_str)
|
||||||
if logdir == '':
|
if logdir == '':
|
||||||
logdir = str(config.default_journal_dir)
|
logdir = config.default_journal_dir_str
|
||||||
|
|
||||||
if not logdir or not isdir(logdir):
|
if not logdir or not isdir(logdir):
|
||||||
logger.info(f"No logdir, or it isn't a directory: {logdir=}")
|
logger.info(f"No logdir, or it isn't a directory: {logdir=}")
|
||||||
self.stop()
|
self.stop()
|
||||||
|
4
l10n.py
4
l10n.py
@ -117,7 +117,7 @@ class _Translations:
|
|||||||
plugin_path = join(config.plugin_dir, plugin, LOCALISATION_DIR)
|
plugin_path = join(config.plugin_dir, plugin, LOCALISATION_DIR)
|
||||||
if isdir(plugin_path):
|
if isdir(plugin_path):
|
||||||
try:
|
try:
|
||||||
self.translations[plugin] = self.contents(cast(str, lang), plugin_path)
|
self.translations[plugin] = self.contents(cast(str, lang), str(plugin_path))
|
||||||
|
|
||||||
except UnicodeDecodeError as e:
|
except UnicodeDecodeError as e:
|
||||||
logger.warning(f'Malformed file {lang}.strings in plugin {plugin}: {e}')
|
logger.warning(f'Malformed file {lang}.strings in plugin {plugin}: {e}')
|
||||||
@ -160,7 +160,7 @@ class _Translations:
|
|||||||
"""
|
"""
|
||||||
if context:
|
if context:
|
||||||
# TODO: There is probably a better way to go about this now.
|
# TODO: There is probably a better way to go about this now.
|
||||||
context = context[len(str(config.plugin_dir))+1:].split(os.sep)[0]
|
context = context[len(config.plugin_dir_str)+1:].split(os.sep)[0]
|
||||||
if self.translations[None] and context not in self.translations:
|
if self.translations[None] and context not in self.translations:
|
||||||
logger.debug(f'No translations for {context!r}')
|
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')
|
journal_dir = config.get_str('journaldir')
|
||||||
|
|
||||||
if journal_dir == '' or journal_dir is None:
|
if journal_dir == '' or journal_dir is None:
|
||||||
journal_dir = str(config.default_journal_dir)
|
journal_dir = config.default_journal_dir_str
|
||||||
|
|
||||||
# TODO(A_D): this is ignored for type checking due to all the different types config.get returns
|
# 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
|
# When that is refactored, remove the magic comment
|
||||||
|
2
plug.py
2
plug.py
@ -184,7 +184,7 @@ def load_plugins(master):
|
|||||||
PLUGINS.extend(sorted(internal, key=lambda p: operator.attrgetter('name')(p).lower()))
|
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
|
# Add plugin folder to load path so packages can be loaded from plugin folder
|
||||||
sys.path.append(config.plugin_dir)
|
sys.path.append(config.plugin_dir_str)
|
||||||
|
|
||||||
found = []
|
found = []
|
||||||
# Load any plugins that are also packages first
|
# Load any plugins that are also packages first
|
||||||
|
@ -745,7 +745,7 @@ def journal_entry( # noqa: C901
|
|||||||
|
|
||||||
journaldir = config.get_str('journaldir')
|
journaldir = config.get_str('journaldir')
|
||||||
if journaldir is None or journaldir == '':
|
if journaldir is None or journaldir == '':
|
||||||
journaldir = str(config.default_journal_dir)
|
journaldir = config.default_journal_dir_str
|
||||||
|
|
||||||
path = pathlib.Path(journaldir) / f'{entry["event"]}.json'
|
path = pathlib.Path(journaldir) / f'{entry["event"]}.json'
|
||||||
|
|
||||||
|
16
prefs.py
16
prefs.py
@ -408,7 +408,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
row = AutoInc(start=1)
|
row = AutoInc(start=1)
|
||||||
|
|
||||||
self.logdir = tk.StringVar()
|
self.logdir = tk.StringVar()
|
||||||
default = str(config.default_journal_dir) if config.default_journal_dir is not None else ''
|
default = config.default_journal_dir_str if config.default_journal_dir is not None else ''
|
||||||
logdir = config.get_str('journaldir')
|
logdir = config.get_str('journaldir')
|
||||||
if logdir is None or logdir == '':
|
if logdir is None or logdir == '':
|
||||||
logdir = default
|
logdir = default
|
||||||
@ -634,7 +634,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
def __setup_appearance_tab(self, notebook: Notebook) -> None:
|
def __setup_appearance_tab(self, notebook: Notebook) -> None:
|
||||||
self.languages = Translations.available_names()
|
self.languages = Translations.available_names()
|
||||||
# Appearance theme and language setting
|
# Appearance theme and language setting
|
||||||
self.lang = tk.StringVar(value=self.languages.get(config.get_str('language'), default=_('Default')))
|
self.lang = tk.StringVar(value=self.languages.get(config.get_str('language'), _('Default')))
|
||||||
self.always_ontop = tk.BooleanVar(value=bool(config.get_int('always_ontop')))
|
self.always_ontop = tk.BooleanVar(value=bool(config.get_int('always_ontop')))
|
||||||
self.theme = tk.IntVar(value=config.get_int('theme'))
|
self.theme = tk.IntVar(value=config.get_int('theme'))
|
||||||
self.theme_colors = [config.get_str('dark_text'), config.get_str('dark_highlight')]
|
self.theme_colors = [config.get_str('dark_text'), config.get_str('dark_highlight')]
|
||||||
@ -985,7 +985,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
entryfield['state'] = tk.NORMAL # must be writable to update
|
entryfield['state'] = tk.NORMAL # must be writable to update
|
||||||
entryfield.delete(0, tk.END)
|
entryfield.delete(0, tk.END)
|
||||||
if platform == 'win32':
|
if platform == 'win32':
|
||||||
start = len(config.home.split('\\')) if pathvar.get().lower().startswith(config.home.lower()) else 0
|
start = len(config.home_str.split('\\')) if pathvar.get().lower().startswith(config.home_str.lower()) else 0
|
||||||
display = []
|
display = []
|
||||||
components = normpath(pathvar.get()).split('\\')
|
components = normpath(pathvar.get()).split('\\')
|
||||||
buf = ctypes.create_unicode_buffer(MAX_PATH)
|
buf = ctypes.create_unicode_buffer(MAX_PATH)
|
||||||
@ -1006,7 +1006,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
|
|
||||||
# None if path doesn't exist
|
# None if path doesn't exist
|
||||||
elif platform == 'darwin' and NSFileManager.defaultManager().componentsToDisplayForPath_(pathvar.get()):
|
elif platform == 'darwin' and NSFileManager.defaultManager().componentsToDisplayForPath_(pathvar.get()):
|
||||||
if pathvar.get().startswith(config.home):
|
if pathvar.get().startswith(config.home_str):
|
||||||
display = ['~'] + NSFileManager.defaultManager().componentsToDisplayForPath_(pathvar.get())[
|
display = ['~'] + NSFileManager.defaultManager().componentsToDisplayForPath_(pathvar.get())[
|
||||||
len(NSFileManager.defaultManager().componentsToDisplayForPath_(config.home)):
|
len(NSFileManager.defaultManager().componentsToDisplayForPath_(config.home)):
|
||||||
]
|
]
|
||||||
@ -1016,8 +1016,8 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
|
|
||||||
entryfield.insert(0, '/'.join(display))
|
entryfield.insert(0, '/'.join(display))
|
||||||
else:
|
else:
|
||||||
if pathvar.get().startswith(config.home):
|
if pathvar.get().startswith(config.home_str):
|
||||||
entryfield.insert(0, '~' + pathvar.get()[len(config.home):])
|
entryfield.insert(0, '~' + pathvar.get()[len(config.home_str):])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
entryfield.insert(0, pathvar.get())
|
entryfield.insert(0, pathvar.get())
|
||||||
@ -1027,7 +1027,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
def logdir_reset(self) -> None:
|
def logdir_reset(self) -> None:
|
||||||
"""Reset the log dir to the default."""
|
"""Reset the log dir to the default."""
|
||||||
if config.default_journal_dir:
|
if config.default_journal_dir:
|
||||||
self.logdir.set(config.default_journal_dir)
|
self.logdir.set(config.default_journal_dir_str)
|
||||||
|
|
||||||
self.outvarchanged()
|
self.outvarchanged()
|
||||||
|
|
||||||
@ -1138,7 +1138,7 @@ class PreferencesDialog(tk.Toplevel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
logdir = self.logdir.get()
|
logdir = self.logdir.get()
|
||||||
if config.default_journal_dir and logdir.lower() == config.default_journal_dir.lower():
|
if config.default_journal_dir and logdir.lower() == config.default_journal_dir_str.lower():
|
||||||
config.set('journaldir', '') # default location
|
config.set('journaldir', '') # default location
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user