Поддержать настройки трендов в Python 3.8

This commit is contained in:
2026-09-04 12:23:07 +03:00
parent 20850b26df
commit 392817432b
2 changed files with 3 additions and 1 deletions

View File

@@ -129,7 +129,8 @@ def encode_settings(settings: Mapping[str, list[TrendSignal]]) -> str:
def decode_settings(text: str) -> dict[str, list[TrendSignal]]: def decode_settings(text: str) -> dict[str, list[TrendSignal]]:
if len(text.encode("utf-8")) > MAX_FILE_BYTES: if len(text.encode("utf-8")) > MAX_FILE_BYTES:
raise ValueError("Trend configuration exceeds 1 MiB") raise ValueError("Trend configuration exceeds 1 MiB")
root = json.loads(text.removeprefix("\ufeff")) # Python 3.8 is used by the Windows 7 port; remove at most one BOM.
root = json.loads(text[1:] if text.startswith("\ufeff") else text)
if not isinstance(root, dict) or root.get("format") != "setflash-trends" or type(root.get("version")) is not int or root["version"] != 1: if not isinstance(root, dict) or root.get("format") != "setflash-trends" or type(root.get("version")) is not int or root["version"] != 1:
raise ValueError("Unknown trend configuration format/version") raise ValueError("Unknown trend configuration format/version")
profiles = root.get("profiles") profiles = root.get("profiles")

View File

@@ -9,6 +9,7 @@ import unittest
from protocan.plot import Bounds, Marker, Markers, PlotMath, Viewport from protocan.plot import Bounds, Marker, Markers, PlotMath, Viewport
@unittest.skipUnless(os.environ.get("SETPROTOCOL_LIBRARY"), "Set SETPROTOCOL_LIBRARY to the built C library")
class PlotTests(unittest.TestCase): class PlotTests(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):