bear-utils 0.7.14__py3-none-any.whl → 0.7.16__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/cli/__init__.py +1 -1
- bear_utils/cli/commands.py +40 -0
- bear_utils/cli/shell/_base_command.py +5 -4
- bear_utils/files/file_handlers/file_handler_factory.py +2 -0
- bear_utils/files/file_handlers/toml_file_handler.py +68 -0
- {bear_utils-0.7.14.dist-info → bear_utils-0.7.16.dist-info}/METADATA +18 -22
- {bear_utils-0.7.14.dist-info → bear_utils-0.7.16.dist-info}/RECORD +10 -9
- {bear_utils-0.7.14.dist-info → bear_utils-0.7.16.dist-info}/WHEEL +1 -1
bear_utils/cli/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from .commands import MaskShellCommand, OPShellCommand, UVShellCommand
|
1
|
+
from .commands import GitCommand, MaskShellCommand, OPShellCommand, UVShellCommand
|
2
2
|
from .shell._base_command import BaseShellCommand
|
3
3
|
from .shell._base_shell import SimpleShellSession, shell_session
|
4
4
|
from .shell._common import DEFAULT_SHELL
|
bear_utils/cli/commands.py
CHANGED
@@ -52,8 +52,48 @@ class MaskShellCommand(BaseShellCommand):
|
|
52
52
|
return cls.sub("init", *args, **kwargs)
|
53
53
|
|
54
54
|
|
55
|
+
class GitCommand(BaseShellCommand):
|
56
|
+
"""Base class for Git commands"""
|
57
|
+
|
58
|
+
command_name = "git"
|
59
|
+
|
60
|
+
def __init__(self, *args, **kwargs):
|
61
|
+
super().__init__(*args, **kwargs)
|
62
|
+
|
63
|
+
@classmethod
|
64
|
+
def init(cls, *args, **kwargs) -> "GitCommand":
|
65
|
+
"""Initialize a new Git repository"""
|
66
|
+
return cls.sub("init", *args, **kwargs)
|
67
|
+
|
68
|
+
@classmethod
|
69
|
+
def status(cls, *args, **kwargs) -> "GitCommand":
|
70
|
+
"""Get the status of the Git repository"""
|
71
|
+
return cls.sub("status", *args, **kwargs)
|
72
|
+
|
73
|
+
@classmethod
|
74
|
+
def log(cls, *args, **kwargs) -> "GitCommand":
|
75
|
+
"""Show the commit logs"""
|
76
|
+
return cls.sub("log", *args, **kwargs)
|
77
|
+
|
78
|
+
@classmethod
|
79
|
+
def add(cls, files, *args, **kwargs) -> "GitCommand":
|
80
|
+
"""Add files to the staging area"""
|
81
|
+
return cls.sub("add", *args, **kwargs).value(files)
|
82
|
+
|
83
|
+
@classmethod
|
84
|
+
def diff(cls, *args, **kwargs) -> "GitCommand":
|
85
|
+
"""Show changes between commits, commit and working tree, etc."""
|
86
|
+
return cls.sub("diff", *args, **kwargs)
|
87
|
+
|
88
|
+
@classmethod
|
89
|
+
def commit(cls, message: str, *args, **kwargs) -> "GitCommand":
|
90
|
+
"""Commit changes with a message"""
|
91
|
+
return cls.sub("commit -m", *args, **kwargs).value(f"'{message}'")
|
92
|
+
|
93
|
+
|
55
94
|
__all__ = [
|
56
95
|
"MaskShellCommand",
|
57
96
|
"OPShellCommand",
|
58
97
|
"UVShellCommand",
|
98
|
+
"GitCommand",
|
59
99
|
]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from asyncio.subprocess import Process
|
2
|
+
from subprocess import CompletedProcess
|
1
3
|
from typing import ClassVar, Generic, Self, TypeVar
|
2
4
|
|
3
5
|
T = TypeVar("T", bound=str)
|
@@ -56,13 +58,12 @@ class BaseShellCommand(Generic[T]):
|
|
56
58
|
return f"{joined} {self.suffix}"
|
57
59
|
return joined
|
58
60
|
|
59
|
-
def do(self) -> Self:
|
61
|
+
def do(self, **kwargs) -> Self:
|
60
62
|
"""Run the command using subprocess"""
|
61
63
|
from ._base_shell import shell_session
|
62
64
|
|
63
|
-
with shell_session() as session:
|
64
|
-
session.add(
|
65
|
-
self.result = session.run()
|
65
|
+
with shell_session(**kwargs) as session:
|
66
|
+
self.result: CompletedProcess[str] | Process = session.add(self.cmd).run()
|
66
67
|
return self
|
67
68
|
|
68
69
|
def get(self) -> str:
|
@@ -46,6 +46,7 @@ class FileHandlerFactory:
|
|
46
46
|
try:
|
47
47
|
from .json_file_handler import JsonFileHandler
|
48
48
|
from .log_file_handler import LogFileHandler
|
49
|
+
from .toml_file_handler import TomlFileHandler
|
49
50
|
from .txt_file_handler import TextFileHandler
|
50
51
|
from .yaml_file_handler import YamlFileHandler
|
51
52
|
|
@@ -53,6 +54,7 @@ class FileHandlerFactory:
|
|
53
54
|
self.register_handler(TextFileHandler)
|
54
55
|
self.register_handler(YamlFileHandler)
|
55
56
|
self.register_handler(LogFileHandler)
|
57
|
+
self.register_handler(TomlFileHandler)
|
56
58
|
|
57
59
|
except ImportError as e:
|
58
60
|
warnings.warn(f"Could not import all default handlers: {e}")
|
@@ -0,0 +1,68 @@
|
|
1
|
+
from dataclasses import dataclass
|
2
|
+
from pathlib import Path
|
3
|
+
from typing import Any, ClassVar
|
4
|
+
|
5
|
+
import toml
|
6
|
+
|
7
|
+
from ._base_file_handler import FileHandler
|
8
|
+
|
9
|
+
|
10
|
+
class TomlFileHandler(FileHandler):
|
11
|
+
"""Class for handling .toml files with read, write, and present methods"""
|
12
|
+
|
13
|
+
valid_extensions: ClassVar[list[str]] = ["toml"]
|
14
|
+
|
15
|
+
@FileHandler.ValidateFileType
|
16
|
+
def read_file(self, file_path: Path) -> dict:
|
17
|
+
try:
|
18
|
+
super().read_file(file_path)
|
19
|
+
|
20
|
+
return toml.load(file_path)
|
21
|
+
except Exception as e:
|
22
|
+
raise ValueError(f"Error reading file: {e}")
|
23
|
+
|
24
|
+
@FileHandler.ValidateFileType
|
25
|
+
def write_file(self, file_path: Path, data: dict[str, Any] | str, **kwargs) -> None:
|
26
|
+
try:
|
27
|
+
super().write_file(file_path, data)
|
28
|
+
|
29
|
+
with open(file_path, "w", encoding="utf-8") as file:
|
30
|
+
if isinstance(data, dict):
|
31
|
+
toml.dump(data, file, **kwargs)
|
32
|
+
else:
|
33
|
+
file.write(data)
|
34
|
+
except Exception as e:
|
35
|
+
raise ValueError(f"Error writing file: {e}")
|
36
|
+
|
37
|
+
def present_file(self, data: dict[str, Any] | str, **kwargs) -> str:
|
38
|
+
raise NotImplementedError("Presenting TOML files is not implemented. Not needed.")
|
39
|
+
|
40
|
+
|
41
|
+
@dataclass
|
42
|
+
class PyProjectToml:
|
43
|
+
"""Dataclass for handling pyproject.toml files"""
|
44
|
+
|
45
|
+
name: str
|
46
|
+
version: str
|
47
|
+
description: str | None = None
|
48
|
+
author_name: str | None = None
|
49
|
+
author_email: str | None = None
|
50
|
+
dependencies: list[str] | None = None
|
51
|
+
|
52
|
+
def __post_init__(self):
|
53
|
+
if self.dependencies:
|
54
|
+
self.dependencies = [dep.split(" ")[0] for dep in self.dependencies if isinstance(dep, str)]
|
55
|
+
self.dependencies = [dep.split(">=")[0] for dep in self.dependencies]
|
56
|
+
|
57
|
+
@classmethod
|
58
|
+
def from_dict(cls, data: dict[str, Any]) -> "PyProjectToml":
|
59
|
+
data = data.get("project", {})
|
60
|
+
authors: dict = data.get("authors", {})[0]
|
61
|
+
return cls(
|
62
|
+
name=data.get("name", ""),
|
63
|
+
version=data.get("version", ""),
|
64
|
+
description=data.get("description"),
|
65
|
+
author_name=authors.get("name") if authors else None,
|
66
|
+
author_email=authors.get("email") if authors else None,
|
67
|
+
dependencies=data.get("dependencies", []),
|
68
|
+
)
|
@@ -1,29 +1,26 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: bear-utils
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.16
|
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
|
-
Author: chaz
|
6
|
-
Author-email: bright.lid5647@fastmail.com
|
5
|
+
Author-email: chaz <bright.lid5647@fastmail.com>
|
7
6
|
Requires-Python: >=3.12
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Requires-Dist:
|
12
|
-
Requires-Dist:
|
13
|
-
Requires-Dist:
|
14
|
-
Requires-Dist:
|
15
|
-
Requires-Dist:
|
16
|
-
Requires-Dist:
|
17
|
-
Requires-Dist:
|
18
|
-
Requires-Dist:
|
19
|
-
Requires-Dist:
|
20
|
-
Requires-Dist:
|
21
|
-
Requires-Dist:
|
22
|
-
Requires-Dist: singleton-base (>=1.0.5)
|
23
|
-
Requires-Dist: sqlalchemy (>=2.0.40,<3.0.0)
|
7
|
+
Requires-Dist: bear-epoch-time>=1.0.1
|
8
|
+
Requires-Dist: diskcache<6.0.0,>=5.6.3
|
9
|
+
Requires-Dist: httpx>=0.28.1
|
10
|
+
Requires-Dist: pathspec>=0.12.1
|
11
|
+
Requires-Dist: pillow<12.0.0,>=11.2.1
|
12
|
+
Requires-Dist: prompt-toolkit<4.0.0,>=3.0.51
|
13
|
+
Requires-Dist: pydantic>=2.11.5
|
14
|
+
Requires-Dist: pyglm<3.0.0,>=2.8.2
|
15
|
+
Requires-Dist: pyqt6>=6.9.0
|
16
|
+
Requires-Dist: pyyaml>=6.0.2
|
17
|
+
Requires-Dist: rich<15.0.0,>=14.0.0
|
18
|
+
Requires-Dist: singleton-base>=1.0.5
|
19
|
+
Requires-Dist: sqlalchemy<3.0.0,>=2.0.40
|
20
|
+
Requires-Dist: toml>=0.10.2
|
24
21
|
Description-Content-Type: text/markdown
|
25
22
|
|
26
|
-
# Bear Utils v# Bear Utils v0.7.
|
23
|
+
# Bear Utils v# Bear Utils v0.7.16
|
27
24
|
|
28
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.
|
29
26
|
|
@@ -257,4 +254,3 @@ def handle_function(func):
|
|
257
254
|
# Handle sync function
|
258
255
|
pass
|
259
256
|
```
|
260
|
-
|
@@ -6,11 +6,11 @@ bear_utils/ai/ai_helpers/_config.py,sha256=UX7wPIiEr2Uqt2kZWtMaYagmRFmUsQKSuopQ4
|
|
6
6
|
bear_utils/ai/ai_helpers/_parsers.py,sha256=aWbbrB44pRI-CZpmPuVCQalcEd17BDUtE2FVQstq3rU,7993
|
7
7
|
bear_utils/ai/ai_helpers/_types.py,sha256=yTvB00bKIZXu-BKoXtZv6I3vHrxBwxO0gpl61bEslrY,550
|
8
8
|
bear_utils/cache/__init__.py,sha256=PRXhqzVCoMLlu1AwLcNz1w39n4dvjkj3__uYUFQk8Nk,4109
|
9
|
-
bear_utils/cli/__init__.py,sha256=
|
10
|
-
bear_utils/cli/commands.py,sha256=
|
9
|
+
bear_utils/cli/__init__.py,sha256=umMR79Zskl2YY2gWh3e8yI_DEEi5kfb9mPKWlTPxIfY,239
|
10
|
+
bear_utils/cli/commands.py,sha256=2uVYhU3qXdpkmQ3gKaUgsplfJMpEVxVGvdnJl-3H7to,2806
|
11
11
|
bear_utils/cli/prompt_helpers.py,sha256=aGfa4tnO24kFKC-CBJhoiKtll8kc_uU5RvXmxSoD5BM,6094
|
12
12
|
bear_utils/cli/shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
-
bear_utils/cli/shell/_base_command.py,sha256=
|
13
|
+
bear_utils/cli/shell/_base_command.py,sha256=4VsInKhWRSzPyllnXXdueCDKwJz6i7ioZP1bZN-K5T4,2360
|
14
14
|
bear_utils/cli/shell/_base_shell.py,sha256=XW55HapnW2_1UnM-SKFQtQgqtOl6uUpUmT0Mn-Mfj6s,14529
|
15
15
|
bear_utils/cli/shell/_common.py,sha256=_KQyL5lvqOfjonFIwlEOyp3K9G3TSOj19RhgVzfNNpg,669
|
16
16
|
bear_utils/config/__init__.py,sha256=htYbcAhIAGXgA4BaSQMKRtwu5RjWwNsnAiD0JxZ82aE,289
|
@@ -34,14 +34,15 @@ bear_utils/extras/platform_utils.py,sha256=vRLybOm_Kk4ysVyNdsv1oTrMHD64vPeGre23f
|
|
34
34
|
bear_utils/extras/wrappers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
35
|
bear_utils/extras/wrappers/add_methods.py,sha256=8JI9oFakHRBHcyix6sgqfiXZyXW5antLbyRdFL4F1_M,4222
|
36
36
|
bear_utils/files/__init__.py,sha256=Xzo1229NTq-NaeQIvsqUSaFxwm8DFmpxEIfnhDb_uHg,142
|
37
|
+
bear_utils/files/ignore_parser.py,sha256=W8SQDUm-_R9abUwvcaA7zr8me281N0kLIP823_sAoyA,10678
|
37
38
|
bear_utils/files/file_handlers/__init__.py,sha256=hXoxBoUP343DyjjBFxQRF7cCB1tEMNor2huYOdlGvqo,87
|
38
39
|
bear_utils/files/file_handlers/_base_file_handler.py,sha256=jNmdYfpN6DRplKNR590Yy3Vd9wuPg27DwnSlm79Ed3o,3164
|
39
|
-
bear_utils/files/file_handlers/file_handler_factory.py,sha256=
|
40
|
+
bear_utils/files/file_handlers/file_handler_factory.py,sha256=OJ8Gj0gIpWIr-rlhw52iiR02YJ6nTQuVpylPKCpvFSA,9856
|
40
41
|
bear_utils/files/file_handlers/json_file_handler.py,sha256=YUz4yFHHzO6HcQl0kiiWZCMp57FEaUJ6_yNGhw6tJz4,1482
|
41
42
|
bear_utils/files/file_handlers/log_file_handler.py,sha256=hScsVnJkO17y9tovJatY7VpMyO5kzFGv_1OnQ9oQCiU,1246
|
43
|
+
bear_utils/files/file_handlers/toml_file_handler.py,sha256=TWg7dG6OV4diK1NBjDxYPJnYtYVXOYwXmUmeEz_d_g4,2287
|
42
44
|
bear_utils/files/file_handlers/txt_file_handler.py,sha256=dsw1sO6KwzMcqmwt5_UZSv9SF1xisN2Zo2cRNYcO_XI,1250
|
43
45
|
bear_utils/files/file_handlers/yaml_file_handler.py,sha256=Oe8U0fYtDv7q8sFWs_rO3uRQa9olEbrGWF1JuQ2iyTk,2083
|
44
|
-
bear_utils/files/ignore_parser.py,sha256=W8SQDUm-_R9abUwvcaA7zr8me281N0kLIP823_sAoyA,10678
|
45
46
|
bear_utils/graphics/__init__.py,sha256=N6EXOyAVoytsKecFKvi4P9Q0biEZeLkLBDor5YFUqYg,218
|
46
47
|
bear_utils/graphics/bear_gradient.py,sha256=bwjJobhgMguEA0FQnjpGzyU3CzFG4bxEvxJtJXAKBcc,4808
|
47
48
|
bear_utils/graphics/image_helpers.py,sha256=fy96H_BkuiCXecDXCMmrlH-SWGsA5SkEUSxlKGzcibI,1374
|
@@ -54,6 +55,7 @@ bear_utils/gui/gui_tools/qt_color_picker.py,sha256=c_-VMaSqSiceDc3mmu7SPRJ3E_ZWj
|
|
54
55
|
bear_utils/gui/gui_tools/qt_file_handler.py,sha256=vOYSlQTFiRi-FtXqagp1M_jRSOjz7W-LCb8KXlEtr50,4325
|
55
56
|
bear_utils/gui/gui_tools/qt_input_dialog.py,sha256=MwZ2myLEKRZlldYH_rZtEzPeaz3-fRBP06xBmkTKyAk,9224
|
56
57
|
bear_utils/logging/__init__.py,sha256=o5MX0ow4ugo3JhS2k9vFO0HMzTwUBVnzdhoJBCmqW1g,492
|
58
|
+
bear_utils/logging/loggers.py,sha256=oFdKrm9ot7F4pKghzYQrq-BK7RfevKQSBaHsmSolHTA,3196
|
57
59
|
bear_utils/logging/logger_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
58
60
|
bear_utils/logging/logger_manager/_common.py,sha256=6r69PIqk6IaIauxax35c5Paz1J1iv87ukbvoZ3uWI_Q,1582
|
59
61
|
bear_utils/logging/logger_manager/_console_junk.py,sha256=vMChuVTNxyxly-onEad1u2tsb6syalXjFVfxOS2-qHw,4821
|
@@ -69,10 +71,9 @@ bear_utils/logging/logger_manager/loggers/_level_sin.py,sha256=n4EJUZc_z2YQkTzbV
|
|
69
71
|
bear_utils/logging/logger_manager/loggers/_logger.py,sha256=RbqfrHSyaxIbXEDO63WK5oGMVXsMJIL1Rx8_frYacsQ,547
|
70
72
|
bear_utils/logging/logger_manager/loggers/_sub_logger.py,sha256=YMW03UP9fh_c51Ls1KEoMr-bcAfMt4tTT0OIELpDa_k,3471
|
71
73
|
bear_utils/logging/logger_manager/loggers/_sub_logger.pyi,sha256=-SCh73lTkqolDq-5Ll-lstfl-88gi-E3y1FIknBoI5w,1520
|
72
|
-
bear_utils/logging/loggers.py,sha256=oFdKrm9ot7F4pKghzYQrq-BK7RfevKQSBaHsmSolHTA,3196
|
73
74
|
bear_utils/monitoring/__init__.py,sha256=cj7UYsipfYFwxQmXtMpziAv4suRtGzWEdjdwOCbxJN4,168
|
74
75
|
bear_utils/monitoring/host_monitor.py,sha256=GwIK9X8rATUhYIbOXi4MINfACWgO3T1vzUK1gSK_TQc,12902
|
75
76
|
bear_utils/time/__init__.py,sha256=EHzc9KiGG3l6mAPhiIeFcYqxQG_w0QQ1ES3yRFVr8ug,721
|
76
|
-
bear_utils-0.7.
|
77
|
-
bear_utils-0.7.
|
78
|
-
bear_utils-0.7.
|
77
|
+
bear_utils-0.7.16.dist-info/METADATA,sha256=S7g4ny5792tsaI6u-NxZVP7Yds5zU8SvGC83NtE5R90,7326
|
78
|
+
bear_utils-0.7.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
79
|
+
bear_utils-0.7.16.dist-info/RECORD,,
|