bear-utils 0.7.12__tar.gz → 0.7.14__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.
Files changed (80) hide show
  1. {bear_utils-0.7.12 → bear_utils-0.7.14}/PKG-INFO +2 -2
  2. {bear_utils-0.7.12 → bear_utils-0.7.14}/README.md +1 -1
  3. {bear_utils-0.7.12 → bear_utils-0.7.14}/pyproject.toml +1 -1
  4. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/__init__.py +3 -1
  5. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/cli/shell/_base_shell.py +4 -5
  6. bear_utils-0.7.14/src/bear_utils/constants/date_related.py +23 -0
  7. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/extras/_tools.py +41 -4
  8. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/_styles.py +0 -2
  9. bear_utils-0.7.14/src/bear_utils/time/__init__.py +30 -0
  10. bear_utils-0.7.12/src/bear_utils/constants/date_related.py +0 -1
  11. bear_utils-0.7.12/src/bear_utils/time/__init__.py +0 -13
  12. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/ai/__init__.py +0 -0
  13. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/ai/ai_helpers/__init__.py +0 -0
  14. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/ai/ai_helpers/_common.py +0 -0
  15. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/ai/ai_helpers/_config.py +0 -0
  16. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/ai/ai_helpers/_parsers.py +0 -0
  17. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/ai/ai_helpers/_types.py +0 -0
  18. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/cache/__init__.py +0 -0
  19. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/cli/__init__.py +0 -0
  20. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/cli/commands.py +0 -0
  21. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/cli/prompt_helpers.py +0 -0
  22. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/cli/shell/__init__.py +0 -0
  23. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/cli/shell/_base_command.py +0 -0
  24. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/cli/shell/_common.py +0 -0
  25. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/config/__init__.py +0 -0
  26. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/config/config_manager.py +0 -0
  27. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/config/dir_manager.py +0 -0
  28. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/config/settings_manager.py +0 -0
  29. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/constants/__init__.py +0 -0
  30. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/constants/_exceptions.py +0 -0
  31. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/constants/_lazy_typing.py +0 -0
  32. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/constants/time_related.py +0 -0
  33. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/database/__init__.py +0 -0
  34. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/database/_db_manager.py +0 -0
  35. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/events/__init__.py +0 -0
  36. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/events/events_class.py +0 -0
  37. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/events/events_module.py +0 -0
  38. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/extras/__init__.py +0 -0
  39. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/extras/_async_helpers.py +0 -0
  40. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/extras/platform_utils.py +0 -0
  41. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/extras/wrappers/__init__.py +0 -0
  42. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/extras/wrappers/add_methods.py +0 -0
  43. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/__init__.py +0 -0
  44. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/file_handlers/__init__.py +0 -0
  45. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/file_handlers/_base_file_handler.py +0 -0
  46. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/file_handlers/file_handler_factory.py +0 -0
  47. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/file_handlers/json_file_handler.py +0 -0
  48. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/file_handlers/log_file_handler.py +0 -0
  49. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/file_handlers/txt_file_handler.py +0 -0
  50. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/file_handlers/yaml_file_handler.py +0 -0
  51. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/files/ignore_parser.py +0 -0
  52. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/graphics/__init__.py +0 -0
  53. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/graphics/bear_gradient.py +0 -0
  54. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/graphics/image_helpers.py +0 -0
  55. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/gui/__init__.py +0 -0
  56. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/gui/gui_tools/__init__.py +0 -0
  57. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/gui/gui_tools/_settings.py +0 -0
  58. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/gui/gui_tools/_types.py +0 -0
  59. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/gui/gui_tools/qt_app.py +0 -0
  60. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/gui/gui_tools/qt_color_picker.py +0 -0
  61. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/gui/gui_tools/qt_file_handler.py +0 -0
  62. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/gui/gui_tools/qt_input_dialog.py +0 -0
  63. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/__init__.py +0 -0
  64. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/__init__.py +0 -0
  65. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/_common.py +0 -0
  66. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/_console_junk.py +0 -0
  67. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/__init__.py +0 -0
  68. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_base_logger.py +0 -0
  69. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_base_logger.pyi +0 -0
  70. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_buffer_logger.py +0 -0
  71. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_console_logger.py +0 -0
  72. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_console_logger.pyi +0 -0
  73. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_file_logger.py +0 -0
  74. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_level_sin.py +0 -0
  75. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_logger.py +0 -0
  76. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_sub_logger.py +0 -0
  77. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/logger_manager/loggers/_sub_logger.pyi +0 -0
  78. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/logging/loggers.py +0 -0
  79. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/monitoring/__init__.py +0 -0
  80. {bear_utils-0.7.12 → bear_utils-0.7.14}/src/bear_utils/monitoring/host_monitor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bear-utils
3
- Version: 0.7.12
3
+ Version: 0.7.14
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: chaz
6
6
  Author-email: bright.lid5647@fastmail.com
@@ -23,7 +23,7 @@ Requires-Dist: singleton-base (>=1.0.5)
23
23
  Requires-Dist: sqlalchemy (>=2.0.40,<3.0.0)
24
24
  Description-Content-Type: text/markdown
25
25
 
26
- # Bear Utils v# Bear Utils v0.7.12
26
+ # Bear Utils v# Bear Utils v0.7.14
27
27
 
28
28
  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
29
 
@@ -1,4 +1,4 @@
1
- # Bear Utils v# Bear Utils v0.7.12
1
+ # Bear Utils v# Bear Utils v0.7.14
2
2
 
3
3
  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.
4
4
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bear-utils"
3
- version = "0.7.12"
3
+ version = "0.7.14"
4
4
  description = "Various utilities for Bear programmers, including a rich logging utility, a disk cache, and a SQLite database wrapper amongst other things."
5
5
  authors = [{ name = "chaz", email = "bright.lid5647@fastmail.com" }]
6
6
  readme = "README.md"
@@ -1,3 +1,5 @@
1
+ from importlib.metadata import version
2
+
1
3
  from bear_epoch_time import EpochTimestamp, TimeTools
2
4
 
3
5
  from .cache import CacheWrapper, cache, cache_factory
@@ -10,4 +12,4 @@ from .logging.logger_manager._common import VERBOSE_CONSOLE_FORMAT
10
12
  from .logging.logger_manager._styles import VERBOSE
11
13
  from .logging.loggers import BaseLogger, BufferLogger, ConsoleLogger, FileLogger
12
14
 
13
- __version__ = "0.7.12"
15
+ __version__: str = version("bear-utils")
@@ -284,17 +284,14 @@ class AsyncShellSession(SimpleShellSession):
284
284
  if self.empty_history and cmd is None:
285
285
  raise ValueError("No commands to run")
286
286
 
287
- self.logger.debug(f"Running command: {cmd} with args: {args}")
288
287
  if self.has_history and cmd is not None:
289
288
  raise ValueError("Use `amp` to chain commands, not `run`")
290
289
  if self.has_history and cmd is None:
291
290
  command = self.cmd
292
291
  elif self.empty_history and cmd is not None:
293
292
  self.cmd_buffer.write(f"{cmd}")
294
- self.logger.info(f"{self.cmd_buffer.getvalue()}")
295
293
  if args:
296
294
  self.cmd_buffer.write(" ".join(map(str, args)))
297
-
298
295
  command = self.cmd
299
296
  else:
300
297
  raise ValueError("Unexpected state")
@@ -305,7 +302,9 @@ class AsyncShellSession(SimpleShellSession):
305
302
  """Communicate with the process, sending input and waiting for completion"""
306
303
  if self.process is None:
307
304
  raise ValueError("No process has been started yet")
308
- stdout, stderr = await self.process.communicate(input=stdin.encode("utf-8"))
305
+ bytes_stdin = stdin.encode("utf-8") if isinstance(stdin, str) else stdin
306
+
307
+ stdout, stderr = await self.process.communicate(input=bytes_stdin)
309
308
  return_code = await self.process.wait()
310
309
 
311
310
  self.result = FancyCompletedProcess(
@@ -332,7 +331,7 @@ class AsyncShellSession(SimpleShellSession):
332
331
  if not line: # EOF
333
332
  break
334
333
  yield line.decode("utf-8").rstrip("\n")
335
- except Exception as e:
334
+ except Exception:
336
335
  break
337
336
 
338
337
  async def stream_stdout(self) -> AsyncGenerator[str, None]:
@@ -0,0 +1,23 @@
1
+ from bear_epoch_time.constants.date_related import (
2
+ DATE_FORMAT,
3
+ DATE_TIME_FORMAT,
4
+ DT_FORMAT_WITH_SECONDS,
5
+ DT_FORMAT_WITH_TZ,
6
+ DT_FORMAT_WITH_TZ_AND_SECONDS,
7
+ ET_TIME_ZONE,
8
+ PT_TIME_ZONE,
9
+ TIME_FORMAT_WITH_SECONDS,
10
+ UTC_TIME_ZONE,
11
+ )
12
+
13
+ __all__ = [
14
+ "DATE_FORMAT",
15
+ "DATE_TIME_FORMAT",
16
+ "DT_FORMAT_WITH_SECONDS",
17
+ "DT_FORMAT_WITH_TZ",
18
+ "DT_FORMAT_WITH_TZ_AND_SECONDS",
19
+ "ET_TIME_ZONE",
20
+ "PT_TIME_ZONE",
21
+ "TIME_FORMAT_WITH_SECONDS",
22
+ "UTC_TIME_ZONE",
23
+ ]
@@ -1,5 +1,6 @@
1
1
  import asyncio
2
2
  import shutil
3
+ from asyncio.subprocess import PIPE
3
4
  from collections import deque
4
5
  from functools import cached_property
5
6
  from subprocess import CompletedProcess
@@ -79,7 +80,7 @@ class ClipboardManager:
79
80
  Returns:
80
81
  int: The return code of the command.
81
82
  """
82
- await self.shell.run(self._copy)
83
+ await self.shell.run(self._copy, stdin=PIPE)
83
84
  result: CompletedProcess[str] = await self.shell.communicate(stdin=output)
84
85
  if result.returncode == 0:
85
86
  self.clipboard_history.append(output) # Only append to history if the copy was successful
@@ -125,10 +126,24 @@ def copy_to_clipboard(output: str) -> int:
125
126
  int: The return code of the command.
126
127
  """
127
128
  clipboard_manager = ClipboardManager()
128
- loop = asyncio.get_event_loop()
129
+ loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
129
130
  return loop.run_until_complete(clipboard_manager.copy(output))
130
131
 
131
132
 
133
+ async def copy_to_clipboard_async(output: str) -> int:
134
+ """
135
+ Asynchronously copy the output to the clipboard.
136
+
137
+ Args:
138
+ output (str): The output to copy to the clipboard.
139
+
140
+ Returns:
141
+ int: The return code of the command.
142
+ """
143
+ clipboard_manager = ClipboardManager()
144
+ return await clipboard_manager.copy(output)
145
+
146
+
132
147
  def paste_from_clipboard() -> str:
133
148
  """
134
149
  Paste the output from the clipboard.
@@ -137,10 +152,21 @@ def paste_from_clipboard() -> str:
137
152
  str: The content of the clipboard.
138
153
  """
139
154
  clipboard_manager = ClipboardManager()
140
- loop = asyncio.get_event_loop()
155
+ loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
141
156
  return loop.run_until_complete(clipboard_manager.paste())
142
157
 
143
158
 
159
+ async def paste_from_clipboard_async() -> str:
160
+ """
161
+ Asynchronously paste the output from the clipboard.
162
+
163
+ Returns:
164
+ str: The content of the clipboard.
165
+ """
166
+ clipboard_manager = ClipboardManager()
167
+ return await clipboard_manager.paste()
168
+
169
+
144
170
  def clear_clipboard() -> int:
145
171
  """
146
172
  Clear the clipboard.
@@ -149,10 +175,21 @@ def clear_clipboard() -> int:
149
175
  int: The return code of the command.
150
176
  """
151
177
  clipboard_manager = ClipboardManager()
152
- loop = asyncio.get_event_loop()
178
+ loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
153
179
  return loop.run_until_complete(clipboard_manager.clear())
154
180
 
155
181
 
182
+ async def clear_clipboard_async() -> int:
183
+ """
184
+ Asynchronously clear the clipboard.
185
+
186
+ Returns:
187
+ int: The return code of the command.
188
+ """
189
+ clipboard_manager = ClipboardManager()
190
+ return await clipboard_manager.clear()
191
+
192
+
156
193
  def fmt_header(
157
194
  title: str,
158
195
  sep: str = "#",
@@ -89,5 +89,3 @@ DEFAULT_STYLES: dict[str, str] = {**{method: info["style"] for method, info in L
89
89
  """Just the styles of the logger methods, used to create the theme."""
90
90
 
91
91
  DEFAULT_THEME = Theme(styles=DEFAULT_STYLES)
92
-
93
- print(DEFAULT_STYLES)
@@ -0,0 +1,30 @@
1
+ from bear_epoch_time import EpochTimestamp, TimerData, TimeTools, add_ord_suffix, create_timer, timer
2
+ from bear_epoch_time.constants.date_related import (
3
+ DATE_FORMAT,
4
+ DATE_TIME_FORMAT,
5
+ DT_FORMAT_WITH_SECONDS,
6
+ DT_FORMAT_WITH_TZ,
7
+ DT_FORMAT_WITH_TZ_AND_SECONDS,
8
+ ET_TIME_ZONE,
9
+ PT_TIME_ZONE,
10
+ TIME_FORMAT_WITH_SECONDS,
11
+ UTC_TIME_ZONE,
12
+ )
13
+
14
+ __all__ = [
15
+ "EpochTimestamp",
16
+ "TimerData",
17
+ "create_timer",
18
+ "timer",
19
+ "TimeTools",
20
+ "add_ord_suffix",
21
+ "DATE_FORMAT",
22
+ "DATE_TIME_FORMAT",
23
+ "DT_FORMAT_WITH_SECONDS",
24
+ "DT_FORMAT_WITH_TZ",
25
+ "DT_FORMAT_WITH_TZ_AND_SECONDS",
26
+ "ET_TIME_ZONE",
27
+ "PT_TIME_ZONE",
28
+ "TIME_FORMAT_WITH_SECONDS",
29
+ "UTC_TIME_ZONE",
30
+ ]
@@ -1 +0,0 @@
1
- from bear_epoch_time.constants.date_related import DATE_FORMAT, DATE_TIME_FORMAT
@@ -1,13 +0,0 @@
1
- from bear_epoch_time import EpochTimestamp, TimerData, TimeTools, add_ord_suffix, create_timer, timer
2
- from bear_epoch_time.constants.date_related import DATE_FORMAT, DATE_TIME_FORMAT
3
-
4
- __all__ = [
5
- "EpochTimestamp",
6
- "TimerData",
7
- "create_timer",
8
- "timer",
9
- "TimeTools",
10
- "add_ord_suffix",
11
- "DATE_FORMAT",
12
- "DATE_TIME_FORMAT",
13
- ]