You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.9 KiB
65 lines
1.9 KiB
From 889c37dcfc8011c0171b6d9a26615f3e06686f58 Mon Sep 17 00:00:00 2001
|
|
From: tigro <tigro@msvsphere-os.ru>
|
|
Date: Mon, 9 Sep 2024 14:44:19 +0300
|
|
Subject: [PATCH] Backport to old Python 3.9
|
|
|
|
---
|
|
gdms/__init__.py | 15 ++++++++-------
|
|
gdms/cmd.py | 2 ++
|
|
gdms/utils.py | 2 ++
|
|
3 files changed, 12 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/gdms/__init__.py b/gdms/__init__.py
|
|
index bc11b86..e3c7b55 100644
|
|
--- a/gdms/__init__.py
|
|
+++ b/gdms/__init__.py
|
|
@@ -56,14 +56,15 @@ class _Style(str, Enum):
|
|
|
|
|
|
class _StdErrFormatter(logging.Formatter):
|
|
- def format (self, record):
|
|
- match record.levelname:
|
|
- case 'CRITICAL': level_color = _Style.BRIGHT_RED
|
|
- case 'ERROR': level_color = _Style.RED
|
|
- case 'WARNING': level_color = _Style.YELLOW
|
|
- case 'INFO': level_color = _Style.GREEN
|
|
- case default: level_color = _Style.BLUE
|
|
+ LEVEL_COLOR_MAP = {
|
|
+ 'CRITICAL': _Style.BRIGHT_RED,
|
|
+ 'ERROR': _Style.RED,
|
|
+ 'WARNING': _Style.YELLOW,
|
|
+ 'INFO': _Style.GREEN
|
|
+ }
|
|
|
|
+ def format (self, record):
|
|
+ level_color = self.LEVEL_COLOR_MAP.get(record.levelname, _Style.BLUE)
|
|
return (_Style.BOLD + level_color + record.levelname + _Style.NORMAL + ':'
|
|
+ _Style.MANENTA + record.name + _Style.NORMAL + ':'
|
|
+ ' ' + record.getMessage())
|
|
diff --git a/gdms/cmd.py b/gdms/cmd.py
|
|
index ddeda01..fe5d8a9 100644
|
|
--- a/gdms/cmd.py
|
|
+++ b/gdms/cmd.py
|
|
@@ -1,3 +1,5 @@
|
|
+from __future__ import annotations
|
|
+
|
|
import os
|
|
import subprocess
|
|
from collections.abc import Sequence
|
|
diff --git a/gdms/utils.py b/gdms/utils.py
|
|
index 2b82bde..664bc81 100644
|
|
--- a/gdms/utils.py
|
|
+++ b/gdms/utils.py
|
|
@@ -4,6 +4,8 @@
|
|
'self-contained' means that this module does not depend on anything from
|
|
the gdm_settings package'''
|
|
|
|
+from __future__ import annotations
|
|
+
|
|
import os
|
|
import pathlib
|
|
import subprocess
|
|
--
|
|
2.46.0
|
|
|