bear-utils 0.8.5__py3-none-any.whl → 0.8.6__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.
@@ -1,5 +1,5 @@
1
1
  from subprocess import CompletedProcess
2
- from typing import TYPE_CHECKING, Any, ClassVar, LiteralString, Self, cast
2
+ from typing import TYPE_CHECKING, Any, ClassVar, Self
3
3
 
4
4
  if TYPE_CHECKING:
5
5
  from subprocess import CompletedProcess
@@ -50,9 +50,9 @@ class BaseShellCommand[T: str]:
50
50
  @property
51
51
  def cmd(self) -> str:
52
52
  """Return the full command as a string"""
53
- cmd_parts = [self.command_name, self.sub_command, *self.args]
54
- cmd_parts = [part for part in cmd_parts if part]
55
- joined: LiteralString = " ".join(cmd_parts).strip()
53
+ cmd_parts: list[str] = [self.command_name, self.sub_command, *self.args]
54
+ cmd_parts: list[str] = [part for part in cmd_parts if part]
55
+ joined: str = " ".join(cmd_parts).strip()
56
56
  if self.suffix:
57
57
  return f"{joined} {self.suffix}"
58
58
  return joined
@@ -64,9 +64,17 @@ class BaseShellCommand[T: str]:
64
64
  with shell_session(**kwargs) as session:
65
65
  result: CompletedProcess[str] = session.add(self.cmd).run()
66
66
  if result is not None:
67
- self.result = cast("CompletedProcess[str]", result)
67
+ self.result = result
68
68
  return self
69
69
 
70
+ def get_result(self) -> CompletedProcess[str]:
71
+ """Get the result of the command execution"""
72
+ if self.result is None:
73
+ self.do()
74
+ if self.result is None:
75
+ raise RuntimeError("Command execution failed for some reason.")
76
+ return self.result
77
+
70
78
  def get(self) -> str:
71
79
  """Get the result of the command execution"""
72
80
  if self.result is None:
@@ -180,7 +180,7 @@ class SimpleShellSession:
180
180
  self.reset_buffer()
181
181
  return self.result
182
182
 
183
- def run(self, cmd: str | BaseShellCommand | None = None, *args) -> CompletedProcess[str] | Process:
183
+ def run(self, cmd: str | BaseShellCommand | None = None, *args) -> CompletedProcess[str]:
184
184
  """Run the accumulated command history"""
185
185
  if self.empty_history and cmd is None:
186
186
  raise ValueError("No commands to run")
@@ -191,12 +191,12 @@ class SimpleShellSession:
191
191
  )
192
192
 
193
193
  if self.has_history and cmd is None:
194
- result: CompletedProcess[str] | Process = self._run(self.cmd)
194
+ result: CompletedProcess[str] = self._run(self.cmd)
195
195
  elif self.empty_history and cmd is not None:
196
196
  self.cmd_buffer.write(f"{cmd} ")
197
197
  if args:
198
198
  self.cmd_buffer.write(" ".join(map(str, args)))
199
- result: CompletedProcess[str] | Process = self._run(self.cmd)
199
+ result: CompletedProcess[str] = self._run(self.cmd)
200
200
  else:
201
201
  raise ValueError("Unexpected state")
202
202
  self.reset_buffer()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bear-utils
3
- Version: 0.8.5
3
+ Version: 0.8.6
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
@@ -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.8.5
23
+ # Bear Utils v# Bear Utils v0.8.6
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
 
@@ -14,8 +14,8 @@ bear_utils/cli/__init__.py,sha256=H2QpLyHpQS_Yn3sF2px7n4KqT97LEe7Oyzafg2iHcpc,50
14
14
  bear_utils/cli/commands.py,sha256=5ppEjvVV_g28WLaIFtKgz-ctzwoo-g-KpHTXNx9xBzo,3161
15
15
  bear_utils/cli/prompt_helpers.py,sha256=DVdg1f5yZElVyFNao6RTPfrc6mKy4PoXLgY6az-ejo8,6580
16
16
  bear_utils/cli/shell/__init__.py,sha256=2s3oR6CqLKj1iyERy7YafWT3t3KzTr70Z1yaLKa6IiQ,42
17
- bear_utils/cli/shell/_base_command.py,sha256=I2yG1YBPXl2nKX5y3a2kokfdboD0-MGzJ1M7jtJaTUw,2534
18
- bear_utils/cli/shell/_base_shell.py,sha256=l0lbFTqqF-gn5TEzGYu2SyDELbUj0qNDim1v6ycLg2c,16727
17
+ bear_utils/cli/shell/_base_command.py,sha256=T1bwY9UX355Mv2u7JjSgI4U7VoWCTibszG8WvC3IEo4,2789
18
+ bear_utils/cli/shell/_base_shell.py,sha256=GW2kgj_KR33FtJLvV-ljSs_wzo5WQ8--H-K2hDPOblQ,16697
19
19
  bear_utils/cli/shell/_common.py,sha256=_KQyL5lvqOfjonFIwlEOyp3K9G3TSOj19RhgVzfNNpg,669
20
20
  bear_utils/config/__init__.py,sha256=HC_lWpmLF0kbPr5i1Wa2FLER2b446E_GecgU9EPmc04,353
21
21
  bear_utils/config/config_manager.py,sha256=Xj0xOmY-wo_rwfcWiXyxNZWX9NknX_Jm9W56Gx8yyHQ,8244
@@ -80,6 +80,6 @@ bear_utils/monitoring/__init__.py,sha256=9DKNIWTp_voLnaWgiP-wJ-o_N0hYixo-MzjUmg8
80
80
  bear_utils/monitoring/_common.py,sha256=LYQFxgTP9fk0cH71IQTuGwBYYPWCqHP_mMRNecoD76M,657
81
81
  bear_utils/monitoring/host_monitor.py,sha256=e0TYRJw9iDj5Ga6y3ck1TBFEeH42Cax5mQYaNU8yams,13241
82
82
  bear_utils/time/__init__.py,sha256=d9Ovv-Dlx5NWgnOl1hY-evznVm9hboS6ypNp1wDFxQQ,934
83
- bear_utils-0.8.5.dist-info/METADATA,sha256=4YF2l-2KEa1Od0MDuFuU-L6U1R6CoaUemmLRrVEVSRk,8634
84
- bear_utils-0.8.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
85
- bear_utils-0.8.5.dist-info/RECORD,,
83
+ bear_utils-0.8.6.dist-info/METADATA,sha256=QG8sOkLV4XiFr490DziS-jSq9tIaICPgMvz--TgyaZI,8634
84
+ bear_utils-0.8.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
85
+ bear_utils-0.8.6.dist-info/RECORD,,