mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-12 15:27:14 +03:00
[2114] Cleanup Initial Commit
Some of these are already paths.
This commit is contained in:
parent
fe8818d187
commit
f8b7a8b919
@ -490,8 +490,8 @@ class EDMCContextFilter(logging.Filter):
|
|||||||
:return: The munged module_name.
|
:return: The munged module_name.
|
||||||
"""
|
"""
|
||||||
file_name = pathlib.Path(frame_info.filename).expanduser()
|
file_name = pathlib.Path(frame_info.filename).expanduser()
|
||||||
plugin_dir = pathlib.Path(config.plugin_dir_path).expanduser()
|
plugin_dir = config.plugin_dir_path.expanduser()
|
||||||
internal_plugin_dir = pathlib.Path(config.internal_plugin_dir_path).expanduser()
|
internal_plugin_dir = config.internal_plugin_dir_path.expanduser()
|
||||||
# Find the first parent called 'plugins'
|
# Find the first parent called 'plugins'
|
||||||
plugin_top = file_name
|
plugin_top = file_name
|
||||||
while plugin_top and plugin_top.name != '':
|
while plugin_top and plugin_top.name != '':
|
||||||
|
@ -116,12 +116,12 @@ def main() -> None:
|
|||||||
root.withdraw() # Hide the window initially to calculate the dimensions
|
root.withdraw() # Hide the window initially to calculate the dimensions
|
||||||
try:
|
try:
|
||||||
icon_image = tk.PhotoImage(
|
icon_image = tk.PhotoImage(
|
||||||
file=pathlib.Path(cur_config.respath_path) / "io.edcd.EDMarketConnector.png"
|
file=cur_config.respath_path / "io.edcd.EDMarketConnector.png"
|
||||||
)
|
)
|
||||||
|
|
||||||
root.iconphoto(True, icon_image)
|
root.iconphoto(True, icon_image)
|
||||||
except tk.TclError:
|
except tk.TclError:
|
||||||
root.iconbitmap(pathlib.Path(cur_config.respath_path) / "EDMarketConnector.ico")
|
root.iconbitmap(cur_config.respath_path / "EDMarketConnector.ico")
|
||||||
|
|
||||||
sys_report = get_sys_report(cur_config)
|
sys_report = get_sys_report(cur_config)
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ class AppWindow:
|
|||||||
self.w.wm_iconbitmap(default='EDMarketConnector.ico')
|
self.w.wm_iconbitmap(default='EDMarketConnector.ico')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
image_path = pathlib.Path(config.respath_path) / 'io.edcd.EDMarketConnector.png'
|
image_path = config.respath_path / 'io.edcd.EDMarketConnector.png'
|
||||||
self.w.tk.call('wm', 'iconphoto', self.w, '-default', image=tk.PhotoImage(file=image_path))
|
self.w.tk.call('wm', 'iconphoto', self.w, '-default', image=tk.PhotoImage(file=image_path))
|
||||||
|
|
||||||
# TODO: Export to files and merge from them in future ?
|
# TODO: Export to files and merge from them in future ?
|
||||||
@ -1639,7 +1639,7 @@ class AppWindow:
|
|||||||
# Avoid file length limits if possible
|
# Avoid file length limits if possible
|
||||||
provider = config.get_str('shipyard_provider', default='EDSY')
|
provider = config.get_str('shipyard_provider', default='EDSY')
|
||||||
target = plug.invoke(provider, 'EDSY', 'shipyard_url', loadout, monitor.is_beta)
|
target = plug.invoke(provider, 'EDSY', 'shipyard_url', loadout, monitor.is_beta)
|
||||||
file_name = pathlib.Path(config.app_dir_path) / "last_shipyard.html"
|
file_name = config.app_dir_path / "last_shipyard.html"
|
||||||
|
|
||||||
with open(file_name, 'w') as f:
|
with open(file_name, 'w') as f:
|
||||||
f.write(SHIPYARD_HTML_TEMPLATE.format(
|
f.write(SHIPYARD_HTML_TEMPLATE.format(
|
||||||
|
@ -51,7 +51,7 @@ def addcommodities(data) -> None: # noqa: CCR001
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
commodityfile = pathlib.Path(config.app_dir_path / 'FDevIDs' / 'commodity.csv')
|
commodityfile = config.app_dir_path / 'FDevIDs' / 'commodity.csv'
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
commodityfile = pathlib.Path('FDevIDs/commodity.csv')
|
commodityfile = pathlib.Path('FDevIDs/commodity.csv')
|
||||||
commodities = {}
|
commodities = {}
|
||||||
|
@ -1204,7 +1204,7 @@ def fixup(data: CAPIData) -> CAPIData: # noqa: C901, CCR001 # Can't be usefully
|
|||||||
if not commodity_map:
|
if not commodity_map:
|
||||||
# Lazily populate
|
# Lazily populate
|
||||||
for f in ('commodity.csv', 'rare_commodity.csv'):
|
for f in ('commodity.csv', 'rare_commodity.csv'):
|
||||||
if not (Path(config.app_dir_path) / 'FDevIDs' / f).is_file():
|
if not (config.app_dir_path / 'FDevIDs' / f).is_file():
|
||||||
logger.warning(f'FDevID file {f} not found! Generating output without these commodity name rewrites.')
|
logger.warning(f'FDevID file {f} not found! Generating output without these commodity name rewrites.')
|
||||||
continue
|
continue
|
||||||
with open(config.app_dir_path / 'FDevIDs' / f, 'r') as csvfile:
|
with open(config.app_dir_path / 'FDevIDs' / f, 'r') as csvfile:
|
||||||
|
2
l10n.py
2
l10n.py
@ -177,7 +177,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.
|
||||||
plugin_name = context[len(config.plugin_dir)+1:].split(sep)[0]
|
plugin_name = context[len(config.plugin_dir)+1:].split(sep)[0]
|
||||||
plugin_path = pathlib.Path(config.plugin_dir_path / plugin_name / LOCALISATION_DIR)
|
plugin_path = config.plugin_dir_path / plugin_name / LOCALISATION_DIR
|
||||||
|
|
||||||
if lang:
|
if lang:
|
||||||
contents: dict[str, str] = self.contents(lang=lang, plugin_path=plugin_path)
|
contents: dict[str, str] = self.contents(lang=lang, plugin_path=plugin_path)
|
||||||
|
6
plug.py
6
plug.py
@ -189,12 +189,12 @@ def _load_found_plugins():
|
|||||||
# The intent here is to e.g. have EDMC-Overlay load before any plugins
|
# The intent here is to e.g. have EDMC-Overlay load before any plugins
|
||||||
# that depend on it.
|
# that depend on it.
|
||||||
|
|
||||||
plugin_files = sorted(Path(config.plugin_dir_path).iterdir(), key=lambda p: (
|
plugin_files = sorted(config.plugin_dir_path.iterdir(), key=lambda p: (
|
||||||
not (p / '__init__.py').is_file(), p.name.lower()))
|
not (p / '__init__.py').is_file(), p.name.lower()))
|
||||||
|
|
||||||
for plugin_file in plugin_files:
|
for plugin_file in plugin_files:
|
||||||
name = plugin_file.name
|
name = plugin_file.name
|
||||||
if not (Path(config.plugin_dir_path) / name).is_dir() or name.startswith(('.', '_')):
|
if not (config.plugin_dir_path / name).is_dir() or name.startswith(('.', '_')):
|
||||||
pass
|
pass
|
||||||
elif name.endswith('.disabled'):
|
elif name.endswith('.disabled'):
|
||||||
name, discard = name.rsplit('.', 1)
|
name, discard = name.rsplit('.', 1)
|
||||||
@ -202,7 +202,7 @@ def _load_found_plugins():
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
# Add plugin's folder to load path in case plugin has internal package dependencies
|
# Add plugin's folder to load path in case plugin has internal package dependencies
|
||||||
sys.path.append(str(Path(config.plugin_dir_path) / name))
|
sys.path.append(str(config.plugin_dir_path / name))
|
||||||
|
|
||||||
import EDMCLogging
|
import EDMCLogging
|
||||||
# Create a logger for this 'found' plugin. Must be before the load.py is loaded.
|
# Create a logger for this 'found' plugin. Must be before the load.py is loaded.
|
||||||
|
2
prefs.py
2
prefs.py
@ -58,7 +58,7 @@ def open_folder(file: Path) -> None:
|
|||||||
|
|
||||||
def help_open_system_profiler(parent) -> None:
|
def help_open_system_profiler(parent) -> None:
|
||||||
"""Open the EDMC System Profiler."""
|
"""Open the EDMC System Profiler."""
|
||||||
profiler_path = Path(config.respath_path)
|
profiler_path = config.respath_path
|
||||||
try:
|
try:
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
profiler_path /= 'EDMCSystemProfiler.exe'
|
profiler_path /= 'EDMCSystemProfiler.exe'
|
||||||
|
3
theme.py
3
theme.py
@ -12,7 +12,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import font as tk_font
|
from tkinter import font as tk_font
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
@ -38,7 +37,7 @@ if sys.platform == 'win32':
|
|||||||
AddFontResourceEx.restypes = [LPCWSTR, DWORD, LPCVOID] # type: ignore
|
AddFontResourceEx.restypes = [LPCWSTR, DWORD, LPCVOID] # type: ignore
|
||||||
FR_PRIVATE = 0x10
|
FR_PRIVATE = 0x10
|
||||||
FR_NOT_ENUM = 0x20
|
FR_NOT_ENUM = 0x20
|
||||||
font_path = Path(config.respath) / 'EUROCAPS.TTF'
|
font_path = config.respath_path / 'EUROCAPS.TTF'
|
||||||
AddFontResourceEx(str(font_path), FR_PRIVATE, 0)
|
AddFontResourceEx(str(font_path), FR_PRIVATE, 0)
|
||||||
|
|
||||||
elif sys.platform == 'linux':
|
elif sys.platform == 'linux':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user