bear-utils 0.7.24__py3-none-any.whl → 0.8.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bear_utils/__init__.py +13 -13
- bear_utils/__main__.py +14 -0
- bear_utils/_internal/__init__.py +0 -0
- bear_utils/_internal/cli.py +73 -0
- bear_utils/_internal/debug.py +159 -0
- bear_utils/ai/ai_helpers/__init__.py +1 -1
- bear_utils/ai/ai_helpers/_types.py +1 -1
- bear_utils/cli/prompt_helpers.py +1 -1
- bear_utils/cli/shell/_base_shell.py +1 -1
- bear_utils/config/settings_manager.py +10 -8
- bear_utils/extras/_tools.py +2 -2
- bear_utils/extras/responses/__init__.py +8 -0
- bear_utils/files/ignore_parser.py +1 -1
- bear_utils/gui/gui_tools/qt_app.py +1 -1
- bear_utils/{logging/loggers.py → logger_manager/__init__.py} +22 -6
- bear_utils/{logging/logger_manager → logger_manager}/loggers/_base_logger.py +2 -2
- bear_utils/{logging/logger_manager → logger_manager}/loggers/_base_logger.pyi +1 -1
- bear_utils/{logging/logger_manager → logger_manager}/loggers/_console_logger.py +2 -2
- bear_utils/{logging/logger_manager → logger_manager}/loggers/_console_logger.pyi +1 -0
- bear_utils/{logging/logger_manager → logger_manager}/loggers/_file_logger.py +2 -0
- bear_utils/{logging/logger_manager → logger_manager}/loggers/_sub_logger.py +1 -0
- bear_utils/monitoring/host_monitor.py +2 -2
- {bear_utils-0.7.24.dist-info → bear_utils-0.8.1.dist-info}/METADATA +3 -3
- {bear_utils-0.7.24.dist-info → bear_utils-0.8.1.dist-info}/RECORD +33 -31
- bear_utils/logging/__init__.py +0 -27
- bear_utils/logging/logger_manager/__init__.py +0 -1
- /bear_utils/{logging/logger_manager → logger_manager}/_common.py +0 -0
- /bear_utils/{logging/logger_manager → logger_manager}/_console_junk.py +0 -0
- /bear_utils/{logging/logger_manager → logger_manager}/_styles.py +0 -0
- /bear_utils/{logging/logger_manager → logger_manager}/loggers/__init__.py +0 -0
- /bear_utils/{logging/logger_manager → logger_manager}/loggers/_buffer_logger.py +0 -0
- /bear_utils/{logging/logger_manager → logger_manager}/loggers/_level_sin.py +0 -0
- /bear_utils/{logging/logger_manager → logger_manager}/loggers/_logger.py +0 -0
- /bear_utils/{logging/logger_manager → logger_manager}/loggers/_sub_logger.pyi +0 -0
- {bear_utils-0.7.24.dist-info → bear_utils-0.8.1.dist-info}/WHEEL +0 -0
bear_utils/__init__.py
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
"""A module for Bear Utils, providing various utilities and tools."""
|
2
2
|
|
3
|
-
from importlib.metadata import version
|
4
|
-
|
5
3
|
from bear_epoch_time import EpochTimestamp, TimeTools
|
6
4
|
|
7
|
-
from .cache import CacheWrapper, cache, cache_factory
|
8
|
-
from .config.settings_manager import SettingsManager, get_settings_manager
|
9
|
-
from .constants.date_related import DATE_FORMAT, DATE_TIME_FORMAT
|
10
|
-
from .database import DatabaseManager
|
11
|
-
from .events import Events
|
12
|
-
from .
|
13
|
-
from .
|
14
|
-
from .
|
15
|
-
from .
|
16
|
-
|
17
|
-
__version__: str = version(distribution_name="bear_utils")
|
5
|
+
from bear_utils.cache import CacheWrapper, cache, cache_factory
|
6
|
+
from bear_utils.config.settings_manager import SettingsManager, get_settings_manager
|
7
|
+
from bear_utils.constants.date_related import DATE_FORMAT, DATE_TIME_FORMAT
|
8
|
+
from bear_utils.database import DatabaseManager
|
9
|
+
from bear_utils.events import Events
|
10
|
+
from bear_utils.extras.responses import FAILURE, SUCCESS, FunctionResponse
|
11
|
+
from bear_utils.files.file_handlers.file_handler_factory import FileHandlerFactory
|
12
|
+
from bear_utils.logger_manager import BaseLogger, BufferLogger, ConsoleLogger, FileLogger
|
13
|
+
from bear_utils.logger_manager._common import VERBOSE_CONSOLE_FORMAT
|
14
|
+
from bear_utils.logger_manager._styles import VERBOSE
|
18
15
|
|
19
16
|
__all__ = [
|
20
17
|
"DATE_FORMAT",
|
21
18
|
"DATE_TIME_FORMAT",
|
19
|
+
"FAILURE",
|
20
|
+
"SUCCESS",
|
22
21
|
"VERBOSE",
|
23
22
|
"VERBOSE_CONSOLE_FORMAT",
|
24
23
|
"BaseLogger",
|
@@ -30,6 +29,7 @@ __all__ = [
|
|
30
29
|
"Events",
|
31
30
|
"FileHandlerFactory",
|
32
31
|
"FileLogger",
|
32
|
+
"FunctionResponse",
|
33
33
|
"SettingsManager",
|
34
34
|
"TimeTools",
|
35
35
|
"cache",
|
bear_utils/__main__.py
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
"""Entry-point module, in case you use `python -m bear_utils`.
|
2
|
+
|
3
|
+
Why does this file exist, and why `__main__`? For more info, read:
|
4
|
+
|
5
|
+
- https://www.python.org/dev/peps/pep-0338/
|
6
|
+
- https://docs.python.org/3/using/cmdline.html#cmdoption-m
|
7
|
+
"""
|
8
|
+
|
9
|
+
import sys
|
10
|
+
|
11
|
+
from bear_utils._internal.cli import main
|
12
|
+
|
13
|
+
if __name__ == "__main__":
|
14
|
+
sys.exit(main(sys.argv[1:]))
|
File without changes
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Why does this file exist, and why not put this in `__main__`?
|
2
|
+
#
|
3
|
+
# You might be tempted to import things from `__main__` later,
|
4
|
+
# but that will cause problems: the code will get executed twice:
|
5
|
+
#
|
6
|
+
# - When you run `python -m bear_utils` python will execute
|
7
|
+
# `__main__.py` as a script. That means there won't be any
|
8
|
+
# `bear_utils.__main__` in `sys.modules`.
|
9
|
+
# - When you import `__main__` it will get executed again (as a module) because
|
10
|
+
# there's no `bear_utils.__main__` in `sys.modules`.
|
11
|
+
from __future__ import annotations
|
12
|
+
|
13
|
+
from argparse import Action, ArgumentParser, Namespace
|
14
|
+
import sys
|
15
|
+
from typing import Any
|
16
|
+
|
17
|
+
from bear_utils._internal import debug
|
18
|
+
|
19
|
+
|
20
|
+
class _DebugInfo(Action):
|
21
|
+
def __init__(self, nargs: int | str | None = 0, **kwargs: Any) -> None:
|
22
|
+
super().__init__(nargs=nargs, **kwargs)
|
23
|
+
|
24
|
+
def __call__(self, *_: Any, **__: Any) -> None:
|
25
|
+
debug._print_debug_info()
|
26
|
+
sys.exit(0)
|
27
|
+
|
28
|
+
|
29
|
+
class _About(Action):
|
30
|
+
def __init__(self, nargs: int | str | None = 0, **kwargs: Any) -> None:
|
31
|
+
super().__init__(nargs=nargs, **kwargs)
|
32
|
+
|
33
|
+
def __call__(self, *_: Any, **__: Any) -> None:
|
34
|
+
print(debug._get_package_info())
|
35
|
+
sys.exit(0)
|
36
|
+
|
37
|
+
|
38
|
+
def get_parser() -> ArgumentParser:
|
39
|
+
name: str = debug._get_name()
|
40
|
+
version: str = f"{name} v{debug._get_version()}"
|
41
|
+
parser = ArgumentParser(description=name.capitalize(), prog=name, exit_on_error=False)
|
42
|
+
parser.add_argument("-V", "--version", action="version", version=version)
|
43
|
+
parser.add_argument("--about", action=_About, help="Print information about the package")
|
44
|
+
parser.add_argument("--debug_info", action=_DebugInfo, help="Print debug information")
|
45
|
+
return parser
|
46
|
+
|
47
|
+
|
48
|
+
def main(args: list[str] | None = None) -> int:
|
49
|
+
"""Main entry point for the CLI.
|
50
|
+
|
51
|
+
This function is called when the CLI is executed. It can be used to
|
52
|
+
initialize the CLI, parse arguments, and execute commands.
|
53
|
+
|
54
|
+
Args:
|
55
|
+
args (list[str] | None): A list of command-line arguments. If None, uses sys.argv[1:].
|
56
|
+
|
57
|
+
Returns:
|
58
|
+
int: Exit code of the CLI execution. 0 for success, non-zero for failure.
|
59
|
+
"""
|
60
|
+
if args is None:
|
61
|
+
args = sys.argv[1:]
|
62
|
+
try:
|
63
|
+
parser: ArgumentParser = get_parser()
|
64
|
+
opts: Namespace = parser.parse_args(args)
|
65
|
+
print(opts)
|
66
|
+
except Exception as e:
|
67
|
+
print(f"Error initializing CLI: {e}", file=sys.stderr)
|
68
|
+
return 1
|
69
|
+
return 0
|
70
|
+
|
71
|
+
|
72
|
+
if __name__ == "__main__":
|
73
|
+
main()
|
@@ -0,0 +1,159 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from dataclasses import dataclass
|
4
|
+
import importlib.metadata
|
5
|
+
from importlib.metadata import PackageNotFoundError, metadata, version
|
6
|
+
import os
|
7
|
+
import platform
|
8
|
+
import sys
|
9
|
+
|
10
|
+
__PACKAGE_NAME__ = "bear-utils"
|
11
|
+
|
12
|
+
|
13
|
+
@dataclass
|
14
|
+
class _Package:
|
15
|
+
"""Dataclass to store package information."""
|
16
|
+
|
17
|
+
name: str = __PACKAGE_NAME__
|
18
|
+
"""Package name."""
|
19
|
+
version: str = "0.0.0"
|
20
|
+
"""Package version."""
|
21
|
+
description: str = "No description available."
|
22
|
+
"""Package description."""
|
23
|
+
|
24
|
+
def __str__(self) -> str:
|
25
|
+
"""String representation of the package information."""
|
26
|
+
return f"{self.name} v{self.version}: {self.description}"
|
27
|
+
|
28
|
+
|
29
|
+
@dataclass
|
30
|
+
class _Variable:
|
31
|
+
"""Dataclass describing an environment variable."""
|
32
|
+
|
33
|
+
name: str
|
34
|
+
"""Variable name."""
|
35
|
+
value: str
|
36
|
+
"""Variable value."""
|
37
|
+
|
38
|
+
|
39
|
+
@dataclass
|
40
|
+
class _Environment:
|
41
|
+
"""Dataclass to store environment information."""
|
42
|
+
|
43
|
+
interpreter_name: str
|
44
|
+
"""Python interpreter name."""
|
45
|
+
interpreter_version: str
|
46
|
+
"""Python interpreter version."""
|
47
|
+
interpreter_path: str
|
48
|
+
"""Path to Python executable."""
|
49
|
+
platform: str
|
50
|
+
"""Operating System."""
|
51
|
+
packages: list[_Package]
|
52
|
+
"""Installed packages."""
|
53
|
+
variables: list[_Variable]
|
54
|
+
"""Environment variables."""
|
55
|
+
|
56
|
+
|
57
|
+
def _interpreter_name_version() -> tuple[str, str]:
|
58
|
+
if hasattr(sys, "implementation"):
|
59
|
+
impl = sys.implementation.version
|
60
|
+
version = f"{impl.major}.{impl.minor}.{impl.micro}"
|
61
|
+
kind = impl.releaselevel
|
62
|
+
if kind != "final":
|
63
|
+
version += kind[0] + str(impl.serial)
|
64
|
+
return sys.implementation.name, version
|
65
|
+
return "", "0.0.0"
|
66
|
+
|
67
|
+
|
68
|
+
def _get_package_info(dist: str = __PACKAGE_NAME__) -> _Package:
|
69
|
+
try:
|
70
|
+
return _Package(
|
71
|
+
name=dist,
|
72
|
+
version=version(dist),
|
73
|
+
description=metadata(dist)["Summary"],
|
74
|
+
)
|
75
|
+
except PackageNotFoundError:
|
76
|
+
return _Package(name=dist)
|
77
|
+
|
78
|
+
|
79
|
+
def _get_name(dist: str = __PACKAGE_NAME__) -> str:
|
80
|
+
"""Get name of the given distribution.
|
81
|
+
|
82
|
+
Parameters:
|
83
|
+
dist: A distribution name.
|
84
|
+
|
85
|
+
Returns:
|
86
|
+
A package name.
|
87
|
+
"""
|
88
|
+
return _get_package_info(dist).name
|
89
|
+
|
90
|
+
|
91
|
+
def _get_version(dist: str = __PACKAGE_NAME__) -> str:
|
92
|
+
"""Get version of the given distribution.
|
93
|
+
|
94
|
+
Parameters:
|
95
|
+
dist: A distribution name.
|
96
|
+
|
97
|
+
Returns:
|
98
|
+
A version number.
|
99
|
+
"""
|
100
|
+
return _get_package_info(dist).version
|
101
|
+
|
102
|
+
|
103
|
+
def _get_description(dist: str = __PACKAGE_NAME__) -> str:
|
104
|
+
"""Get description of the given distribution.
|
105
|
+
|
106
|
+
Parameters:
|
107
|
+
dist: A distribution name.
|
108
|
+
|
109
|
+
Returns:
|
110
|
+
A description string.
|
111
|
+
"""
|
112
|
+
return _get_package_info(dist).description
|
113
|
+
|
114
|
+
|
115
|
+
def _get_debug_info() -> _Environment:
|
116
|
+
"""Get debug/environment information.
|
117
|
+
|
118
|
+
Returns:
|
119
|
+
Environment information.
|
120
|
+
"""
|
121
|
+
py_name, py_version = _interpreter_name_version()
|
122
|
+
packages: list[str] = [__PACKAGE_NAME__]
|
123
|
+
variables: list[str] = [
|
124
|
+
"PYTHONPATH",
|
125
|
+
*[var for var in os.environ if var.startswith(__PACKAGE_NAME__.replace("-", "_"))],
|
126
|
+
]
|
127
|
+
return _Environment(
|
128
|
+
interpreter_name=py_name,
|
129
|
+
interpreter_version=py_version,
|
130
|
+
interpreter_path=sys.executable,
|
131
|
+
platform=platform.platform(),
|
132
|
+
variables=[_Variable(var, val) for var in variables if (val := os.getenv(var))],
|
133
|
+
packages=[_Package(pkg, _get_version(pkg)) for pkg in packages],
|
134
|
+
)
|
135
|
+
|
136
|
+
|
137
|
+
def get_installed_packages() -> list[_Package]:
|
138
|
+
"""Get all installed packages in current environment"""
|
139
|
+
packages = []
|
140
|
+
for dist in importlib.metadata.distributions():
|
141
|
+
packages.append({"name": dist.metadata["Name"], "version": dist.version})
|
142
|
+
return packages
|
143
|
+
|
144
|
+
|
145
|
+
def _print_debug_info() -> None:
|
146
|
+
"""Print debug/environment information."""
|
147
|
+
info: _Environment = _get_debug_info()
|
148
|
+
print(f"- __System__: {info.platform}")
|
149
|
+
print(f"- __Python__: {info.interpreter_name} {info.interpreter_version} ({info.interpreter_path})")
|
150
|
+
print("- __Environment variables__:")
|
151
|
+
for var in info.variables:
|
152
|
+
print(f" - `{var.name}`: `{var.value}`")
|
153
|
+
print("- __Installed packages__:")
|
154
|
+
for pkg in info.packages:
|
155
|
+
print(f" - `{pkg.name}` v{pkg.version}")
|
156
|
+
|
157
|
+
|
158
|
+
if __name__ == "__main__":
|
159
|
+
_print_debug_info()
|
@@ -5,7 +5,7 @@ from typing import Any, cast
|
|
5
5
|
|
6
6
|
from rich.markdown import Markdown
|
7
7
|
|
8
|
-
from bear_utils.
|
8
|
+
from bear_utils.logger_manager import BaseLogger
|
9
9
|
|
10
10
|
from ._common import GPT_4_1_NANO, PRODUCTION_MODE, TESTING_MODE, AIModel, EnvironmentMode
|
11
11
|
from ._config import AIEndpointConfig
|
bear_utils/cli/prompt_helpers.py
CHANGED
@@ -8,7 +8,7 @@ from prompt_toolkit.validation import ValidationError, Validator
|
|
8
8
|
|
9
9
|
from bear_utils.constants._exceptions import UserCancelledError
|
10
10
|
from bear_utils.constants._lazy_typing import LitBool, LitFloat, LitInt, LitStr, OptBool, OptFloat, OptInt, OptStr
|
11
|
-
from bear_utils.
|
11
|
+
from bear_utils.logger_manager import get_console
|
12
12
|
|
13
13
|
# TODO: Overhaul this trash, it is written like absolute garbage.
|
14
14
|
|
@@ -14,7 +14,7 @@ from subprocess import CompletedProcess
|
|
14
14
|
from typing import Self, override
|
15
15
|
|
16
16
|
from bear_utils.constants.logger_protocol import LoggerProtocol
|
17
|
-
from bear_utils.
|
17
|
+
from bear_utils.logger_manager import VERBOSE, BaseLogger, SubConsoleLogger
|
18
18
|
|
19
19
|
from ._base_command import BaseShellCommand
|
20
20
|
from ._common import DEFAULT_SHELL
|
@@ -9,11 +9,11 @@ from typing import Any, Self
|
|
9
9
|
from tinydb import Query, TinyDB
|
10
10
|
|
11
11
|
|
12
|
-
def
|
13
|
-
"""Get the path to the bear configuration
|
14
|
-
|
15
|
-
|
16
|
-
return
|
12
|
+
def get_config_folder() -> Path:
|
13
|
+
"""Get the path to the bear configuration directory."""
|
14
|
+
config_path: Path = Path.home() / ".bear_utils"
|
15
|
+
config_path.mkdir(parents=True, exist_ok=True)
|
16
|
+
return config_path
|
17
17
|
|
18
18
|
|
19
19
|
class SettingsManager:
|
@@ -21,11 +21,13 @@ class SettingsManager:
|
|
21
21
|
|
22
22
|
__slots__ = ("cache", "db", "file_path", "settings_name")
|
23
23
|
|
24
|
-
def __init__(self, settings_name: str) -> None:
|
24
|
+
def __init__(self, settings_name: str, folder_path: str | Path | None = None) -> None:
|
25
25
|
"""Initialize the SettingsManager with a specific settings name."""
|
26
|
-
self.settings_name = settings_name
|
26
|
+
self.settings_name: str = settings_name
|
27
27
|
self.cache: dict[str, Any] = {}
|
28
|
-
|
28
|
+
file_name: str = f"{settings_name}.json"
|
29
|
+
self.file_path: Path = Path(folder_path) / file_name if folder_path else get_config_folder() / file_name
|
30
|
+
|
29
31
|
self.db: TinyDB = TinyDB(self.file_path, indent=4, ensure_ascii=False)
|
30
32
|
|
31
33
|
atexit.register(self.close)
|
bear_utils/extras/_tools.py
CHANGED
@@ -8,7 +8,7 @@ from typing import TYPE_CHECKING
|
|
8
8
|
from bear_utils.cli.shell._base_command import BaseShellCommand as ShellCommand
|
9
9
|
from bear_utils.cli.shell._base_shell import AsyncShellSession
|
10
10
|
from bear_utils.extras.platform_utils import OS, get_platform
|
11
|
-
from bear_utils.
|
11
|
+
from bear_utils.logger_manager.loggers._base_logger import BaseLogger
|
12
12
|
|
13
13
|
if TYPE_CHECKING:
|
14
14
|
from subprocess import CompletedProcess
|
@@ -17,7 +17,7 @@ if TYPE_CHECKING:
|
|
17
17
|
class TextHelper:
|
18
18
|
@cached_property
|
19
19
|
def local_console(self) -> BaseLogger:
|
20
|
-
from bear_utils.
|
20
|
+
from bear_utils.logger_manager import BaseLogger # noqa: PLC0415
|
21
21
|
|
22
22
|
init: bool = not BaseLogger.has_instance()
|
23
23
|
return BaseLogger.get_instance(init=init)
|
@@ -6,7 +6,7 @@ from pathlib import Path
|
|
6
6
|
from pathspec import PathSpec
|
7
7
|
|
8
8
|
from bear_utils.cli.prompt_helpers import ask_yes_no
|
9
|
-
from bear_utils.
|
9
|
+
from bear_utils.logger_manager import ConsoleLogger
|
10
10
|
|
11
11
|
logger: ConsoleLogger = ConsoleLogger.get_instance(init=True)
|
12
12
|
|
@@ -9,7 +9,7 @@ from PyQt6.QtCore import QCoreApplication, QObject, Qt
|
|
9
9
|
from PyQt6.QtGui import QAction, QIcon, QKeySequence, QShortcut
|
10
10
|
from PyQt6.QtWidgets import QApplication, QDialog, QLabel, QMenu, QMenuBar, QMessageBox, QVBoxLayout
|
11
11
|
|
12
|
-
from bear_utils.
|
12
|
+
from bear_utils.logger_manager import VERBOSE, ConsoleLogger
|
13
13
|
|
14
14
|
from ._types import ActionHolder
|
15
15
|
|
@@ -1,10 +1,12 @@
|
|
1
|
-
"""
|
1
|
+
"""Logging utilities for Bear Utils."""
|
2
2
|
|
3
|
-
from .logger_manager.
|
4
|
-
from .logger_manager.
|
5
|
-
from .logger_manager.loggers.
|
6
|
-
from .logger_manager.loggers.
|
7
|
-
from .logger_manager.loggers.
|
3
|
+
from bear_utils.logger_manager._common import VERBOSE_CONSOLE_FORMAT
|
4
|
+
from bear_utils.logger_manager._styles import VERBOSE
|
5
|
+
from bear_utils.logger_manager.loggers._base_logger import BaseLogger
|
6
|
+
from bear_utils.logger_manager.loggers._buffer_logger import BufferLogger
|
7
|
+
from bear_utils.logger_manager.loggers._console_logger import ConsoleLogger
|
8
|
+
from bear_utils.logger_manager.loggers._file_logger import FileLogger
|
9
|
+
from bear_utils.logger_manager.loggers._sub_logger import SubConsoleLogger
|
8
10
|
|
9
11
|
AllLoggers = BaseLogger | ConsoleLogger | SubConsoleLogger
|
10
12
|
Loggers = BaseLogger | ConsoleLogger
|
@@ -70,3 +72,17 @@ def get_sub_logger(logger: BaseLogger | ConsoleLogger, namespace: str) -> SubCon
|
|
70
72
|
raise TypeError("Expected logger to be an instance of BaseLogger or ConsoleLogger")
|
71
73
|
|
72
74
|
return SubConsoleLogger(logger=logger, namespace=namespace)
|
75
|
+
|
76
|
+
|
77
|
+
__all__ = [
|
78
|
+
"VERBOSE",
|
79
|
+
"VERBOSE_CONSOLE_FORMAT",
|
80
|
+
"BaseLogger",
|
81
|
+
"BufferLogger",
|
82
|
+
"ConsoleLogger",
|
83
|
+
"FileLogger",
|
84
|
+
"SubConsoleLogger",
|
85
|
+
"get_console",
|
86
|
+
"get_logger",
|
87
|
+
"get_sub_logger",
|
88
|
+
]
|
@@ -11,8 +11,8 @@ from rich.theme import Theme
|
|
11
11
|
from rich.traceback import Traceback
|
12
12
|
from singleton_base import SingletonBase
|
13
13
|
|
14
|
-
from bear_utils.
|
15
|
-
from bear_utils.
|
14
|
+
from bear_utils.logger_manager._common import ExecValues, StackLevelTracker
|
15
|
+
from bear_utils.logger_manager._styles import DEFAULT_THEME, LOGGER_METHODS, LoggerExtraInfo
|
16
16
|
|
17
17
|
from ._level_sin import INFO, add_level_name, check_level, lvl_exists
|
18
18
|
from ._sub_logger import SubConsoleLogger
|
@@ -7,7 +7,7 @@ from rich.theme import Theme
|
|
7
7
|
from rich.traceback import Traceback
|
8
8
|
from singleton_base import SingletonBase
|
9
9
|
|
10
|
-
from bear_utils.
|
10
|
+
from bear_utils.logger_manager._common import ExecValues, StackLevelTracker
|
11
11
|
|
12
12
|
from ._sub_logger import SubConsoleLogger
|
13
13
|
|
@@ -11,8 +11,8 @@ from rich.text import Text
|
|
11
11
|
from rich.theme import Theme
|
12
12
|
|
13
13
|
from bear_utils.constants.date_related import DATE_TIME_FORMAT
|
14
|
-
from bear_utils.
|
15
|
-
from bear_utils.
|
14
|
+
from bear_utils.logger_manager._common import FIVE_MEGABYTES, VERBOSE_CONSOLE_FORMAT, VERBOSE_FORMAT, ExecValues
|
15
|
+
from bear_utils.logger_manager._console_junk import ConsoleBuffering, ConsoleFormatter, ConsoleHandler
|
16
16
|
|
17
17
|
from ._base_logger import BaseLogger
|
18
18
|
|
@@ -5,6 +5,7 @@ from typing import Any
|
|
5
5
|
from rich.text import Text
|
6
6
|
from rich.theme import Theme
|
7
7
|
|
8
|
+
from bear_utils.logger_manager._console_junk import ConsoleBuffering, ConsoleHandler
|
8
9
|
from bear_utils.logging.logger_manager._console_junk import ConsoleBuffering, ConsoleHandler
|
9
10
|
|
10
11
|
from ._base_logger import BaseLogger
|
@@ -4,12 +4,14 @@ from typing import TYPE_CHECKING, Any, override
|
|
4
4
|
|
5
5
|
from rich.theme import Theme
|
6
6
|
|
7
|
+
from bear_utils.logger_manager._common import FIVE_MEGABYTES
|
7
8
|
from bear_utils.logging.logger_manager._common import FIVE_MEGABYTES
|
8
9
|
|
9
10
|
from ._console_logger import ConsoleLogger
|
10
11
|
from ._sub_logger import SubConsoleLogger
|
11
12
|
|
12
13
|
if TYPE_CHECKING:
|
14
|
+
from bear_utils.logger_manager._styles import LoggerExtraInfo
|
13
15
|
from bear_utils.logging.logger_manager._styles import LoggerExtraInfo
|
14
16
|
|
15
17
|
|
@@ -9,6 +9,7 @@ from typing import TYPE_CHECKING, Any, Generic, TypeVar
|
|
9
9
|
|
10
10
|
from rich.text import Text
|
11
11
|
|
12
|
+
from bear_utils.logger_manager._styles import LOGGER_METHODS, LoggerExtraInfo
|
12
13
|
from bear_utils.logging.logger_manager._styles import LOGGER_METHODS, LoggerExtraInfo
|
13
14
|
|
14
15
|
from ._level_sin import check_level
|
@@ -9,7 +9,7 @@ from dataclasses import dataclass
|
|
9
9
|
import subprocess
|
10
10
|
from typing import TYPE_CHECKING, Literal, Self, TypedDict, cast, overload
|
11
11
|
|
12
|
-
from bear_utils.
|
12
|
+
from bear_utils.logger_manager import get_console
|
13
13
|
from bear_utils.monitoring._common import CPU, CPU_MEM, DISK, GPU, MEM, TaskChoice
|
14
14
|
|
15
15
|
ROLLING_AVERAGE_TIME = 300
|
@@ -306,7 +306,7 @@ class HostMonitor:
|
|
306
306
|
if current_cpu_samples:
|
307
307
|
return round(sum(current_cpu_samples) / len(current_cpu_samples), 2)
|
308
308
|
except Exception as e:
|
309
|
-
|
309
|
+
self.console.error(f"Error getting CPU temperature: {e}", exc_info=True)
|
310
310
|
return 0.0
|
311
311
|
|
312
312
|
async def get_avg_mem_usage(self) -> float:
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: bear-utils
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.8.1
|
4
4
|
Summary: Various utilities for Bear programmers, including a rich logging utility, a disk cache, and a SQLite database wrapper amongst other things.
|
5
5
|
Author-email: chaz <bright.lid5647@fastmail.com>
|
6
6
|
Requires-Python: >=3.12
|
7
|
-
Requires-Dist: bear-epoch-time>=1.
|
7
|
+
Requires-Dist: bear-epoch-time>=1.1.1
|
8
8
|
Requires-Dist: diskcache<6.0.0,>=5.6.3
|
9
9
|
Requires-Dist: httpx>=0.28.1
|
10
10
|
Requires-Dist: pathspec>=0.12.1
|
@@ -20,7 +20,7 @@ Requires-Dist: tinydb>=4.8.2
|
|
20
20
|
Requires-Dist: toml>=0.10.2
|
21
21
|
Description-Content-Type: text/markdown
|
22
22
|
|
23
|
-
# Bear Utils v# Bear Utils v0.
|
23
|
+
# Bear Utils v# Bear Utils v0.8.1
|
24
24
|
|
25
25
|
Personal set of tools and utilities for Python projects, focusing on modularity and ease of use. This library includes components for caching, database management, logging, time handling, file operations, CLI prompts, image processing, clipboard interaction, gradient utilities, event systems, and async helpers.
|
26
26
|
|
@@ -1,22 +1,26 @@
|
|
1
|
-
bear_utils/__init__.py,sha256=
|
1
|
+
bear_utils/__init__.py,sha256=T-lPXm-iGMOBz2JShR_nSRiIZ9k63e80hCxP37n83mU,1248
|
2
|
+
bear_utils/__main__.py,sha256=-FlPquBlI1Tg2RoeX6d0Z8jTAiMFnJ0V06ZeRyiq58k,355
|
3
|
+
bear_utils/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
bear_utils/_internal/cli.py,sha256=w3Cj8AM4iW5FNyM3ffCkBmwRoCWHc4JNYF26A35cxzw,2447
|
5
|
+
bear_utils/_internal/debug.py,sha256=_Y2UzSuKqLYqNekuDR4NTE3CST5c4TnUHKnTRQ421Jk,4277
|
2
6
|
bear_utils/ai/__init__.py,sha256=Q5P1KpSYS6iMt3vRbmasdWU5Oy5UkXfOGGyDI7Qy3Po,747
|
3
|
-
bear_utils/ai/ai_helpers/__init__.py,sha256=
|
7
|
+
bear_utils/ai/ai_helpers/__init__.py,sha256=6SiOQ71NNGvIkMX8pMnZ3lxK9WDZ2Zgo3P6TRS5pvP4,4351
|
4
8
|
bear_utils/ai/ai_helpers/_common.py,sha256=KgaOb_IePfC8Z1VsdA0EiodfS_YGVYYnrZFR2ZdsUYM,418
|
5
9
|
bear_utils/ai/ai_helpers/_config.py,sha256=UX7wPIiEr2Uqt2kZWtMaYagmRFmUsQKSuopQ41XW53I,774
|
6
10
|
bear_utils/ai/ai_helpers/_parsers.py,sha256=KlkhLHru6eivy37di9sSlxZdttPEMKRnt08nJeYmuhk,8161
|
7
|
-
bear_utils/ai/ai_helpers/_types.py,sha256=
|
11
|
+
bear_utils/ai/ai_helpers/_types.py,sha256=rmnl8mTlUj0LyL9USzTb-EN_31TtXY6qzhkOEuHjvBI,465
|
8
12
|
bear_utils/cache/__init__.py,sha256=c9z1mLhWpZJHZdXRlviYQXl8tc9KTJCM8vin3moDO3I,4578
|
9
13
|
bear_utils/cli/__init__.py,sha256=H2QpLyHpQS_Yn3sF2px7n4KqT97LEe7Oyzafg2iHcpc,503
|
10
14
|
bear_utils/cli/commands.py,sha256=5ppEjvVV_g28WLaIFtKgz-ctzwoo-g-KpHTXNx9xBzo,3161
|
11
|
-
bear_utils/cli/prompt_helpers.py,sha256=
|
15
|
+
bear_utils/cli/prompt_helpers.py,sha256=DVdg1f5yZElVyFNao6RTPfrc6mKy4PoXLgY6az-ejo8,6580
|
12
16
|
bear_utils/cli/shell/__init__.py,sha256=2s3oR6CqLKj1iyERy7YafWT3t3KzTr70Z1yaLKa6IiQ,42
|
13
17
|
bear_utils/cli/shell/_base_command.py,sha256=eqvYSXR_NqWqJm5meGTONYJGSG32q0AQDfTGums2hI0,2471
|
14
|
-
bear_utils/cli/shell/_base_shell.py,sha256=
|
18
|
+
bear_utils/cli/shell/_base_shell.py,sha256=FGlXshVVEGXXB0CYcoLZd_tLn4-AVXP0qLt01yRaoQw,16737
|
15
19
|
bear_utils/cli/shell/_common.py,sha256=_KQyL5lvqOfjonFIwlEOyp3K9G3TSOj19RhgVzfNNpg,669
|
16
20
|
bear_utils/config/__init__.py,sha256=HC_lWpmLF0kbPr5i1Wa2FLER2b446E_GecgU9EPmc04,353
|
17
21
|
bear_utils/config/config_manager.py,sha256=Xj0xOmY-wo_rwfcWiXyxNZWX9NknX_Jm9W56Gx8yyHQ,8244
|
18
22
|
bear_utils/config/dir_manager.py,sha256=slIy1oRr7VIPdsiwN66-xQiuSvgqm_j6d1IrKhxRsSk,2028
|
19
|
-
bear_utils/config/settings_manager.py,sha256=
|
23
|
+
bear_utils/config/settings_manager.py,sha256=6YaCSHYA0k6VPaLSrXJ_yjZ-lOPklMgQC73K20Z8yis,5181
|
20
24
|
bear_utils/constants/__init__.py,sha256=fE3p01HDJDV9uAMWYB8q8h7K01ekSqZPxymvgbNaN7Y,563
|
21
25
|
bear_utils/constants/_exceptions.py,sha256=gnAGTmuD9NYpJakeLrYHAyPrAQPHDNahY_rS42Ct39k,251
|
22
26
|
bear_utils/constants/_lazy_typing.py,sha256=WfuWpRqx9XchvuyPWg3tVjMC5-C4QA-Bhwfskf4YmAE,339
|
@@ -30,14 +34,14 @@ bear_utils/events/events_class.py,sha256=vPDjWrbut8L3TFn7byyYFZpWYM5ADIqtW2Aeh-q
|
|
30
34
|
bear_utils/events/events_module.py,sha256=rv9NoCDFOaYY70EilrImG9ug90n_wpDBDz4XvxUYqdE,2291
|
31
35
|
bear_utils/extras/__init__.py,sha256=szflSapj7aGFc2j5sTitQFccXu-6_UdGG-eYuv6zVJI,607
|
32
36
|
bear_utils/extras/_async_helpers.py,sha256=cxq5d24NHkECmZqTVXEazv6K-XUa7skFnX6KQZb0Ycw,411
|
33
|
-
bear_utils/extras/_tools.py,sha256=
|
37
|
+
bear_utils/extras/_tools.py,sha256=kxJ1jaqx3PvLpc0CZUIV8XQUwjQGrNCRLoka11aNtoc,7672
|
34
38
|
bear_utils/extras/platform_utils.py,sha256=Ai7ow7S-_cKb5zFwFh8dkC8xmbMJFy-0_-w3NCERdEw,1362
|
35
|
-
bear_utils/extras/responses/__init__.py,sha256=
|
39
|
+
bear_utils/extras/responses/__init__.py,sha256=XbE4VKemrKRwx9E5jqy__OiM_AAjA58ebnqQ2hytnT0,225
|
36
40
|
bear_utils/extras/responses/function_response.py,sha256=Zis2uIpGp3Mqbpc0RszyNt2JSsLAiGmWKhgezLjzUTM,14153
|
37
41
|
bear_utils/extras/wrappers/__init__.py,sha256=crh4sKOLvuhNMVX5bJYjCFWtXtH7G47UgNPOHq3HXTk,43
|
38
42
|
bear_utils/extras/wrappers/add_methods.py,sha256=z2XZG2ZoYOB1MaGiLli4NRyyTeRgBy7tuYsiy8mTa9s,4422
|
39
43
|
bear_utils/files/__init__.py,sha256=mIdnFSXoDE64ElM43bN2m6KuafURnN82ki0pdqN8q2o,201
|
40
|
-
bear_utils/files/ignore_parser.py,sha256=
|
44
|
+
bear_utils/files/ignore_parser.py,sha256=2KlbfbEn012KGMqW4TdcV6jFbHXGmuCmA5DjjmIZ6_Y,10958
|
41
45
|
bear_utils/files/file_handlers/__init__.py,sha256=VF2IlWNr3UqeSvsbh3YCbLw9cLmlyf64mfeOKuhBdvk,136
|
42
46
|
bear_utils/files/file_handlers/_base_file_handler.py,sha256=Fl45rAuKSY-fVYBP-7o7op6thXlX8FLQbgwXEt4gDLQ,3726
|
43
47
|
bear_utils/files/file_handlers/file_handler_factory.py,sha256=fDo2UcWp5-pOMtVWKCTuz-Fw4qSIB9fg5FgNRoYR6g4,9931
|
@@ -53,31 +57,29 @@ bear_utils/gui/__init__.py,sha256=i699iAUONA7KLN7_kqwV33fUJ5Zr71_qLzqMsSBUles,34
|
|
53
57
|
bear_utils/gui/gui_tools/__init__.py,sha256=cD6cKxU1cmKDVaBRT8KsqsCbulf6TUNAmVr50XGPpo8,446
|
54
58
|
bear_utils/gui/gui_tools/_settings.py,sha256=xSQ7I-axAifZNvEw_28mnFBFYIJd4xFuDpycFFQLib0,1201
|
55
59
|
bear_utils/gui/gui_tools/_types.py,sha256=krguJ-ccALKeUHz9auh_iyOCzeAuerOYcuhWW8jjJQ0,248
|
56
|
-
bear_utils/gui/gui_tools/qt_app.py,sha256=
|
60
|
+
bear_utils/gui/gui_tools/qt_app.py,sha256=hjZtHNJkCcpfT_KkUV35aa9y92ejEhpAV3AFgd27IbY,5865
|
57
61
|
bear_utils/gui/gui_tools/qt_color_picker.py,sha256=5NtLiBHk5r9Goma_oiymriH49D_JGIk844p4Hsi51io,4744
|
58
62
|
bear_utils/gui/gui_tools/qt_file_handler.py,sha256=FgWdS-9WnjVuyGIC8V30ByDCBeJGZKGc8KRTy34SFfI,4404
|
59
63
|
bear_utils/gui/gui_tools/qt_input_dialog.py,sha256=5KaCM9q8kmoy-Fd0j1FbXIVrLlE7W47NEGdhsWtvKwQ,9281
|
60
|
-
bear_utils/
|
61
|
-
bear_utils/
|
62
|
-
bear_utils/
|
63
|
-
bear_utils/
|
64
|
-
bear_utils/
|
65
|
-
bear_utils/
|
66
|
-
bear_utils/
|
67
|
-
bear_utils/
|
68
|
-
bear_utils/
|
69
|
-
bear_utils/
|
70
|
-
bear_utils/
|
71
|
-
bear_utils/
|
72
|
-
bear_utils/
|
73
|
-
bear_utils/
|
74
|
-
bear_utils/
|
75
|
-
bear_utils/logging/logger_manager/loggers/_sub_logger.py,sha256=Nd3hJFlBK9iVZZSJJoxH5M6tarIysf03skYI9aWBBmU,3428
|
76
|
-
bear_utils/logging/logger_manager/loggers/_sub_logger.pyi,sha256=rRcmrVFg7dhHO_tNQQXrpF3h4r0CdVyGxC4xtOIemzM,1002
|
64
|
+
bear_utils/logger_manager/__init__.py,sha256=SPzzveSMUqaft2fX-uwQAcfFyoQoUDJCzHN4ZOFz6Mw,3236
|
65
|
+
bear_utils/logger_manager/_common.py,sha256=m72yhFmBBgZN7u3omI43AERKQyR9bVwgeHEfbgPJV4Y,1581
|
66
|
+
bear_utils/logger_manager/_console_junk.py,sha256=2fwiYjZZps3GrH5An7aU3Bgvb_aAJiqNzTnKaku6m-0,4916
|
67
|
+
bear_utils/logger_manager/_styles.py,sha256=3A30TrvPSOm1h2IfHgdDEUc0WP71zWZDGCHrCRofdjc,2523
|
68
|
+
bear_utils/logger_manager/loggers/__init__.py,sha256=ashcnkvQIUQDLbUtU6QILkMjP_fMaeHAN1w7pHLWqQk,67
|
69
|
+
bear_utils/logger_manager/loggers/_base_logger.py,sha256=64ZzAKjuk4sZG_sUnXPSMjk57OY3GTKu_uc5RIajH_s,9493
|
70
|
+
bear_utils/logger_manager/loggers/_base_logger.pyi,sha256=bo_Pykv42XvfBsQ7AmP_e_TEZ7puT_DhLqtqhEWBsc8,2667
|
71
|
+
bear_utils/logger_manager/loggers/_buffer_logger.py,sha256=JEd2afChzAKkM1va-L8xVOi1cF9n9W1vGzkI49YEf40,1527
|
72
|
+
bear_utils/logger_manager/loggers/_console_logger.py,sha256=bzyTA-DkeokGngl7AIg5zIvLwQUaWTk4NKtlH7P9SW8,9866
|
73
|
+
bear_utils/logger_manager/loggers/_console_logger.pyi,sha256=GHQONxyDi5l3VXEYk6dE3JguUJvKXisHQaICirfWp3M,1959
|
74
|
+
bear_utils/logger_manager/loggers/_file_logger.py,sha256=1EGgATidGuWi4_W_cBFEgZBGvYauV0z_xPFUM-yHqrc,4887
|
75
|
+
bear_utils/logger_manager/loggers/_level_sin.py,sha256=HxAhuQSBhJHygTB8hcAIYLoPl6u0pUbF1BZ2aLFmEHI,1747
|
76
|
+
bear_utils/logger_manager/loggers/_logger.py,sha256=FA0ALmROX1BQIal7zhEemLnC0UnXTQY-YqJBlPEbQDM,537
|
77
|
+
bear_utils/logger_manager/loggers/_sub_logger.py,sha256=t7l8cQIyrNgJi9PE0XMYhhb2wsy6VoHvsyvIkWuwwWM,3506
|
78
|
+
bear_utils/logger_manager/loggers/_sub_logger.pyi,sha256=rRcmrVFg7dhHO_tNQQXrpF3h4r0CdVyGxC4xtOIemzM,1002
|
77
79
|
bear_utils/monitoring/__init__.py,sha256=9DKNIWTp_voLnaWgiP-wJ-o_N0hYixo-MzjUmg8RUvI,240
|
78
80
|
bear_utils/monitoring/_common.py,sha256=LYQFxgTP9fk0cH71IQTuGwBYYPWCqHP_mMRNecoD76M,657
|
79
|
-
bear_utils/monitoring/host_monitor.py,sha256=
|
81
|
+
bear_utils/monitoring/host_monitor.py,sha256=e0TYRJw9iDj5Ga6y3ck1TBFEeH42Cax5mQYaNU8yams,13241
|
80
82
|
bear_utils/time/__init__.py,sha256=d9Ovv-Dlx5NWgnOl1hY-evznVm9hboS6ypNp1wDFxQQ,934
|
81
|
-
bear_utils-0.
|
82
|
-
bear_utils-0.
|
83
|
-
bear_utils-0.
|
83
|
+
bear_utils-0.8.1.dist-info/METADATA,sha256=YpR8pGkBiFFeVIiYpnqIKhqOJpsch9-_djhd2S-VDj4,8627
|
84
|
+
bear_utils-0.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
85
|
+
bear_utils-0.8.1.dist-info/RECORD,,
|
bear_utils/logging/__init__.py
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
"""Logging utilities for Bear Utils."""
|
2
|
-
|
3
|
-
from .logger_manager._common import VERBOSE_CONSOLE_FORMAT
|
4
|
-
from .logger_manager._styles import VERBOSE
|
5
|
-
from .loggers import (
|
6
|
-
BaseLogger,
|
7
|
-
BufferLogger,
|
8
|
-
ConsoleLogger,
|
9
|
-
FileLogger,
|
10
|
-
SubConsoleLogger,
|
11
|
-
get_console,
|
12
|
-
get_logger,
|
13
|
-
get_sub_logger,
|
14
|
-
)
|
15
|
-
|
16
|
-
__all__ = [
|
17
|
-
"VERBOSE",
|
18
|
-
"VERBOSE_CONSOLE_FORMAT",
|
19
|
-
"BaseLogger",
|
20
|
-
"BufferLogger",
|
21
|
-
"ConsoleLogger",
|
22
|
-
"FileLogger",
|
23
|
-
"SubConsoleLogger",
|
24
|
-
"get_console",
|
25
|
-
"get_logger",
|
26
|
-
"get_sub_logger",
|
27
|
-
]
|
@@ -1 +0,0 @@
|
|
1
|
-
"""Logging Manager for Bear Utils."""
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|