1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-05-03 17:01:31 +03:00

[Minor] Slight Refactorings

This commit is contained in:
David Sangrey 2025-04-13 13:44:51 -04:00
parent 26f06b7bf0
commit 5c14a7afc7
No known key found for this signature in database
GPG Key ID: 3AEADBB0186884BC
4 changed files with 24 additions and 30 deletions

View File

@ -338,8 +338,6 @@ class EDMCContextFilter(logging.Filter):
# <https://stackoverflow.com/questions/2203424/python-how-to-retrieve-class-information-from-a-frame-object#2220759>
try:
frame_info = inspect.getframeinfo(frame)
# raise(IndexError) # TODO: Remove, only for testing
except Exception:
# Separate from the print below to guarantee we see at least this much.
print('EDMCLogging:EDMCContextFilter:caller_attributes(): Failed in `inspect.getframinfo(frame)`')

View File

@ -38,17 +38,17 @@ from monitor import monitor
from EDMCLogging import get_main_logger
def get_sys_report(config: config.AbstractConfig) -> str:
def get_sys_report(active_config: config.AbstractConfig) -> str:
"""Gather system information about Elite, the Host Computer, and EDMC."""
# Calculate Requested Information
plt = platform.uname()
locale.setlocale(locale.LC_ALL, "")
lcl = locale.getlocale()
monitor.currentdir = config.get_str(
"journaldir", default=config.default_journal_dir
monitor.currentdir = active_config.get_str(
"journaldir", default=active_config.default_journal_dir
)
if not monitor.currentdir:
monitor.currentdir = config.default_journal_dir
monitor.currentdir = active_config.default_journal_dir
try:
logfile = monitor.journal_newest_filename(monitor.currentdir)
if logfile is None:
@ -108,21 +108,21 @@ def copy_sys_report(root: tk.Tk, report: str) -> None:
messagebox.showinfo("System Profiler", "System Report copied to Clipboard", parent=root)
def main() -> None:
def main(active_config: config.AbstractConfig) -> None:
"""Entry Point for the System Profiler."""
# Now Let's Begin
root: tk.Tk = tk.Tk()
root.withdraw() # Hide the window initially to calculate the dimensions
try:
icon_image = tk.PhotoImage(
file=path.join(cur_config.respath_path, "io.edcd.EDMarketConnector.png")
file=path.join(active_config.respath_path, "io.edcd.EDMarketConnector.png")
)
root.iconphoto(True, icon_image)
except tk.TclError:
root.iconbitmap(path.join(cur_config.respath_path, "EDMarketConnector.ico"))
root.iconbitmap(path.join(active_config.respath_path, "EDMarketConnector.ico"))
sys_report = get_sys_report(cur_config)
sys_report = get_sys_report(active_config)
# Set up styling
style = ttk.Style(root)
@ -182,7 +182,8 @@ if __name__ == "__main__":
# Args: Only work if not frozen
parser = argparse.ArgumentParser(
prog=appname,
description="Prints diagnostic and debugging information about the current EDMC configuration.",
description="Prints diagnostic and debugging information "
"about the current EDMC configuration.",
)
parser.add_argument(
"--out-console",
@ -203,4 +204,4 @@ if __name__ == "__main__":
print(sys_report)
sys.exit(0)
main()
main(cur_config)

View File

@ -840,8 +840,7 @@ class AppWindow:
r' if downgrading between major versions with significant changes.\r\n\r\n'
'Do you want to open GitHub to download the latest release?'
)
update_msg = update_msg.replace('\\n', '\n')
update_msg = update_msg.replace('\\r', '\r')
update_msg = update_msg.replace('\\n', '\n').replace('\\r', '\r')
stable_popup = tk.messagebox.askyesno(title=title, message=update_msg)
if stable_popup:
webbrowser.open("https://github.com/EDCD/eDMarketConnector/releases/latest")
@ -2064,17 +2063,15 @@ def validate_providers():
# LANG: Popup-text about Reset Providers
popup_text = tr.tl(r'One or more of your URL Providers were invalid, and have been reset:\r\n\r\n')
for provider in reset_providers:
for provider, (old_prov, new_prov) in reset_providers.items():
# LANG: Text About What Provider Was Reset
popup_text += tr.tl(r'{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}\r\n')
popup_text = popup_text.format(
popup_text += tr.tl(r'{PROVIDER} was set to {OLDPROV}, and has been reset to {NEWPROV}\r\n').format(
PROVIDER=provider,
OLDPROV=reset_providers[provider][0],
NEWPROV=reset_providers[provider][1]
OLDPROV=old_prov,
NEWPROV=new_prov
)
# And now we do need these to be actual \r\n
popup_text = popup_text.replace('\\n', '\n')
popup_text = popup_text.replace('\\r', '\r')
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')
tk.messagebox.showinfo(
# LANG: Popup window title for Reset Providers
@ -2246,8 +2243,7 @@ sys.path: {sys.path}'''
detail = tr.tl( # LANG: EDMC Critical Error Details
r"Here's what EDMC Detected:\r\n\r\n{ERR}\r\n\r\nDo you want to file a Bug Report on GitHub?"
).format(ERR=err)
detail = detail.replace('\\n', '\n')
detail = detail.replace('\\r', '\r')
detail = detail.replace('\\n', '\n').replace('\\r', '\r')
msg = tk.messagebox.askyesno(
title=title, message=message, detail=detail, icon=tkinter.messagebox.ERROR, type=tkinter.messagebox.YESNO,
parent=root
@ -2278,8 +2274,7 @@ sys.path: {sys.path}'''
DISABLED='.disabled'
)
# And now we do need these to be actual \r\n
popup_text = popup_text.replace('\\n', '\n')
popup_text = popup_text.replace('\\r', '\r')
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')
tk.messagebox.showinfo(
# LANG: Popup window title for list of 'broken' plugins that failed to load
@ -2309,8 +2304,7 @@ sys.path: {sys.path}'''
DISABLED='.disabled'
)
# And now we do need these to be actual \r\n
popup_text = popup_text.replace('\\n', '\n')
popup_text = popup_text.replace('\\r', '\r')
popup_text = popup_text.replace('\\n', '\n').replace('\\r', '\r')
tk.messagebox.showinfo(
# LANG: Popup window title for list of 'enabled' plugins that don't work with Python 3.x

View File

@ -829,7 +829,8 @@ class PreferencesDialog(tk.Toplevel):
appearance_frame,
# LANG: Appearance - Help/hint text for UI scaling selection
text=tr.tl('100 means Default{CR}Restart Required for{CR}changes to take effect!')
).grid(column=3, padx=self.PADX, pady=self.PADY, sticky=tk.E, row=cur_row)
) # E1111
self.ui_scaling_defaultis.grid(column=3, padx=self.PADX, pady=self.PADY, sticky=tk.E, row=cur_row)
# Transparency slider
ttk.Separator(appearance_frame, orient=tk.HORIZONTAL).grid(
@ -1310,10 +1311,10 @@ class PreferencesDialog(tk.Toplevel):
self._destroy()
# Send to the Post Config if we updated the update branch or need to restart
post_flags = {
'Update': True if self.curr_update_track != self.update_paths.get() else False,
'Update': self.curr_update_track != self.update_paths.get(), # Just needs bool not true if else false
'Track': self.update_paths.get(),
'Parent': self,
'Restart_Req': True if self.req_restart else False
'Restart_Req': self.req_restart # Sipmle Bool Needed
}
if self.callback:
self.callback(**post_flags)