diff --git a/EDMCLogging.py b/EDMCLogging.py index ad5397c7..3683baba 100644 --- a/EDMCLogging.py +++ b/EDMCLogging.py @@ -364,6 +364,27 @@ def get_plugin_logger(plugin_name: str, loglevel: int = _default_loglevel) -> Lo # munged into InterceptHandler. Logger/Loguru both are handling this complex logic # without sys._getframe() calls. +class EDMCContextFilter(logging.Filter): + """ + Legacy compatibility shim. + EDMC now intercepts standard logging globally via Loguru, + making manual context filtering obsolete. + """ + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + warnings.warn( + "EDMCContextFilter is deprecated and no longer performs log enrichment. " + "It will be completely removed in a future major version release.", + DeprecationWarning, + stacklevel=2 + ) + + def filter(self, record: logging.LogRecord) -> bool: + """Establish Compatibilty Shim.""" + # Pass everything through cleanly without altering the record + return True + + def get_main_logger(sublogger_name: str = '') -> LoggerMixin: """Return the correct logger for how the program is being run.""" if not os.getenv("EDMC_NO_UI"): diff --git a/config/__init__.py b/config/__init__.py index e5de422b..841eaae7 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -56,7 +56,7 @@ appcmdname = "EDMC" # # Major.Minor.Patch(-prerelease)(+buildmetadata) # NB: Do *not* import this, use the functions appversion() and appversion_nobuild() -_static_appversion = "6.1.3-beta3" +_static_appversion = "6.2.0-alpha0" _cached_version: semantic_version.Version | None = None copyright = "© 2015-2019 Jonathan Harris, 2020-2026 EDCD" IS_FROZEN = getattr(sys, 'frozen', False) diff --git a/dashboard.py b/dashboard.py index e68a621d..17d8aa65 100644 --- a/dashboard.py +++ b/dashboard.py @@ -11,6 +11,7 @@ import json import sys import time import tkinter as tk +import warnings from datetime import datetime from pathlib import Path from typing import Any @@ -159,6 +160,20 @@ class Dashboard(FileSystemEventHandler): except Exception: logger.exception('Processing Status.json') + def poll(self, first_time: bool = False) -> None: + """ + Legacy compatibility shim for backwards compatibility with plugins. + Status.json is now handled entirely via filesystem event observers. + """ + warnings.warn( + "Dashboard.poll() is deprecated as EDMC now leverages unified Watchdog observers. " + "This method is a no-op and will be removed in a future major version.", + DeprecationWarning, + stacklevel=2 + ) + # Safely run process once just in case the plugin was using it to force a refresh + self.process() + # singleton dashboard = Dashboard() diff --git a/util/text.py b/util/text.py new file mode 100644 index 00000000..7c940cf7 --- /dev/null +++ b/util/text.py @@ -0,0 +1,32 @@ +""" +text.py - Dealing with Text and Bytes. +Copyright (c) EDCD, All Rights Reserved +Licensed under the GNU General Public License v2 or later. +See LICENSE file. +""" +from __future__ import annotations + +from gzip import compress +from warnings import deprecated + +__all__ = ['gzip'] + + +@deprecated("text.gzip is deprecated and will be removed in a later version!") +def gzip(data: str | bytes, max_size: int = 512, encoding='utf-8') -> tuple[bytes, bool]: + """ + Compress the given data if the max size is greater than specified. + The default was chosen somewhat arbitrarily, see eddn.py for some more careful + work towards keeping the data almost always compressed + :param data: The data to compress + :param max_size: The max size of data, in bytes, defaults to 512 + :param encoding: The encoding to use if data is a str, defaults to 'utf-8' + :return: the payload to send, and a bool indicating compression state + """ + if isinstance(data, str): + data = data.encode(encoding=encoding) + + if len(data) <= max_size: + return data, False + + return compress(data), True