bear-utils 0.9.5__tar.gz → 0.9.7__tar.gz
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-0.9.5 → bear_utils-0.9.7}/PKG-INFO +1 -1
- {bear_utils-0.9.5 → bear_utils-0.9.7}/pyproject.toml +1 -1
- bear_utils-0.9.7/src/bear_utils/_internal/_version.py +1 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/_internal/cli.py +4 -5
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/_internal/debug.py +42 -14
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/_zapper.py +1 -1
- bear_utils-0.9.5/src/bear_utils/logger_manager/_console_junk.py → bear_utils-0.9.7/src/bear_utils/logger_manager/_logger_misc.py +19 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/_console.py +27 -8
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/console_logger.py +19 -1
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/console_logger.pyi +1 -1
- bear_utils-0.9.5/src/bear_utils/_internal/_version.py +0 -1
- {bear_utils-0.9.5 → bear_utils-0.9.7}/.gitignore +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/.python-version +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/AGENTS.md +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/README.md +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/config/coverage.ini +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/config/default.toml +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/config/git-changelog.toml +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/config/pytest.ini +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/config/ruff.toml +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/directory_structure.txt +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/directory_structure.xml +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/maskfile.md +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/noxfile.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/__main__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/_internal/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/ai/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/ai/ai_helpers/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/ai/ai_helpers/_common.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/ai/ai_helpers/_config.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/ai/ai_helpers/_parsers.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/ai/ai_helpers/_types.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cache/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/_args.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/_get_version.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/commands.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/prompt_helpers.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/shell/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/shell/_base_command.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/shell/_base_shell.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/shell/_common.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/cli/typer_bridge.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/config/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/config/config_manager.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/config/dir_manager.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/config/settings_manager.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/constants/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/constants/_exceptions.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/constants/_exit_code.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/constants/_http_status_code.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/constants/_lazy_typing.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/constants/_meta.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/constants/date_related.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/constants/time_related.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/database/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/database/_db_manager.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/events/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/events/events_class.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/events/events_module.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/_async_helpers.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/_tools.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/platform_utils.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/responses/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/responses/function_response.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/wrappers/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/wrappers/add_methods.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/extras/wrappers/string_io.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/_base_file_handler.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/file_handler_factory.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/json_file_handler.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/log_file_handler.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/toml_file_handler.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/txt_file_handler.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/yaml_file_handler.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/ignore_parser.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/bear_gradient.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/font/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/font/_raw_block_letters.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/font/_theme.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/font/_utils.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/font/block_font.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/font/glitch_font.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/graphics/image_helpers.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/gui/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/gui/gui_tools/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/gui/gui_tools/_settings.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/gui/gui_tools/_types.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/gui/gui_tools/qt_app.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/gui/gui_tools/qt_color_picker.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/gui/gui_tools/qt_file_handler.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/gui/gui_tools/qt_input_dialog.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/_common.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/_log_level.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/_styles.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/logger_protocol.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/_level_sin.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/_logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/base_logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/base_logger.pyi +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/basic_logger/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/basic_logger/logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/basic_logger/logger.pyi +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/buffer_logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/fastapi_logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/file_logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/simple_logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/sub_logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/sub_logger.pyi +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/monitoring/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/monitoring/_common.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/monitoring/host_monitor.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/time/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/__init__.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_add_ord_suffix.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_clipboard.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_database_manager.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_default_shell.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_font_utils.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_function_response.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_gradient.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_logger.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_platform_utils.py +0 -0
- {bear_utils-0.9.5 → bear_utils-0.9.7}/tests/test_prompt_helpers.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: bear-utils
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.7
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.9.7"
|
@@ -15,7 +15,6 @@ import sys
|
|
15
15
|
from typing import Any
|
16
16
|
|
17
17
|
from bear_utils._internal import debug
|
18
|
-
from bear_utils._internal._version import version as _version
|
19
18
|
from bear_utils.cli._get_version import VALID_BUMP_TYPES, cli_bump
|
20
19
|
from bear_utils.constants import STDERR, ExitCode
|
21
20
|
|
@@ -43,14 +42,14 @@ class _Version(Action):
|
|
43
42
|
super().__init__(nargs=nargs, **kwargs)
|
44
43
|
|
45
44
|
def __call__(self, *_: Any, **__: Any) -> None:
|
46
|
-
version: str = f"{debug._get_name()} v{
|
45
|
+
version: str = f"{debug._get_name()} v{debug._get_version()}"
|
47
46
|
print(version)
|
48
47
|
sys.exit(ExitCode.SUCCESS)
|
49
48
|
|
50
49
|
|
51
50
|
def get_version() -> ExitCode:
|
52
51
|
"""CLI command to get the version of the package."""
|
53
|
-
print(
|
52
|
+
print(debug._get_version())
|
54
53
|
return ExitCode.SUCCESS
|
55
54
|
|
56
55
|
|
@@ -64,11 +63,11 @@ def bump_version(args: list[str] | None = None) -> ExitCode:
|
|
64
63
|
help=f"Type of version bump: {', '.join(VALID_BUMP_TYPES)}",
|
65
64
|
)
|
66
65
|
_args: Namespace = parser.parse_args(args or sys.argv[1:])
|
67
|
-
return cli_bump([_args.bump_type, debug.
|
66
|
+
return cli_bump([_args.bump_type, debug._get_name(), debug._get_version()])
|
68
67
|
|
69
68
|
|
70
69
|
def get_parser() -> ArgumentParser:
|
71
|
-
name = debug._get_name()
|
70
|
+
name: str = debug._get_name()
|
72
71
|
parser = ArgumentParser(description=name.capitalize(), prog=name, exit_on_error=False)
|
73
72
|
parser.add_argument("-V", "--version", action=_Version, help="Print the version of the package")
|
74
73
|
subparser = parser.add_subparsers(dest="command", required=False, help="Available commands")
|
@@ -7,22 +7,50 @@ import os
|
|
7
7
|
import platform
|
8
8
|
import sys
|
9
9
|
|
10
|
-
from
|
10
|
+
from pydantic import BaseModel, Field, field_validator
|
11
|
+
|
12
|
+
from bear_utils._internal._version import __version__
|
11
13
|
from bear_utils.cli._get_version import Version
|
12
14
|
|
13
15
|
__PACKAGE_NAME__ = "bear-utils"
|
14
16
|
|
15
17
|
|
18
|
+
class _ProjectMetadata(BaseModel):
|
19
|
+
"""Dataclass to store project metadata."""
|
20
|
+
|
21
|
+
name: str = Field(default=__PACKAGE_NAME__, description="Project name of the package.")
|
22
|
+
version: str = Field(default=__version__, description="Project version.")
|
23
|
+
description: str = Field(default="No description available.", description="Project description.")
|
24
|
+
|
25
|
+
def __str__(self) -> str:
|
26
|
+
"""String representation of the project metadata."""
|
27
|
+
return f"{self.name} v{self.version}: {self.description}"
|
28
|
+
|
29
|
+
@field_validator("version", mode="before")
|
30
|
+
@classmethod
|
31
|
+
def validate_version(cls, v: str) -> str:
|
32
|
+
"""Validate the version string."""
|
33
|
+
if not isinstance(v, str) or "0.0.0" in v:
|
34
|
+
try:
|
35
|
+
v = version(__PACKAGE_NAME__)
|
36
|
+
except PackageNotFoundError:
|
37
|
+
v = "0.0.0"
|
38
|
+
return v
|
39
|
+
|
40
|
+
|
41
|
+
_metadata = _ProjectMetadata()
|
42
|
+
|
43
|
+
|
16
44
|
@dataclass
|
17
45
|
class _Package:
|
18
46
|
"""Dataclass to store package information."""
|
19
47
|
|
20
|
-
name: str =
|
48
|
+
name: str = _metadata.name
|
21
49
|
"""Package name."""
|
22
|
-
version: str =
|
50
|
+
version: str = _metadata.version
|
23
51
|
"""Package version."""
|
24
|
-
_version: Version = field(default_factory=lambda: Version.from_string(
|
25
|
-
description: str =
|
52
|
+
_version: Version = field(default_factory=lambda: Version.from_string(_metadata.version))
|
53
|
+
description: str = _metadata.description
|
26
54
|
"""Package description."""
|
27
55
|
|
28
56
|
def __post_init__(self) -> None:
|
@@ -40,7 +68,7 @@ class _Package:
|
|
40
68
|
return f"{self.name} v{self.version}: {self.description}"
|
41
69
|
|
42
70
|
|
43
|
-
@dataclass
|
71
|
+
@dataclass(frozen=True)
|
44
72
|
class _Variable:
|
45
73
|
"""Dataclass describing an environment variable."""
|
46
74
|
|
@@ -50,7 +78,7 @@ class _Variable:
|
|
50
78
|
"""Variable value."""
|
51
79
|
|
52
80
|
|
53
|
-
@dataclass
|
81
|
+
@dataclass(frozen=True)
|
54
82
|
class _Environment:
|
55
83
|
"""Dataclass to store environment information."""
|
56
84
|
|
@@ -79,18 +107,18 @@ def _interpreter_name_version() -> tuple[str, str]:
|
|
79
107
|
return "", "0.0.0"
|
80
108
|
|
81
109
|
|
82
|
-
def _get_package_info(dist: str =
|
110
|
+
def _get_package_info(dist: str = _metadata.name) -> _Package:
|
83
111
|
try:
|
84
112
|
return _Package(
|
85
113
|
name=dist,
|
86
|
-
version=
|
114
|
+
version=_metadata.version or version(dist),
|
87
115
|
description=metadata(dist)["Summary"],
|
88
116
|
)
|
89
117
|
except PackageNotFoundError:
|
90
118
|
return _Package(name=dist)
|
91
119
|
|
92
120
|
|
93
|
-
def _get_name(dist: str =
|
121
|
+
def _get_name(dist: str = _metadata.name) -> str:
|
94
122
|
"""Get name of the given distribution.
|
95
123
|
|
96
124
|
Parameters:
|
@@ -102,7 +130,7 @@ def _get_name(dist: str = __PACKAGE_NAME__) -> str:
|
|
102
130
|
return _get_package_info(dist).name
|
103
131
|
|
104
132
|
|
105
|
-
def _get_version(dist: str =
|
133
|
+
def _get_version(dist: str = _metadata.name) -> str:
|
106
134
|
"""Get version of the given distribution.
|
107
135
|
|
108
136
|
Parameters:
|
@@ -114,7 +142,7 @@ def _get_version(dist: str = __PACKAGE_NAME__) -> str:
|
|
114
142
|
return _get_package_info(dist).version
|
115
143
|
|
116
144
|
|
117
|
-
def _get_description(dist: str =
|
145
|
+
def _get_description(dist: str = _metadata.name) -> str:
|
118
146
|
"""Get description of the given distribution.
|
119
147
|
|
120
148
|
Parameters:
|
@@ -133,10 +161,10 @@ def _get_debug_info() -> _Environment:
|
|
133
161
|
Environment information.
|
134
162
|
"""
|
135
163
|
py_name, py_version = _interpreter_name_version()
|
136
|
-
packages: list[str] = [
|
164
|
+
packages: list[str] = [_metadata.name]
|
137
165
|
variables: list[str] = [
|
138
166
|
"PYTHONPATH",
|
139
|
-
*[var for var in os.environ if var.startswith(
|
167
|
+
*[var for var in os.environ if var.startswith(_metadata.name.replace("-", "_"))],
|
140
168
|
]
|
141
169
|
return _Environment(
|
142
170
|
interpreter_name=py_name,
|
@@ -189,7 +189,7 @@ def zap_multi(
|
|
189
189
|
>>> zap_multi("!?*", "Hello!? World! *", "-")
|
190
190
|
'Hello- World- -'
|
191
191
|
"""
|
192
|
-
zapper = Zapper(sym, src, replace, atomic=atomic)
|
192
|
+
zapper: Zapper[str] = Zapper(sym, src, replace, atomic=atomic)
|
193
193
|
return zapper.zap().value
|
194
194
|
|
195
195
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from collections.abc import Callable
|
2
2
|
from io import StringIO
|
3
|
+
import json
|
3
4
|
from logging import Formatter, Handler, LogRecord
|
4
5
|
from logging.handlers import BufferingHandler
|
5
6
|
import threading
|
@@ -94,6 +95,24 @@ class ConsoleFormatter(Formatter):
|
|
94
95
|
return super().format(record)
|
95
96
|
|
96
97
|
|
98
|
+
class JSONLFormatter(Formatter):
|
99
|
+
"""A formatter that outputs log records in JSON Lines format."""
|
100
|
+
|
101
|
+
def format(self, record: LogRecord) -> str:
|
102
|
+
extra: LoggerExtraInfo = get_extra(record)
|
103
|
+
log_entry = {
|
104
|
+
"time": self.formatTime(record, self.datefmt),
|
105
|
+
"level": record.levelname,
|
106
|
+
"message": record.msg,
|
107
|
+
"funcName": record.funcName,
|
108
|
+
"name": record.name,
|
109
|
+
"module": record.module,
|
110
|
+
"line": record.lineno,
|
111
|
+
**extra,
|
112
|
+
}
|
113
|
+
return json.dumps(log_entry)
|
114
|
+
|
115
|
+
|
97
116
|
class ConsoleBuffering(BufferingHandler):
|
98
117
|
def __init__(
|
99
118
|
self,
|
@@ -15,6 +15,8 @@ from rich.text import Text
|
|
15
15
|
from rich.theme import Theme, ThemeStack
|
16
16
|
from rich.themes import DEFAULT
|
17
17
|
|
18
|
+
from bear_utils.logger_manager._log_level import LogLevel
|
19
|
+
|
18
20
|
if TYPE_CHECKING:
|
19
21
|
from rich.color import ColorSystem
|
20
22
|
from rich.live import Live
|
@@ -62,6 +64,7 @@ class LogConsole[T: TextIO](Console):
|
|
62
64
|
get_datetime: Callable[[], datetime] | None = None,
|
63
65
|
get_time: Callable[[], float] | None = None,
|
64
66
|
_environ: Mapping[str, str] | None = None,
|
67
|
+
level: str | int | LogLevel = LogLevel.INFO,
|
65
68
|
):
|
66
69
|
# Copy of os.environ allows us to replace it for testing
|
67
70
|
if _environ is not None:
|
@@ -144,6 +147,7 @@ class LogConsole[T: TextIO](Console):
|
|
144
147
|
self._render_hooks: list[RenderHook] = []
|
145
148
|
self._live: Live | None = None
|
146
149
|
self._is_alt_screen = False
|
150
|
+
self.level: LogLevel = LogLevel.get(level, default=LogLevel.INFO)
|
147
151
|
|
148
152
|
@property
|
149
153
|
def file(self) -> T:
|
@@ -159,37 +163,52 @@ class LogConsole[T: TextIO](Console):
|
|
159
163
|
"""Set a new file object."""
|
160
164
|
self._file = new_file
|
161
165
|
|
166
|
+
def _log(self, level: LogLevel, msg: object, *args, **kwargs) -> None:
|
167
|
+
"""Log a message at the specified level.
|
168
|
+
|
169
|
+
Args:
|
170
|
+
level (LogLevel): The log level for the message. We aren't using this parameter in the current implementation,
|
171
|
+
msg (object): The message to log.
|
172
|
+
*args: Additional positional arguments.
|
173
|
+
**kwargs: Additional keyword arguments.
|
174
|
+
"""
|
175
|
+
if level.value >= self.level.value:
|
176
|
+
"""Log a message at the specified level."""
|
177
|
+
with self._lock:
|
178
|
+
if not self.quiet:
|
179
|
+
self.log(msg, *args, **kwargs)
|
180
|
+
|
162
181
|
def info(self, msg: object, *args, **kwargs) -> None:
|
163
182
|
"""Log an informational message to the console."""
|
164
|
-
self.
|
183
|
+
self._log(LogLevel.INFO, msg, *args, **kwargs)
|
165
184
|
|
166
185
|
def warning(self, msg: object, *args, **kwargs) -> None:
|
167
186
|
"""Log a warning message to the console."""
|
168
|
-
self.
|
187
|
+
self._log(LogLevel.WARNING, msg, *args, **kwargs)
|
169
188
|
|
170
189
|
def error(self, msg: object, *args, **kwargs) -> None:
|
171
190
|
"""Log an error message to the console."""
|
172
|
-
self.
|
191
|
+
self._log(LogLevel.ERROR, msg, *args, **kwargs)
|
173
192
|
|
174
193
|
def debug(self, msg: object, *args, **kwargs) -> None:
|
175
194
|
"""Log a debug message to the console."""
|
176
|
-
self.
|
195
|
+
self._log(LogLevel.DEBUG, msg, *args, **kwargs)
|
177
196
|
|
178
197
|
def verbose(self, msg: object, *args, **kwargs) -> None:
|
179
198
|
"""Log a verbose message to the console."""
|
180
|
-
self.
|
199
|
+
self._log(LogLevel.VERBOSE, msg, *args, **kwargs)
|
181
200
|
|
182
201
|
def success(self, msg: object, *args, **kwargs) -> None:
|
183
202
|
"""Log a success message to the console."""
|
184
|
-
self.
|
203
|
+
self._log(LogLevel.SUCCESS, msg, *args, **kwargs)
|
185
204
|
|
186
205
|
def failure(self, msg: object, *args, **kwargs) -> None:
|
187
206
|
"""Log a failure message to the console."""
|
188
|
-
self.
|
207
|
+
self._log(LogLevel.FAILURE, msg, *args, **kwargs)
|
189
208
|
|
190
209
|
def exception(self, msg: object, *args, **kwargs) -> None:
|
191
210
|
"""Log an exception message to the console."""
|
192
|
-
self.
|
211
|
+
self._log(LogLevel.ERROR, msg, *args, **kwargs)
|
193
212
|
|
194
213
|
|
195
214
|
if __name__ == "__main__":
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/console_logger.py
RENAMED
@@ -14,7 +14,7 @@ from rich.theme import Theme
|
|
14
14
|
|
15
15
|
from bear_utils.constants.date_related import DATE_TIME_FORMAT
|
16
16
|
from bear_utils.logger_manager._common import FIVE_MEGABYTES, VERBOSE_CONSOLE_FORMAT, VERBOSE_FORMAT, ExecValues
|
17
|
-
from bear_utils.logger_manager.
|
17
|
+
from bear_utils.logger_manager._logger_misc import ConsoleBuffering, ConsoleFormatter, ConsoleHandler
|
18
18
|
|
19
19
|
from .base_logger import BaseLogger
|
20
20
|
|
@@ -124,6 +124,24 @@ class ConsoleLogger(Logger, BaseLogger):
|
|
124
124
|
for handler in self._handlers:
|
125
125
|
self.addHandler(handler)
|
126
126
|
|
127
|
+
def set_console_formatter(self, fmt: str = VERBOSE_CONSOLE_FORMAT) -> None:
|
128
|
+
"""Set the formatter for the console handler."""
|
129
|
+
if hasattr(self, "console_handler"):
|
130
|
+
self.console_handler.setFormatter(ConsoleFormatter(fmt=fmt, datefmt=DATE_TIME_FORMAT))
|
131
|
+
self.verbose(f"ConsoleLogger: Console formatter set to {fmt}")
|
132
|
+
|
133
|
+
def set_file_formatter(self, fmt: str = VERBOSE_FORMAT) -> None:
|
134
|
+
"""Set the formatter for the file handler."""
|
135
|
+
if hasattr(self, "file_handler"):
|
136
|
+
self.file_handler.setFormatter(Formatter(fmt=fmt, datefmt=DATE_TIME_FORMAT))
|
137
|
+
self.verbose(f"ConsoleLogger: File formatter set to {fmt}")
|
138
|
+
|
139
|
+
def set_buffer_formatter(self, fmt: str = VERBOSE_CONSOLE_FORMAT) -> None:
|
140
|
+
"""Set the formatter for the buffer handler."""
|
141
|
+
if hasattr(self, "buffer_handler"):
|
142
|
+
self.buffer_handler.setFormatter(ConsoleFormatter(fmt=fmt, datefmt=DATE_TIME_FORMAT))
|
143
|
+
self.verbose(f"ConsoleLogger: Buffer formatter set to {fmt}")
|
144
|
+
|
127
145
|
def stop_queue_listener(self) -> None:
|
128
146
|
"""Stop the queue listener if it exists and clean up resources."""
|
129
147
|
if hasattr(self, "listener"):
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/console_logger.pyi
RENAMED
@@ -5,7 +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.
|
8
|
+
from bear_utils.logger_manager._logger_misc import ConsoleBuffering, ConsoleHandler
|
9
9
|
|
10
10
|
from .base_logger import BaseLogger
|
11
11
|
from .sub_logger import SubConsoleLogger
|
@@ -1 +0,0 @@
|
|
1
|
-
version = "0.9.5"
|
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
|
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
|
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
|
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
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/_base_file_handler.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/file_handler_factory.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/json_file_handler.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/log_file_handler.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/toml_file_handler.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/txt_file_handler.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/files/file_handlers/yaml_file_handler.py
RENAMED
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
|
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
|
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
|
File without changes
|
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/basic_logger/__init__.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/basic_logger/logger.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/basic_logger/logger.pyi
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/buffer_logger.py
RENAMED
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/fastapi_logger.py
RENAMED
File without changes
|
File without changes
|
{bear_utils-0.9.5 → bear_utils-0.9.7}/src/bear_utils/logger_manager/loggers/simple_logger.py
RENAMED
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
|
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
|