1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-09 11:52:27 +03:00

Cleaned up imports, removed incase imports

closes EDCD/EDMarketConnector#569
This commit is contained in:
A_D 2021-05-28 09:42:40 +02:00
parent f3b8df6548
commit fe90f1f0b3
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4
8 changed files with 23 additions and 28 deletions

View File

@ -19,9 +19,8 @@ os.environ["EDMC_NO_UI"] = "1"
# See EDMCLogging.py docs. # See EDMCLogging.py docs.
# workaround for https://github.com/EDCD/EDMarketConnector/issues/568 # workaround for https://github.com/EDCD/EDMarketConnector/issues/568
from EDMCLogging import edmclogger, logger, logging from EDMCLogging import edmclogger, logger, logging
if TYPE_CHECKING: 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) edmclogger.set_channels_loglevel(logging.INFO)

View File

@ -262,10 +262,10 @@ if __name__ == '__main__': # noqa: C901
# See EDMCLogging.py docs. # See EDMCLogging.py docs.
# isort: off # isort: off
if TYPE_CHECKING: if TYPE_CHECKING:
from logging import trace, TRACE # type: ignore # noqa: F401 from logging import TRACE # type: ignore # noqa: F401 # Needed to update mypy
import update # import update
# from infi.systray import SysTrayIcon # from infi.systray import SysTrayIcon
# isort: on # isort: on
def _(x: str) -> str: def _(x: str) -> str:
"""Fake the l10n translation functions for typing.""" """Fake the l10n translation functions for typing."""

View File

@ -19,8 +19,6 @@ import urllib.parse
import webbrowser import webbrowser
from builtins import object, range, str from builtins import object, range, str
from email.utils import parsedate 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 os.path import join
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, OrderedDict, TypeVar, Union from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, OrderedDict, TypeVar, Union

18
plug.py
View File

@ -1,21 +1,18 @@
""" """
Plugin hooks for EDMC - Ian Norton, Jonathan Harris Plugin hooks for EDMC - Ian Norton, Jonathan Harris
""" """
from builtins import str
from builtins import object
import os
import importlib import importlib
import sys import logging
import operator import operator
import threading # noqa: F401 - We don't use it, but plugins might import os
from typing import Optional import sys
import tkinter as tk import tkinter as tk
from builtins import object, str
from typing import Optional
import myNotebook as nb # noqa: N813 import myNotebook as nb # noqa: N813
from config import config
from config import appcmdname, appname, config
from EDMCLogging import get_main_logger from EDMCLogging import get_main_logger
import logging
logger = get_main_logger() logger = get_main_logger()
@ -140,7 +137,7 @@ def load_plugins(master):
found = [] found = []
# Load any plugins that are also packages first # Load any plugins that are also packages first
for name in sorted(os.listdir(config.plugin_dir_path), 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 ['.', '_']: if not os.path.isdir(os.path.join(config.plugin_dir_path, name)) or name[0] in ['.', '_']:
pass pass
elif name.endswith('.disabled'): 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)] return [p.name for p in PLUGINS if p._get_func(fn_name)]
def invoke(plugin_name, fallback, fn_name, *args): def invoke(plugin_name, fallback, fn_name, *args):
""" """
Invoke a function on a named plugin Invoke a function on a named plugin

View File

@ -9,19 +9,19 @@
# 4) Ensure the EDSM API call(back) for setting the image at end of system # 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. # text is always fired. i.e. CAPI cmdr_data() processing.
from companion import CAPIData
import json import json
import sys import sys
import tkinter as tk import tkinter as tk
from queue import Queue from queue import Queue
from threading import Thread 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 requests
import killswitch import killswitch
import myNotebook as nb # noqa: N813 import myNotebook as nb # noqa: N813
import plug import plug
from companion import CAPIData
from config import applongname, appversion, config from config import applongname, appversion, config
from EDMCLogging import get_main_logger from EDMCLogging import get_main_logger
from ttkHyperlinkLabel import HyperlinkLabel from ttkHyperlinkLabel import HyperlinkLabel

View File

@ -191,6 +191,8 @@ elif sys.platform == 'win32':
'shutil', # Included for plugins 'shutil', # Included for plugins
'timeout_session', 'timeout_session',
'zipfile', # Included for plugins 'zipfile', # Included for plugins
'threading', # Included for plugins (though it should always be there anyway)
'http', # Included for plugins
], ],
'excludes': [ 'excludes': [
'distutils', 'distutils',

6
td.py
View File

@ -1,13 +1,11 @@
# Export to Trade Dangerous # Export to Trade Dangerous
from os.path import join import time
from collections import defaultdict from collections import defaultdict
import codecs
import numbers
from operator import itemgetter from operator import itemgetter
from os.path import join
from platform import system from platform import system
from sys import platform from sys import platform
import time
from config import applongname, appversion, config from config import applongname, appversion, config

View File

@ -12,14 +12,14 @@ from sys import platform
from tkinter import font as tkFont from tkinter import font as tkFont
from tkinter import ttk from tkinter import ttk
from config import applongname, appname, config from config import config
from ttkHyperlinkLabel import HyperlinkLabel from ttkHyperlinkLabel import HyperlinkLabel
if __debug__: if __debug__:
from traceback import print_exc from traceback import print_exc
if platform == "linux": 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': if platform == 'win32':