mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2026-10-25 01:06:05 +03:00
Remove Deprecated Functions
This commit is contained in:
7 files changed
+5
-170
No files matched your search
@@ -765,13 +765,6 @@ class AppWindow:
|
||||
# Start a protocol handler to handle cAPI registration. Requires main loop to be running.
|
||||
self.w.after_idle(lambda: protocol.protocolhandler.start(self.w))
|
||||
|
||||
# Migration from <= 3.30
|
||||
for username in config.get_list('fdev_usernames', default=[]):
|
||||
config.delete_password(username)
|
||||
config.delete('fdev_usernames', suppress=True)
|
||||
config.delete('username', suppress=True)
|
||||
config.delete('password', suppress=True)
|
||||
config.delete('logdir', suppress=True)
|
||||
self.postprefs(False) # Companion login happens in callback from monitor
|
||||
self.toggle_suit_row(visible=False)
|
||||
if args.start_min:
|
||||
|
||||
+4
-67
@@ -40,7 +40,6 @@ import pathlib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import warnings
|
||||
from abc import abstractmethod
|
||||
from typing import Any, Callable, Type, TypeVar
|
||||
import semantic_version
|
||||
@@ -52,7 +51,7 @@ appcmdname = 'EDMC'
|
||||
# <https://semver.org/#semantic-versioning-specification-semver>
|
||||
# Major.Minor.Patch(-prerelease)(+buildmetadata)
|
||||
# NB: Do *not* import this, use the functions appversion() and appversion_nobuild()
|
||||
_static_appversion = '5.13.2'
|
||||
_static_appversion = '6.0.0-alpha0'
|
||||
_cached_version: semantic_version.Version | None = None
|
||||
copyright = '© 2015-2019 Jonathan Harris, 2020-2025 EDCD'
|
||||
|
||||
@@ -68,11 +67,7 @@ capi_pretend_down: bool = False
|
||||
capi_debug_access_token: str | None = None
|
||||
# This must be done here in order to avoid an import cycle with EDMCLogging.
|
||||
# Other code should use EDMCLogging.get_main_logger
|
||||
if os.getenv("EDMC_NO_UI"):
|
||||
logger = logging.getLogger(appcmdname)
|
||||
|
||||
else:
|
||||
logger = logging.getLogger(appname)
|
||||
logger = logging.getLogger(appcmdname) if os.getenv("EDMC_NO_UI") else logging.getLogger(appname)
|
||||
|
||||
|
||||
_T = TypeVar('_T')
|
||||
@@ -334,33 +329,6 @@ class AbstractConfig(abc.ABC):
|
||||
|
||||
return None
|
||||
|
||||
@warnings.deprecated("get() is Deprecated. use the specific getter for your type. Will remove in 6.0")
|
||||
def get(
|
||||
self, key: str,
|
||||
default: list | str | bool | int | None = None
|
||||
) -> list | str | bool | int | None:
|
||||
"""
|
||||
Return the data for the requested key, or a default.
|
||||
|
||||
:param key: The key data is being requested for.
|
||||
:param default: The default to return if the key does not exist, defaults to None.
|
||||
:raises OSError: On Windows, if a Registry error occurs.
|
||||
:return: The data or the default.
|
||||
"""
|
||||
if (a_list := self._suppress_call(self.get_list, ValueError, key, default=None)) is not None:
|
||||
return a_list
|
||||
|
||||
if (a_str := self._suppress_call(self.get_str, ValueError, key, default=None)) is not None:
|
||||
return a_str
|
||||
|
||||
if (a_bool := self._suppress_call(self.get_bool, ValueError, key, default=None)) is not None:
|
||||
return a_bool
|
||||
|
||||
if (an_int := self._suppress_call(self.get_int, ValueError, key, default=None)) is not None:
|
||||
return an_int
|
||||
|
||||
return default
|
||||
|
||||
@abstractmethod
|
||||
def get_list(self, key: str, *, default: list | None = None) -> list:
|
||||
"""
|
||||
@@ -396,16 +364,6 @@ class AbstractConfig(abc.ABC):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@warnings.deprecated("Migrate to get_int. Will remove in 6.0 or later.")
|
||||
def getint(self, key: str, *, default: int = 0) -> int:
|
||||
"""
|
||||
Getint is a Deprecated getter method.
|
||||
|
||||
See get_int for its replacement.
|
||||
:raises OSError: On Windows, if a Registry error occurs.
|
||||
"""
|
||||
return self.get_int(key, default=default)
|
||||
|
||||
@abstractmethod
|
||||
def get_int(self, key: str, *, default: int = 0) -> int:
|
||||
"""
|
||||
@@ -459,22 +417,6 @@ class AbstractConfig(abc.ABC):
|
||||
"""Close this config and release any associated resources."""
|
||||
raise NotImplementedError
|
||||
|
||||
@warnings.deprecated("Password system doesn't do anything. Will remove in 6.0 or later.")
|
||||
def get_password(self, account: str) -> None:
|
||||
"""Legacy password retrieval."""
|
||||
pass
|
||||
|
||||
@warnings.deprecated("Password system doesn't do anything. Will remove in 6.0 or later.")
|
||||
def set_password(self, account: str, password: str) -> None:
|
||||
"""Legacy password setting."""
|
||||
pass
|
||||
|
||||
@warnings.deprecated("Password system doesn't do anything. Will remove in 6.0 or later.")
|
||||
def delete_password(self, account: str) -> None:
|
||||
"""Legacy password deletion."""
|
||||
pass
|
||||
# End Dep Zone
|
||||
|
||||
|
||||
def get_config(*args, **kwargs) -> AbstractConfig:
|
||||
"""
|
||||
@@ -496,6 +438,8 @@ def get_config(*args, **kwargs) -> AbstractConfig:
|
||||
|
||||
|
||||
config = get_config()
|
||||
if sys.platform == "win32":
|
||||
config.write_registry_to_toml(f"{config.app_dir_path}/config.toml") # type: ignore
|
||||
|
||||
|
||||
# Wiki: https://github.com/EDCD/EDMarketConnector/wiki/Participating-in-Open-Betas-of-EDMC
|
||||
@@ -504,10 +448,3 @@ def get_update_feed() -> str:
|
||||
if config.get_bool('beta_optin'):
|
||||
return 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector-beta.xml'
|
||||
return 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector.xml'
|
||||
|
||||
|
||||
@warnings.deprecated("Migrate to get_update_feed(). Will remove in 6.0 or later.")
|
||||
def __getattr__(name: str):
|
||||
if name == 'update_feed':
|
||||
return get_update_feed()
|
||||
raise AttributeError(name=name)
|
||||
@@ -10,12 +10,10 @@ Localization with gettext is a pain on non-Unix systems.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import builtins
|
||||
import locale
|
||||
import numbers
|
||||
import re
|
||||
import sys
|
||||
import warnings
|
||||
from contextlib import suppress
|
||||
from os import listdir, sep
|
||||
from typing import Iterable, TextIO, cast
|
||||
@@ -77,8 +75,6 @@ class Translations:
|
||||
Use when translation is not desired or not available
|
||||
"""
|
||||
self.translations = {None: {}}
|
||||
# DEPRECATED: Migrate to translations.translate or tr.tl. Will remove in 6.0 or later.
|
||||
builtins.__dict__['_'] = lambda x: str(x).replace(r'\"', '"').replace('{CR}', '\n')
|
||||
|
||||
def install(self, lang: str | None = None) -> None: # noqa: CCR001
|
||||
"""
|
||||
@@ -121,9 +117,6 @@ class Translations:
|
||||
except Exception:
|
||||
logger.exception(f'Exception occurred while parsing {lang}.strings in plugin {plugin}')
|
||||
|
||||
# DEPRECATED: Migrate to translations.translate or tr.tl. Will remove in 6.0 or later.
|
||||
builtins.__dict__['_'] = self.translate
|
||||
|
||||
def contents(self, lang: str, plugin_path: pathlib.Path | None = None) -> dict[str, str]:
|
||||
"""Load all the translations from a translation file."""
|
||||
if lang not in self.available() and lang != self.FALLBACK: # Because "en" doesn't appear in self.available()
|
||||
@@ -262,21 +255,6 @@ def _wszarray_to_list(array):
|
||||
class _Locale:
|
||||
"""Locale holds a few utility methods to convert data to and from localized versions."""
|
||||
|
||||
@warnings.deprecated("Migrate to _Locale.string_from_number. Will remove in 6.0 or later.")
|
||||
def stringFromNumber(self, number: float | int, decimals: int | None = None) -> str: # noqa: N802
|
||||
warnings.warn('use _Locale.string_from_number instead.', DeprecationWarning, stacklevel=2)
|
||||
return self.string_from_number(number, decimals) # type: ignore
|
||||
|
||||
@warnings.deprecated("Migrate to _Locale.number_from_string. Will remove in 6.0 or later.")
|
||||
def numberFromString(self, string: str) -> int | float | None: # noqa: N802
|
||||
warnings.warn('use _Locale.number_from_string instead.', DeprecationWarning, stacklevel=2)
|
||||
return self.number_from_string(string)
|
||||
|
||||
@warnings.deprecated("Migrate to _Locale.preferred_languages. Will remove in 6.0 or later.")
|
||||
def preferredLanguages(self) -> Iterable[str]: # noqa: N802
|
||||
warnings.warn('use _Locale.preferred_languages instead.', DeprecationWarning, stacklevel=2)
|
||||
return self.preferred_languages()
|
||||
|
||||
def string_from_number(self, number: float | int, decimals: int = 5) -> str:
|
||||
"""
|
||||
Convert a number to a string.
|
||||
@@ -353,18 +331,6 @@ class _Locale:
|
||||
Locale = _Locale()
|
||||
translations = Translations()
|
||||
|
||||
|
||||
@warnings.deprecated("Migrate to `translations`. Will be removed in 6.0 or later.")
|
||||
# Begin Deprecation Zone
|
||||
class _Translations(Translations):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
|
||||
# Yes, I know this is awful renaming garbage. But we need it for compat.
|
||||
Translations: Translations = translations # type: ignore
|
||||
# End Deprecation Zone
|
||||
|
||||
# generate template strings file - like xgettext
|
||||
# parsing is limited - only single ' or " delimited strings, and only one string per line
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -11,7 +11,6 @@ from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import tkinter as tk
|
||||
import warnings
|
||||
from tkinter import ttk, messagebox
|
||||
from PIL import ImageGrab
|
||||
from l10n import translations as tr
|
||||
@@ -119,14 +118,6 @@ class EntryMenu(ttk.Entry):
|
||||
pass
|
||||
|
||||
|
||||
class Entry(EntryMenu):
|
||||
"""Custom ttk.Entry class to fix some display issues."""
|
||||
|
||||
@warnings.deprecated("Migrate to EntryMenu. Will remove in 6.0 or later.")
|
||||
def __init__(self, master: ttk.Frame | None = None, **kw):
|
||||
EntryMenu.__init__(self, master, **kw)
|
||||
|
||||
|
||||
class Button(ttk.Button):
|
||||
"""Custom ttk.Button class to fix some display issues."""
|
||||
|
||||
@@ -135,14 +126,6 @@ class Button(ttk.Button):
|
||||
super().__init__(master, style=style, **kw) # type: ignore
|
||||
|
||||
|
||||
class ColoredButton(tk.Button):
|
||||
"""Custom tk.Button class to fix some display issues."""
|
||||
|
||||
@warnings.deprecated("Migrate to tk.Button. Will remove in 6.0 or later.")
|
||||
def __init__(self, master: ttk.Frame | None = None, **kw):
|
||||
tk.Button.__init__(self, master, **kw)
|
||||
|
||||
|
||||
class Checkbutton(ttk.Checkbutton):
|
||||
"""Custom ttk.Checkbutton class to fix some display issues."""
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import re
|
||||
import sqlite3
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
import warnings
|
||||
from platform import system
|
||||
from textwrap import dedent
|
||||
from threading import Lock
|
||||
@@ -172,12 +171,6 @@ class EDDNSender:
|
||||
self.db_conn = self.sqlite_queue_v1()
|
||||
self.db = self.db_conn.cursor()
|
||||
|
||||
#######################################################################
|
||||
# Queue database migration
|
||||
#######################################################################
|
||||
self.convert_legacy_file()
|
||||
#######################################################################
|
||||
|
||||
self.queue_processing = Lock()
|
||||
# Initiate retry/send-now timer
|
||||
logger.trace_if(
|
||||
@@ -223,27 +216,6 @@ class EDDNSender:
|
||||
|
||||
return db_conn
|
||||
|
||||
@warnings.deprecated("Legacy files no longer used as of 5.6.0. Will remove in 6.0 or later.")
|
||||
def convert_legacy_file(self):
|
||||
"""Convert a legacy file's contents into the sqlite3 db."""
|
||||
filename = config.app_dir_path / 'replay.jsonl'
|
||||
if not filename.exists():
|
||||
return
|
||||
logger.info("Converting legacy `replay.jsonl` to `eddn_queue-v1.db`")
|
||||
try:
|
||||
with filename.open('r', encoding='utf-8') as replay_file:
|
||||
for line in replay_file:
|
||||
cmdr, msg = json.loads(line)
|
||||
self.add_message(cmdr, msg)
|
||||
except Exception as e:
|
||||
logger.exception("Failed to convert legacy file: %s", e)
|
||||
return
|
||||
logger.info("Conversion complete, removing `replay.jsonl`")
|
||||
try:
|
||||
filename.unlink()
|
||||
except Exception as e:
|
||||
logger.warning("Could not delete legacy file: %s", e)
|
||||
|
||||
def close(self) -> None:
|
||||
"""Clean up any resources."""
|
||||
logger.debug('Closing db cursor.')
|
||||
|
||||
@@ -3,7 +3,6 @@ from __future__ import annotations
|
||||
|
||||
import numbers
|
||||
import sys
|
||||
import warnings
|
||||
from configparser import NoOptionError
|
||||
from os import getenv, makedirs, mkdir
|
||||
from os.path import dirname, expanduser, isdir, join
|
||||
@@ -389,19 +388,5 @@ class OldConfig:
|
||||
def __init__(self):
|
||||
raise NotImplementedError('Implement me')
|
||||
|
||||
# Common
|
||||
|
||||
def get_password(self, account: str) -> None:
|
||||
"""Legacy password retrieval."""
|
||||
warnings.warn("password subsystem is no longer supported", DeprecationWarning)
|
||||
|
||||
def set_password(self, account: str, password: str) -> None:
|
||||
"""Legacy password setting."""
|
||||
warnings.warn("password subsystem is no longer supported", DeprecationWarning)
|
||||
|
||||
def delete_password(self, account: str) -> None:
|
||||
"""Legacy password deletion."""
|
||||
warnings.warn("password subsystem is no longer supported", DeprecationWarning)
|
||||
|
||||
|
||||
old_config = OldConfig()
|
||||
@@ -143,8 +143,7 @@ class TestNewConfig:
|
||||
config.set(name, '1337')
|
||||
config.save()
|
||||
self.__update_linuxconfig()
|
||||
with pytest.deprecated_call():
|
||||
res = config.get(name)
|
||||
res = config.get_str(name)
|
||||
|
||||
assert res == '1337'
|
||||
config.delete(name)
|
||||
|
||||
Reference in new issue
Block a user