From d6efcf784dbca943436a0d25218ccae4a19ccc43 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Fri, 4 Aug 2023 01:45:34 -0400 Subject: [PATCH] #2051 And another 3! --- plugins/inara.py | 5 ++--- prefs.py | 27 ++++++++++++++++----------- protocol.py | 13 +++++-------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 7f7abbd18..f4052ad3a 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -174,7 +174,7 @@ def system_url(system_name: str) -> str: return requests.utils.requote_uri(f'https://inara.cz/galaxy-starsystem/' f'?search={this.system_address}') - elif system_name: + if system_name: return requests.utils.requote_uri(f'https://inara.cz/galaxy-starsystem/' f'?search={system_name}') @@ -382,8 +382,7 @@ def credentials(cmdr: Optional[str]) -> Optional[str]: if cmdr in cmdrs and config.get_list('inara_apikeys'): return config.get_list('inara_apikeys')[cmdrs.index(cmdr)] - else: - return None + return None def journal_entry( # noqa: C901, CCR001 diff --git a/prefs.py b/prefs.py index 51c7bc47c..57204db9a 100644 --- a/prefs.py +++ b/prefs.py @@ -384,10 +384,10 @@ def __setup_output_tab(self, root_notebook: ttk.Notebook) -> None: self.outdir_entry.grid(columnspan=2, padx=self.PADX, pady=(0, self.PADY), sticky=tk.EW, row=row.get()) if sys.platform == 'darwin': - text = (_('Change...')) # LANG: macOS Preferences - files location selection button + text = _('Change...') # LANG: macOS Preferences - files location selection button else: - text = (_('Browse...')) # LANG: NOT-macOS Settings - files location selection button + text = _('Browse...') # LANG: NOT-macOS Settings - files location selection button self.outbutton = nb.Button( output_frame, @@ -434,10 +434,10 @@ def __setup_config_tab(self, notebook: ttk.Notebook) -> None: # noqa: CCR001 self.logdir_entry.grid(columnspan=4, padx=self.PADX, pady=(0, self.PADY), sticky=tk.EW, row=row.get()) if sys.platform == 'darwin': - text = (_('Change...')) # LANG: macOS Preferences - files location selection button + text = _('Change...') # LANG: macOS Preferences - files location selection button else: - text = (_('Browse...')) # LANG: NOT-macOS Setting - files location selection button + text = _('Browse...') # LANG: NOT-macOS Setting - files location selection button self.logbutton = nb.Button( config_frame, @@ -924,7 +924,7 @@ def __setup_plugin_tab(self, notebook: ttk.Notebook) -> None: # noqa: CCR001 ).grid(columnspan=2, padx=self.PADX, pady=10, sticky=tk.NSEW, row=row.get()) enabled_plugins = list(filter(lambda x: x.folder and x.module, plug.PLUGINS)) - if len(enabled_plugins): + if enabled_plugins: ttk.Separator(plugins_frame, orient=tk.HORIZONTAL).grid( columnspan=3, padx=self.PADX, pady=self.PADY * 8, sticky=tk.EW ) @@ -946,7 +946,7 @@ def __setup_plugin_tab(self, notebook: ttk.Notebook) -> None: # noqa: CCR001 ############################################################ # Show which plugins don't have Python 3.x support ############################################################ - if len(plug.PLUGINS_not_py3): + if plug.PLUGINS_not_py3: ttk.Separator(plugins_frame, orient=tk.HORIZONTAL).grid( columnspan=3, padx=self.PADX, pady=self.PADY * 8, sticky=tk.EW, row=row.get() ) @@ -966,24 +966,29 @@ def __setup_plugin_tab(self, notebook: ttk.Notebook) -> None: # noqa: CCR001 ).grid(columnspan=2, padx=self.PADX, sticky=tk.W) ############################################################ - disabled_plugins = list(filter(lambda x: x.folder and not x.module, plug.PLUGINS)) - if len(disabled_plugins): + # Get disabled plugins (plugins without a folder or module) + disabled_plugins = [x for x in plug.PLUGINS if x.folder and not x.module] + + if disabled_plugins: + # Create a separator ttk.Separator(plugins_frame, orient=tk.HORIZONTAL).grid( columnspan=3, padx=self.PADX, pady=self.PADY * 8, sticky=tk.EW, row=row.get() ) + # Label for the section of disabled plugins nb.Label( plugins_frame, # LANG: Lable on list of user-disabled plugins - text=_('Disabled Plugins')+':' # List of plugins in settings + text=_('Disabled Plugins') + ':' # List of plugins in settings ).grid(padx=self.PADX, sticky=tk.W, row=row.get()) + # Show disabled plugins for plugin in disabled_plugins: nb.Label(plugins_frame, text=plugin.name).grid( - columnspan=2, padx=self.PADX*2, sticky=tk.W, row=row.get() + columnspan=2, padx=self.PADX * 2, sticky=tk.W, row=row.get() ) # LANG: Label on Settings > Plugins tab - notebook.add(plugins_frame, text=_('Plugins')) # Tab heading in settings + notebook.add(plugins_frame, text=_('Plugins')) # Tab heading in settings def cmdrchanged(self, event=None): """ diff --git a/protocol.py b/protocol.py index cf3a9f755..be95d8a03 100644 --- a/protocol.py +++ b/protocol.py @@ -124,9 +124,8 @@ def handleEvent_withReplyEvent_(self, event, replyEvent) -> None: # noqa: N802 # This could be false if you use auth_force_edmc_protocol, but then you get to keep the pieces assert sys.platform == 'win32' # spell-checker: words HBRUSH HICON WPARAM wstring WNDCLASS HMENU HGLOBAL - from ctypes import windll # type: ignore from ctypes import ( # type: ignore - POINTER, WINFUNCTYPE, Structure, byref, c_long, c_void_p, create_unicode_buffer, wstring_at + windll, POINTER, WINFUNCTYPE, Structure, byref, c_long, c_void_p, create_unicode_buffer, wstring_at ) from ctypes.wintypes import ( ATOM, BOOL, DWORD, HBRUSH, HGLOBAL, HICON, HINSTANCE, HMENU, HWND, INT, LPARAM, LPCWSTR, LPMSG, LPVOID, LPWSTR, @@ -426,9 +425,8 @@ def parse(self) -> bool: protocolhandler.event(url) # noqa: F821 self.send_response(200) return True - else: - self.send_response(404) # Not found - return False + self.send_response(404) # Not found + return False def do_HEAD(self) -> None: # noqa: N802 # Required to override """Handle HEAD Request.""" @@ -459,14 +457,13 @@ def get_handler_impl() -> Type[GenericProtocolHandler]: if sys.platform == 'darwin' and getattr(sys, 'frozen', False): return DarwinProtocolHandler # pyright: reportUnboundVariable=false - elif ( + if ( (sys.platform == 'win32' and config.auth_force_edmc_protocol) or (getattr(sys, 'frozen', False) and not is_wine and not config.auth_force_localserver) ): return WindowsProtocolHandler - else: - return LinuxProtocolHandler + return LinuxProtocolHandler # *late init* singleton