1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-12 15:27:14 +03:00

[Nit] Cleanup some Flake8

This commit is contained in:
David Sangrey 2024-03-28 10:49:01 -04:00
parent 56a4ae25e0
commit b5a4ee6ed2
No known key found for this signature in database
GPG Key ID: 3AEADBB0186884BC
4 changed files with 21 additions and 23 deletions

View File

@ -467,7 +467,6 @@ def get_config(*args, **kwargs) -> AbstractConfig:
:param kwargs: Args to be passed through to implementation. :param kwargs: Args to be passed through to implementation.
:return: Instance of the implementation. :return: Instance of the implementation.
""" """
if sys.platform == "win32": # pragma: sys-platform-win32 if sys.platform == "win32": # pragma: sys-platform-win32
from .windows import WinConfig from .windows import WinConfig
return WinConfig(*args, **kwargs) return WinConfig(*args, **kwargs)

View File

@ -27,7 +27,6 @@ import os
import pathlib import pathlib
import re import re
import sqlite3 import sqlite3
import sys
import tkinter as tk import tkinter as tk
from platform import system from platform import system
from textwrap import dedent from textwrap import dedent

View File

@ -26,6 +26,7 @@ is_wine = False
if sys.platform == 'win32': if sys.platform == 'win32':
from ctypes import windll # type: ignore from ctypes import windll # type: ignore
try: try:
if windll.ntdll.wine_get_version: if windll.ntdll.wine_get_version:
is_wine = True is_wine = True
@ -58,13 +59,13 @@ class GenericProtocolHandler:
self.master.event_generate('<<CompanionAuthEvent>>', when="tail") self.master.event_generate('<<CompanionAuthEvent>>', when="tail")
if (config.auth_force_edmc_protocol if (config.auth_force_edmc_protocol # noqa: C901
or ( or (
sys.platform == 'win32' sys.platform == 'win32'
and getattr(sys, 'frozen', False) and getattr(sys, 'frozen', False)
and not is_wine and not is_wine
and not config.auth_force_localserver and not config.auth_force_localserver
)): )):
# This could be false if you use auth_force_edmc_protocol, but then you get to keep the pieces # This could be false if you use auth_force_edmc_protocol, but then you get to keep the pieces
assert sys.platform == 'win32' assert sys.platform == 'win32'
# spell-checker: words HBRUSH HICON WPARAM wstring WNDCLASS HMENU HGLOBAL # spell-checker: words HBRUSH HICON WPARAM wstring WNDCLASS HMENU HGLOBAL
@ -186,11 +187,11 @@ if (config.auth_force_edmc_protocol
# which we can read out as shown below, and then compare. # which we can read out as shown below, and then compare.
target_is_valid = lparam_low == 0 or ( target_is_valid = lparam_low == 0 or (
GlobalGetAtomNameW(lparam_low, service, 256) and service.value == appname GlobalGetAtomNameW(lparam_low, service, 256) and service.value == appname
) )
topic_is_valid = lparam_high == 0 or ( topic_is_valid = lparam_high == 0 or (
GlobalGetAtomNameW(lparam_high, topic, 256) and topic.value.lower() == 'system' GlobalGetAtomNameW(lparam_high, topic, 256) and topic.value.lower() == 'system'
) )
if target_is_valid and topic_is_valid: if target_is_valid and topic_is_valid:
@ -251,15 +252,15 @@ if (config.auth_force_edmc_protocol
# https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexw # https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexw
hwnd = CreateWindowExW( hwnd = CreateWindowExW(
0, # dwExStyle 0, # dwExStyle
wndclass.lpszClassName, # lpClassName wndclass.lpszClassName, # lpClassName
"DDE Server", # lpWindowName "DDE Server", # lpWindowName
0, # dwStyle 0, # dwStyle
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, # X, Y, nWidth, nHeight CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, # X, Y, nWidth, nHeight
self.master.winfo_id(), # hWndParent # Don't use HWND_MESSAGE since the window won't get DDE broadcasts self.master.winfo_id(), # hWndParent # Don't use HWND_MESSAGE since the window won't get DDE broadcasts
None, # hMenu None, # hMenu
wndclass.hInstance, # hInstance wndclass.hInstance, # hInstance
None # lpParam None # lpParam
) )
msg = MSG() msg = MSG()
@ -421,10 +422,9 @@ def get_handler_impl() -> Type[GenericProtocolHandler]:
:return: An instantiatable GenericProtocolHandler :return: An instantiatable GenericProtocolHandler
""" """
if ( if (
(sys.platform == 'win32' and config.auth_force_edmc_protocol) (sys.platform == 'win32' and config.auth_force_edmc_protocol)
or (getattr(sys, 'frozen', False) and not is_wine and not config.auth_force_localserver) or (getattr(sys, 'frozen', False) and not is_wine and not config.auth_force_localserver)
): ):
return WindowsProtocolHandler return WindowsProtocolHandler

View File

@ -5,8 +5,8 @@ import numbers
import sys import sys
import warnings import warnings
from configparser import NoOptionError from configparser import NoOptionError
from os import getenv, makedirs, mkdir, pardir from os import getenv, makedirs, mkdir
from os.path import dirname, expanduser, isdir, join, normpath from os.path import dirname, expanduser, isdir, join
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from config import applongname, appname, update_interval from config import applongname, appname, update_interval
from EDMCLogging import get_main_logger from EDMCLogging import get_main_logger
@ -109,7 +109,7 @@ class OldConfig:
OUT_EDDN_DELAY = 4096 OUT_EDDN_DELAY = 4096
OUT_STATION_ANY = OUT_EDDN_SEND_STATION_DATA | OUT_MKT_TD | OUT_MKT_CSV OUT_STATION_ANY = OUT_EDDN_SEND_STATION_DATA | OUT_MKT_TD | OUT_MKT_CSV
if sys.platform == 'win32': if sys.platform == 'win32': # noqa: C901
def __init__(self): def __init__(self):
self.app_dir = join(known_folder_path(FOLDERID_LocalAppData), appname) # type: ignore self.app_dir = join(known_folder_path(FOLDERID_LocalAppData), appname) # type: ignore