mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-18 09:57:40 +03:00
[Minor] Minor Code Tweaks
Officially Deprecates ttkHyperlinkLabel/openurl() function, a few minor code readability updates, and updates dependencies
This commit is contained in:
parent
b0b9113e51
commit
57b00c6105
2
l10n.py
2
l10n.py
@ -25,7 +25,7 @@ from config import config
|
|||||||
from EDMCLogging import get_main_logger
|
from EDMCLogging import get_main_logger
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
def _(x: str) -> str: ...
|
def _(x: str) -> str: return x
|
||||||
|
|
||||||
# Note that this is also done in EDMarketConnector.py, and thus removing this here may not have a desired effect
|
# Note that this is also done in EDMarketConnector.py, and thus removing this here may not have a desired effect
|
||||||
try:
|
try:
|
||||||
|
@ -5,7 +5,7 @@ wheel
|
|||||||
# We can't rely on just picking this up from either the base (not venv),
|
# We can't rely on just picking this up from either the base (not venv),
|
||||||
# or venv-init-time version. Specify here so that dependabot will prod us
|
# or venv-init-time version. Specify here so that dependabot will prod us
|
||||||
# about new versions.
|
# about new versions.
|
||||||
setuptools==69.0.2
|
setuptools==69.0.3
|
||||||
|
|
||||||
# Static analysis tools
|
# Static analysis tools
|
||||||
flake8==6.1.0
|
flake8==6.1.0
|
||||||
@ -18,7 +18,7 @@ flake8-noqa==1.3.2
|
|||||||
flake8-polyfill==1.0.2
|
flake8-polyfill==1.0.2
|
||||||
flake8-use-fstring==1.4
|
flake8-use-fstring==1.4
|
||||||
|
|
||||||
mypy==1.7.1
|
mypy==1.8.0
|
||||||
pep8-naming==0.13.3
|
pep8-naming==0.13.3
|
||||||
safety==2.3.5
|
safety==2.3.5
|
||||||
types-requests==2.31.0.10
|
types-requests==2.31.0.10
|
||||||
@ -28,7 +28,7 @@ types-pkg-resources==0.1.3
|
|||||||
autopep8==2.0.4
|
autopep8==2.0.4
|
||||||
|
|
||||||
# Git pre-commit checking
|
# Git pre-commit checking
|
||||||
pre-commit==3.5.0
|
pre-commit==3.6.0
|
||||||
|
|
||||||
# HTML changelogs
|
# HTML changelogs
|
||||||
grip==4.6.2
|
grip==4.6.2
|
||||||
@ -40,7 +40,7 @@ py2exe==0.13.0.1; sys_platform == 'win32'
|
|||||||
# Testing
|
# Testing
|
||||||
pytest==7.4.3
|
pytest==7.4.3
|
||||||
pytest-cov==4.1.0 # Pytest code coverage support
|
pytest-cov==4.1.0 # Pytest code coverage support
|
||||||
coverage[toml]==7.3.2 # pytest-cov dep. This is here to ensure that it includes TOML support for pyproject.toml configs
|
coverage[toml]==7.3.4 # pytest-cov dep. This is here to ensure that it includes TOML support for pyproject.toml configs
|
||||||
coverage-conditional-plugin==0.9.0
|
coverage-conditional-plugin==0.9.0
|
||||||
# For manipulating folder permissions and the like.
|
# For manipulating folder permissions and the like.
|
||||||
pywin32==306; sys_platform == 'win32'
|
pywin32==306; sys_platform == 'win32'
|
||||||
|
4
stats.py
4
stats.py
@ -5,6 +5,8 @@ Copyright (c) EDCD, All Rights Reserved
|
|||||||
Licensed under the GNU General Public License.
|
Licensed under the GNU General Public License.
|
||||||
See LICENSE file.
|
See LICENSE file.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
@ -22,7 +24,7 @@ from monitor import monitor
|
|||||||
logger = EDMCLogging.get_main_logger()
|
logger = EDMCLogging.get_main_logger()
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
def _(x: str) -> str: ...
|
def _(x: str) -> str: return x
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
import ctypes
|
import ctypes
|
||||||
|
2
td.py
2
td.py
@ -32,7 +32,7 @@ def export(data: CAPIData) -> None:
|
|||||||
with open(data_path / data_filename, 'wb') as h:
|
with open(data_path / data_filename, 'wb') as h:
|
||||||
# Format described here: https://github.com/eyeonus/Trade-Dangerous/wiki/Price-Data
|
# Format described here: https://github.com/eyeonus/Trade-Dangerous/wiki/Price-Data
|
||||||
h.write('#! trade.py import -\n'.encode('utf-8'))
|
h.write('#! trade.py import -\n'.encode('utf-8'))
|
||||||
this_platform = sys.platform == 'darwin' and "Mac OS" or system()
|
this_platform = "Mac OS" if sys.platform == 'darwin' else system()
|
||||||
cmdr_name = data['commander']['name'].strip()
|
cmdr_name = data['commander']['name'].strip()
|
||||||
h.write(
|
h.write(
|
||||||
f'# Created by {applongname} {appversion()} on {this_platform} for Cmdr {cmdr_name}.\n'.encode('utf-8')
|
f'# Created by {applongname} {appversion()} on {this_platform} for Cmdr {cmdr_name}.\n'.encode('utf-8')
|
||||||
|
@ -22,20 +22,21 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
import warnings
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from tkinter import font as tk_font
|
from tkinter import font as tk_font
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
def _(x: str) -> str: ...
|
def _(x: str) -> str: return x
|
||||||
|
|
||||||
|
|
||||||
# FIXME: Split this into multi-file module to separate the platforms
|
# FIXME: Split this into multi-file module to separate the platforms
|
||||||
class HyperlinkLabel(sys.platform == 'darwin' and tk.Label or ttk.Label): # type: ignore
|
class HyperlinkLabel(sys.platform == 'darwin' and tk.Label or ttk.Label): # type: ignore
|
||||||
"""Clickable label for HTTP links."""
|
"""Clickable label for HTTP links."""
|
||||||
|
|
||||||
def __init__(self, master: tk.Frame | None = None, **kw: Any) -> None:
|
def __init__(self, master: ttk.Frame | None = None, **kw: Any) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize the HyperlinkLabel.
|
Initialize the HyperlinkLabel.
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ class HyperlinkLabel(sys.platform == 'darwin' and tk.Label or ttk.Label): # typ
|
|||||||
url = self.url(self['text']) if callable(self.url) else self.url
|
url = self.url(self['text']) if callable(self.url) else self.url
|
||||||
if url:
|
if url:
|
||||||
self._leave(event) # Remove underline before we change window to browser
|
self._leave(event) # Remove underline before we change window to browser
|
||||||
openurl(url)
|
webbrowser.open(url)
|
||||||
|
|
||||||
def _contextmenu(self, event: tk.Event) -> None:
|
def _contextmenu(self, event: tk.Event) -> None:
|
||||||
if self['text'] and (self.popup_copy(self['text']) if callable(self.popup_copy) else self.popup_copy):
|
if self['text'] and (self.popup_copy(self['text']) if callable(self.popup_copy) else self.popup_copy):
|
||||||
@ -183,4 +184,6 @@ def openurl(url: str) -> None:
|
|||||||
ended up using `webbrowser.open()` *anyway*.
|
ended up using `webbrowser.open()` *anyway*.
|
||||||
:param url: URL to open.
|
:param url: URL to open.
|
||||||
"""
|
"""
|
||||||
|
warnings.warn("This function is deprecated. "
|
||||||
|
"Please use `webbrowser.open() instead.", DeprecationWarning, stacklevel=2)
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user