bear-utils 0.7.12__py3-none-any.whl → 0.7.14__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 CHANGED
@@ -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]:
@@ -1 +1,23 @@
1
- from bear_epoch_time.constants.date_related import DATE_FORMAT, DATE_TIME_FORMAT
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)
@@ -1,5 +1,15 @@
1
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
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
+ )
3
13
 
4
14
  __all__ = [
5
15
  "EpochTimestamp",
@@ -10,4 +20,11 @@ __all__ = [
10
20
  "add_ord_suffix",
11
21
  "DATE_FORMAT",
12
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",
13
30
  ]
@@ -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/__init__.py,sha256=Wv20pojGSsmvYwUJDinz8OltznbZuIV4PUQOYF7cdZA,612
1
+ bear_utils/__init__.py,sha256=rwxVGk0zD-vvQ_E1SFHSIX3nmz9potELv129Q7j8Tkw,670
2
2
  bear_utils/ai/__init__.py,sha256=g7DiwwqbcKAktcwqq6Xs3rSwFqvq4H1yrG2aHoc6FQo,766
3
3
  bear_utils/ai/ai_helpers/__init__.py,sha256=siujxR7b7mjsHM2J24V9NXM-edlgcuRZQpxegVU9-is,3968
4
4
  bear_utils/ai/ai_helpers/_common.py,sha256=KgaOb_IePfC8Z1VsdA0EiodfS_YGVYYnrZFR2ZdsUYM,418
@@ -11,7 +11,7 @@ bear_utils/cli/commands.py,sha256=B0eI6iPeE5uaEa7JvfwKZavHe4ZsK_fLFBWxojW1Cx8,15
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
13
  bear_utils/cli/shell/_base_command.py,sha256=96zlL6BFWVkC_pJzxlxQy1o3oxu-P4e80mRcLEvS0PY,2251
14
- bear_utils/cli/shell/_base_shell.py,sha256=8PEny2MciOig8r1gN5YHbk3j3L5fFE6mHh2v3XxLAXU,14596
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
17
17
  bear_utils/config/config_manager.py,sha256=WojWwxsTo2Izf2EFxZJXjjUmhqcbbatZ-nBKq436BGw,2631
@@ -20,7 +20,7 @@ bear_utils/config/settings_manager.py,sha256=1icasrvSmhgPS08fGFswYT7eHbbguqscFZg
20
20
  bear_utils/constants/__init__.py,sha256=exQ6tfE05Wi72i6PyZ71WXRs_b9RO4zbupPUyV6fHQg,545
21
21
  bear_utils/constants/_exceptions.py,sha256=KCd4iT7RxrS4DxU1vLrTiYP2U6pyEjnyP_AGXbEpwR0,137
22
22
  bear_utils/constants/_lazy_typing.py,sha256=WfuWpRqx9XchvuyPWg3tVjMC5-C4QA-Bhwfskf4YmAE,339
23
- bear_utils/constants/date_related.py,sha256=GabqI9xLBDiIEBZ7zJ3UNbsqOUOWZr3wJCPAqAuXZfk,81
23
+ bear_utils/constants/date_related.py,sha256=EpQEZxg8o9e4pkvbflfnSyYUzb-pQDhCxAJKWpiWuT8,508
24
24
  bear_utils/constants/time_related.py,sha256=q-0wi0qnC5qHq4vOXbMAETVA5lEc-c7STFqi3fTjuLs,638
25
25
  bear_utils/database/__init__.py,sha256=JkpeqL9F1Rhcj9CMhM6ZP72qq-nDKPzWAR2aeJyyiZg,111
26
26
  bear_utils/database/_db_manager.py,sha256=1EY8ueSf3US8yUhnMP5R96pHolOyy_3ufNi5fv5d-NM,3776
@@ -29,7 +29,7 @@ bear_utils/events/events_class.py,sha256=pEdZNS8l5wwrn3I4WrFspZlNiy3Lzcwjxr6E2hT
29
29
  bear_utils/events/events_module.py,sha256=NtWqlBpTWAtaC_KVJnweReQe6OU2PXt04yNtAEcATuc,1852
30
30
  bear_utils/extras/__init__.py,sha256=OzjuT-GSI6lT8lmOLBR4-ikA-QrpByy0YRlgiFd7cF4,547
31
31
  bear_utils/extras/_async_helpers.py,sha256=OcgPmCfdAKcTsqGA3Fm8ORkePgaJSok_1t9-sbf-zNQ,416
32
- bear_utils/extras/_tools.py,sha256=8l41jRIiyNTI9LmBC5MM-rx9nyx9wmmVwk_h980B388,6110
32
+ bear_utils/extras/_tools.py,sha256=PdOX9KCB5uGEGzJ7SA9qeBukxyYRo160ePqBZU8dJCw,7094
33
33
  bear_utils/extras/platform_utils.py,sha256=vRLybOm_Kk4ysVyNdsv1oTrMHD64vPeGre23fg-kJxI,1257
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
@@ -57,7 +57,7 @@ bear_utils/logging/__init__.py,sha256=o5MX0ow4ugo3JhS2k9vFO0HMzTwUBVnzdhoJBCmqW1
57
57
  bear_utils/logging/logger_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
58
  bear_utils/logging/logger_manager/_common.py,sha256=6r69PIqk6IaIauxax35c5Paz1J1iv87ukbvoZ3uWI_Q,1582
59
59
  bear_utils/logging/logger_manager/_console_junk.py,sha256=vMChuVTNxyxly-onEad1u2tsb6syalXjFVfxOS2-qHw,4821
60
- bear_utils/logging/logger_manager/_styles.py,sha256=MrtERJMZ2yFOlnm2dVYPT2gNvxYZ-Yk2NocGSkPeDx4,2551
60
+ bear_utils/logging/logger_manager/_styles.py,sha256=Q5Gwt7nmHZuanwpr3kJl7mfo_8jaElFKJgns1sq4IwE,2528
61
61
  bear_utils/logging/logger_manager/loggers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  bear_utils/logging/logger_manager/loggers/_base_logger.py,sha256=LnhPJuTChhgXsxrafJBE1w7aIntn5OW43ZOjFxwhysU,9453
63
63
  bear_utils/logging/logger_manager/loggers/_base_logger.pyi,sha256=fFjv7GHh9LAvBZDK5Bqth50wOheNwM_qt-sKowW8UWg,2606
@@ -72,7 +72,7 @@ bear_utils/logging/logger_manager/loggers/_sub_logger.pyi,sha256=-SCh73lTkqolDq-
72
72
  bear_utils/logging/loggers.py,sha256=oFdKrm9ot7F4pKghzYQrq-BK7RfevKQSBaHsmSolHTA,3196
73
73
  bear_utils/monitoring/__init__.py,sha256=cj7UYsipfYFwxQmXtMpziAv4suRtGzWEdjdwOCbxJN4,168
74
74
  bear_utils/monitoring/host_monitor.py,sha256=GwIK9X8rATUhYIbOXi4MINfACWgO3T1vzUK1gSK_TQc,12902
75
- bear_utils/time/__init__.py,sha256=MN_uAgNj29WEBQDSnwcASfVcsv4E_kNZU9RmuOPrtuE,352
76
- bear_utils-0.7.12.dist-info/METADATA,sha256=wrJ42KLfTbrkEwQyr5WVT8c-M6aEhKiNUNHrRHu1o7k,7494
77
- bear_utils-0.7.12.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
78
- bear_utils-0.7.12.dist-info/RECORD,,
75
+ bear_utils/time/__init__.py,sha256=EHzc9KiGG3l6mAPhiIeFcYqxQG_w0QQ1ES3yRFVr8ug,721
76
+ bear_utils-0.7.14.dist-info/METADATA,sha256=ZPN_uCXYTnpBMTDZKEC8xusGYMrKNDaN0UEJkZHlXB4,7494
77
+ bear_utils-0.7.14.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
78
+ bear_utils-0.7.14.dist-info/RECORD,,