From fe90f1f0b32304aaa802aec56fe9fac5dcd1f62f Mon Sep 17 00:00:00 2001 From: A_D <aunderscored@gmail.com> Date: Fri, 28 May 2021 09:42:40 +0200 Subject: [PATCH 1/5] Cleaned up imports, removed incase imports closes EDCD/EDMarketConnector#569 --- EDMC.py | 3 +-- EDMarketConnector.py | 6 +++--- companion.py | 2 -- plug.py | 20 +++++++++----------- plugins/edsm.py | 8 ++++---- setup.py | 2 ++ td.py | 6 ++---- theme.py | 4 ++-- 8 files changed, 23 insertions(+), 28 deletions(-) diff --git a/EDMC.py b/EDMC.py index 4c5283a7..4120fd35 100755 --- a/EDMC.py +++ b/EDMC.py @@ -19,9 +19,8 @@ os.environ["EDMC_NO_UI"] = "1" # See EDMCLogging.py docs. # workaround for https://github.com/EDCD/EDMarketConnector/issues/568 from EDMCLogging import edmclogger, logger, logging - if TYPE_CHECKING: - from logging import trace, TRACE # type: ignore # noqa: F401 + from logging import TRACE # type: ignore # noqa: F401 # needed to make mypy happy edmclogger.set_channels_loglevel(logging.INFO) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index ed4f829c..f6e17e87 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -262,10 +262,10 @@ if __name__ == '__main__': # noqa: C901 # See EDMCLogging.py docs. # isort: off if TYPE_CHECKING: - from logging import trace, TRACE # type: ignore # noqa: F401 - import update + from logging import TRACE # type: ignore # noqa: F401 # Needed to update mypy + # import update # from infi.systray import SysTrayIcon -# isort: on + # isort: on def _(x: str) -> str: """Fake the l10n translation functions for typing.""" diff --git a/companion.py b/companion.py index fd56a4de..d374f169 100644 --- a/companion.py +++ b/companion.py @@ -19,8 +19,6 @@ import urllib.parse import webbrowser from builtins import object, range, str from email.utils import parsedate -# TODO: see https://github.com/EDCD/EDMarketConnector/issues/569 -from http.cookiejar import LWPCookieJar # noqa: F401 - No longer needed but retained in case plugins use it from os.path import join from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, OrderedDict, TypeVar, Union diff --git a/plug.py b/plug.py index eea96ea7..af4a50ac 100644 --- a/plug.py +++ b/plug.py @@ -1,21 +1,18 @@ """ Plugin hooks for EDMC - Ian Norton, Jonathan Harris """ -from builtins import str -from builtins import object -import os import importlib -import sys +import logging import operator -import threading # noqa: F401 - We don't use it, but plugins might -from typing import Optional +import os +import sys import tkinter as tk +from builtins import object, str +from typing import Optional import myNotebook as nb # noqa: N813 - -from config import appcmdname, appname, config +from config import config from EDMCLogging import get_main_logger -import logging logger = get_main_logger() @@ -140,7 +137,7 @@ def load_plugins(master): found = [] # Load any plugins that are also packages first for name in sorted(os.listdir(config.plugin_dir_path), - key = lambda n: (not os.path.isfile(os.path.join(config.plugin_dir_path, n, '__init__.py')), n.lower())): + key=lambda n: (not os.path.isfile(os.path.join(config.plugin_dir_path, n, '__init__.py')), n.lower())): if not os.path.isdir(os.path.join(config.plugin_dir_path, name)) or name[0] in ['.', '_']: pass elif name.endswith('.disabled'): @@ -172,6 +169,7 @@ def provides(fn_name): """ return [p.name for p in PLUGINS if p._get_func(fn_name)] + def invoke(plugin_name, fallback, fn_name, *args): """ Invoke a function on a named plugin @@ -187,7 +185,7 @@ def invoke(plugin_name, fallback, fn_name, *args): return plugin._get_func(fn_name)(*args) for plugin in PLUGINS: if plugin.name == fallback: - assert plugin._get_func(fn_name), plugin.name # fallback plugin should provide the function + assert plugin._get_func(fn_name), plugin.name # fallback plugin should provide the function return plugin._get_func(fn_name)(*args) diff --git a/plugins/edsm.py b/plugins/edsm.py index 422d0b56..7905f657 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -9,19 +9,19 @@ # 4) Ensure the EDSM API call(back) for setting the image at end of system # text is always fired. i.e. CAPI cmdr_data() processing. -from companion import CAPIData import json import sys import tkinter as tk from queue import Queue from threading import Thread -from typing import TYPE_CHECKING, Any, List, Mapping, MutableMapping, Optional, Tuple, cast +from typing import TYPE_CHECKING, Any, List, Mapping, MutableMapping, Optional, Tuple import requests import killswitch import myNotebook as nb # noqa: N813 import plug +from companion import CAPIData from config import applongname, appversion, config from EDMCLogging import get_main_logger from ttkHyperlinkLabel import HyperlinkLabel @@ -629,11 +629,11 @@ def worker() -> None: else: if msg_num // 100 == 1: - # logger.trace('Overall OK') + # logger.trace('Overall OK') pass elif msg_num // 100 == 5: - # logger.trace('Event(s) not currently processed, but saved for later') + # logger.trace('Event(s) not currently processed, but saved for later') pass else: diff --git a/setup.py b/setup.py index 372b4477..98a3ba4f 100755 --- a/setup.py +++ b/setup.py @@ -191,6 +191,8 @@ elif sys.platform == 'win32': 'shutil', # Included for plugins 'timeout_session', 'zipfile', # Included for plugins + 'threading', # Included for plugins (though it should always be there anyway) + 'http', # Included for plugins ], 'excludes': [ 'distutils', diff --git a/td.py b/td.py index 5f05b732..2f91b4a2 100644 --- a/td.py +++ b/td.py @@ -1,13 +1,11 @@ # Export to Trade Dangerous -from os.path import join +import time from collections import defaultdict -import codecs -import numbers from operator import itemgetter +from os.path import join from platform import system from sys import platform -import time from config import applongname, appversion, config diff --git a/theme.py b/theme.py index d05a52e6..702edf3c 100644 --- a/theme.py +++ b/theme.py @@ -12,14 +12,14 @@ from sys import platform from tkinter import font as tkFont from tkinter import ttk -from config import applongname, appname, config +from config import config from ttkHyperlinkLabel import HyperlinkLabel if __debug__: from traceback import print_exc if platform == "linux": - from ctypes import POINTER, c_char_p, c_int, c_long, c_uint, c_ulong, c_void_p, cdll, Structure, byref + from ctypes import POINTER, Structure, byref, c_char_p, c_int, c_long, c_uint, c_ulong, c_void_p, cdll if platform == 'win32': From bda440df3b8acb2ef634f2a04e14a5a9e40d42f0 Mon Sep 17 00:00:00 2001 From: A_D <aunderscored@gmail.com> Date: Fri, 28 May 2021 10:53:00 +0200 Subject: [PATCH 2/5] Moved packages to packages section --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 98a3ba4f..c6d3ccce 100755 --- a/setup.py +++ b/setup.py @@ -185,14 +185,14 @@ elif sys.platform == 'win32': 'optimize': 2, 'packages': [ 'sqlite3', # Included for plugins + 'threading', # Included for plugins (though it should always be there anyway) + 'http', # Included for plugins ], 'includes': [ 'dataclasses', 'shutil', # Included for plugins 'timeout_session', 'zipfile', # Included for plugins - 'threading', # Included for plugins (though it should always be there anyway) - 'http', # Included for plugins ], 'excludes': [ 'distutils', From 35c45269acdfa5df2184fbfdaddb536c7af61729 Mon Sep 17 00:00:00 2001 From: A_D <aunderscored@gmail.com> Date: Fri, 28 May 2021 10:58:00 +0200 Subject: [PATCH 3/5] threading isnt a package, apparently --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c6d3ccce..6d2eccd4 100755 --- a/setup.py +++ b/setup.py @@ -185,13 +185,13 @@ elif sys.platform == 'win32': 'optimize': 2, 'packages': [ 'sqlite3', # Included for plugins - 'threading', # Included for plugins (though it should always be there anyway) 'http', # Included for plugins ], 'includes': [ 'dataclasses', 'shutil', # Included for plugins 'timeout_session', + 'threading', # Included for plugins (though it should always be there anyway) 'zipfile', # Included for plugins ], 'excludes': [ From 29b10464f7caa52b77d6f69ea6108f73b55788b4 Mon Sep 17 00:00:00 2001 From: A_D <aunderscored@gmail.com> Date: Fri, 28 May 2021 14:47:26 +0200 Subject: [PATCH 4/5] Removed http --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 6d2eccd4..f406c7d6 100755 --- a/setup.py +++ b/setup.py @@ -185,7 +185,6 @@ elif sys.platform == 'win32': 'optimize': 2, 'packages': [ 'sqlite3', # Included for plugins - 'http', # Included for plugins ], 'includes': [ 'dataclasses', From a022b150aceb598df8108440264e65db3d437d86 Mon Sep 17 00:00:00 2001 From: A_D <aunderscored@gmail.com> Date: Fri, 28 May 2021 14:58:13 +0200 Subject: [PATCH 5/5] Removed threading --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index f406c7d6..372b4477 100755 --- a/setup.py +++ b/setup.py @@ -190,7 +190,6 @@ elif sys.platform == 'win32': 'dataclasses', 'shutil', # Included for plugins 'timeout_session', - 'threading', # Included for plugins (though it should always be there anyway) 'zipfile', # Included for plugins ], 'excludes': [