bear-utils 0.7.14__tar.gz → 0.7.15__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 (93) hide show
  1. bear_utils-0.7.15/.bumpversion.cfg +8 -0
  2. bear_utils-0.7.15/.gitignore +165 -0
  3. bear_utils-0.7.15/.python-version +1 -0
  4. bear_utils-0.7.15/AGENTS.md +11 -0
  5. {bear_utils-0.7.14 → bear_utils-0.7.15}/PKG-INFO +17 -22
  6. {bear_utils-0.7.14 → bear_utils-0.7.15}/README.md +1 -1
  7. bear_utils-0.7.15/directory_structure.txt +118 -0
  8. bear_utils-0.7.15/maskfile.md +57 -0
  9. {bear_utils-0.7.14 → bear_utils-0.7.15}/pyproject.toml +3 -3
  10. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/cli/__init__.py +1 -1
  11. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/cli/commands.py +40 -0
  12. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/cli/shell/_base_command.py +5 -4
  13. bear_utils-0.7.15/test.py +24 -0
  14. bear_utils-0.7.15/tests/__init__.py +0 -0
  15. bear_utils-0.7.15/tests/test_add_ord_suffix.py +12 -0
  16. bear_utils-0.7.15/tests/test_clipboard.py +50 -0
  17. bear_utils-0.7.15/tests/test_default_shell.py +7 -0
  18. bear_utils-0.7.15/tests/test_gradient.py +49 -0
  19. bear_utils-0.7.15/tests/test_logger.py +306 -0
  20. bear_utils-0.7.15/tests/test_platform_utils.py +35 -0
  21. bear_utils-0.7.15/uv.lock +1053 -0
  22. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/__init__.py +0 -0
  23. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/ai/__init__.py +0 -0
  24. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/ai/ai_helpers/__init__.py +0 -0
  25. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/ai/ai_helpers/_common.py +0 -0
  26. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/ai/ai_helpers/_config.py +0 -0
  27. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/ai/ai_helpers/_parsers.py +0 -0
  28. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/ai/ai_helpers/_types.py +0 -0
  29. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/cache/__init__.py +0 -0
  30. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/cli/prompt_helpers.py +0 -0
  31. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/cli/shell/__init__.py +0 -0
  32. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/cli/shell/_base_shell.py +0 -0
  33. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/cli/shell/_common.py +0 -0
  34. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/config/__init__.py +0 -0
  35. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/config/config_manager.py +0 -0
  36. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/config/dir_manager.py +0 -0
  37. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/config/settings_manager.py +0 -0
  38. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/constants/__init__.py +0 -0
  39. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/constants/_exceptions.py +0 -0
  40. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/constants/_lazy_typing.py +0 -0
  41. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/constants/date_related.py +0 -0
  42. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/constants/time_related.py +0 -0
  43. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/database/__init__.py +0 -0
  44. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/database/_db_manager.py +0 -0
  45. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/events/__init__.py +0 -0
  46. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/events/events_class.py +0 -0
  47. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/events/events_module.py +0 -0
  48. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/extras/__init__.py +0 -0
  49. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/extras/_async_helpers.py +0 -0
  50. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/extras/_tools.py +0 -0
  51. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/extras/platform_utils.py +0 -0
  52. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/extras/wrappers/__init__.py +0 -0
  53. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/extras/wrappers/add_methods.py +0 -0
  54. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/__init__.py +0 -0
  55. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/file_handlers/__init__.py +0 -0
  56. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/file_handlers/_base_file_handler.py +0 -0
  57. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/file_handlers/file_handler_factory.py +0 -0
  58. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/file_handlers/json_file_handler.py +0 -0
  59. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/file_handlers/log_file_handler.py +0 -0
  60. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/file_handlers/txt_file_handler.py +0 -0
  61. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/file_handlers/yaml_file_handler.py +0 -0
  62. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/files/ignore_parser.py +0 -0
  63. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/graphics/__init__.py +0 -0
  64. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/graphics/bear_gradient.py +0 -0
  65. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/graphics/image_helpers.py +0 -0
  66. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/gui/__init__.py +0 -0
  67. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/gui/gui_tools/__init__.py +0 -0
  68. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/gui/gui_tools/_settings.py +0 -0
  69. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/gui/gui_tools/_types.py +0 -0
  70. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/gui/gui_tools/qt_app.py +0 -0
  71. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/gui/gui_tools/qt_color_picker.py +0 -0
  72. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/gui/gui_tools/qt_file_handler.py +0 -0
  73. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/gui/gui_tools/qt_input_dialog.py +0 -0
  74. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/__init__.py +0 -0
  75. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/__init__.py +0 -0
  76. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/_common.py +0 -0
  77. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/_console_junk.py +0 -0
  78. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/_styles.py +0 -0
  79. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/__init__.py +0 -0
  80. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_base_logger.py +0 -0
  81. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_base_logger.pyi +0 -0
  82. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_buffer_logger.py +0 -0
  83. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_console_logger.py +0 -0
  84. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_console_logger.pyi +0 -0
  85. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_file_logger.py +0 -0
  86. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_level_sin.py +0 -0
  87. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_logger.py +0 -0
  88. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_sub_logger.py +0 -0
  89. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/logger_manager/loggers/_sub_logger.pyi +0 -0
  90. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/logging/loggers.py +0 -0
  91. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/monitoring/__init__.py +0 -0
  92. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/monitoring/host_monitor.py +0 -0
  93. {bear_utils-0.7.14 → bear_utils-0.7.15}/src/bear_utils/time/__init__.py +0 -0
@@ -0,0 +1,8 @@
1
+ [bumpversion]
2
+ current_version = 0.7.15
3
+
4
+ [bumpversion:file:pyproject.toml]
5
+
6
+ [bumpversion:file:README.md]
7
+ search = # Bear Utils v{current_version}
8
+ replace = # Bear Utils v{new_version}
@@ -0,0 +1,165 @@
1
+ # ---- Python ----
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111
+ .pdm.toml
112
+ .pdm-python
113
+ .pdm-build/
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ #.idea/
164
+
165
+ **/.vscode
@@ -0,0 +1 @@
1
+ 3.13.3
@@ -0,0 +1,11 @@
1
+ # Contributor Guide for AI Agents
2
+
3
+ ## Dev Environment Guidelines
4
+
5
+ - Python Version and Typing: Assume Python 3.12 or higher is being used. Because of that we SHOULD use the latest typing features available in Python 3.12 and later. Never use `Optional`, `Union`, or `Dict, List, Tuple` from `typing` module. Instead, use the built-in types directly, e.g., `list`, `dict`, `tuple`, and use `|` for union types. This is not an exhaustive list, so be thoughtful about any potentially deprecated types you might use. If you are not sure about something, ask the user.
6
+ - Type Annotations: Use type annotations as often as possible. If a function has no return value, use `None` as the return type. If a function returns a value, use the appropriate type annotation but don't bend over backwards to make it perfect. If you are not sure about the type, use `Any` as a fallback but use this sparingly, see it as a failure and you should endeavor to avoid using `Any` as much as possible.
7
+ - Docstrings: Use docstrings for most (95%) public functions and classes. The docstring should describe the purpose of the function or class, its parameters, and its return value. Use the Google style for docstrings. Because of this it is highly preferred to not use comments in the code unless absolutely necessary. If you feel like you need to use a comment, consider if the code can be refactored to make it more readable instead.
8
+ - Imports: Use relative imports for everything (beyond the obvious imports for external packages) in this current package. Keep imports clean using `isort src tests` and `black src tests -l 120` to format the code in that order.
9
+ - Endeavor to use a TDD approach when writing new code. Write tests first, then write the code to make the tests pass and then refactor the code to make it cleaner and more readable.
10
+ - There is a `directory_structure.txt` file in the root of the repository that describes the directory structure of the project. Use this as a quick way to understand the project structure and where to place new files or modules.
11
+ - While projects might partially use Poetry, UV is generally the preferred tool for managing dependencies and virtual environments. It is taking me some time to get used to it, so please bear with me. If you are not sure about something, ask the user. If a dependency is not available, then you will need to request the user to add it to the `pyproject.toml` file.
@@ -1,29 +1,25 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: bear-utils
3
- Version: 0.7.14
3
+ Version: 0.7.15
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
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.12
10
- Classifier: Programming Language :: Python :: 3.13
11
- Requires-Dist: bear-epoch-time (>=1.0.1)
12
- Requires-Dist: diskcache (>=5.6.3,<6.0.0)
13
- Requires-Dist: httpx (>=0.28.1)
14
- Requires-Dist: pathspec (>=0.12.1)
15
- Requires-Dist: pillow (>=11.2.1,<12.0.0)
16
- Requires-Dist: prompt-toolkit (>=3.0.51,<4.0.0)
17
- Requires-Dist: pydantic (>=2.11.5)
18
- Requires-Dist: pyglm (>=2.8.2,<3.0.0)
19
- Requires-Dist: pyqt6 (>=6.9.0)
20
- Requires-Dist: pyyaml (>=6.0.2)
21
- Requires-Dist: rich (>=14.0.0,<15.0.0)
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
24
20
  Description-Content-Type: text/markdown
25
21
 
26
- # Bear Utils v# Bear Utils v0.7.14
22
+ # Bear Utils v# Bear Utils v0.7.15
27
23
 
28
24
  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
25
 
@@ -257,4 +253,3 @@ def handle_function(func):
257
253
  # Handle sync function
258
254
  pass
259
255
  ```
260
-
@@ -1,4 +1,4 @@
1
- # Bear Utils v# Bear Utils v0.7.14
1
+ # Bear Utils v# Bear Utils v0.7.15
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
 
@@ -0,0 +1,118 @@
1
+ 📁 bear-utils
2
+ ├── ⚙️ .bumpversion.cfg (312 bytes) (12 lines)
3
+ ├── 🗃️ .gitignore (3170 bytes) (165 lines)
4
+ ├── 🐍 .python-version (7 bytes) (1 lines)
5
+ ├── 📄 AGENTS.md (2953 bytes) (12 lines)
6
+ ├── 📄 directory_structure.txt (7154 bytes) (118 lines)
7
+ ├── 📄 pyproject.toml (970 bytes) (41 lines)
8
+ ├── 📄 README.md (5267 bytes) (208 lines)
9
+ ├── 📁 src
10
+ │ └── 📁 bear_utils
11
+ │ ├── 🐍 __init__.py (616 bytes) (13 lines)
12
+ │ ├── 📁 ai
13
+ │ │ ├── 🐍 __init__.py (26 bytes) (1 lines)
14
+ │ │ └── 📁 ai_helpers
15
+ │ │ ├── 🐍 __init__.py (3968 bytes) (130 lines)
16
+ │ │ ├── 🐍 _common.py (418 bytes) (19 lines)
17
+ │ │ ├── 🐍 _config.py (789 bytes) (25 lines)
18
+ │ │ ├── 🐍 _parsers.py (7993 bytes) (188 lines)
19
+ │ │ └── 🐍 _types.py (550 bytes) (20 lines)
20
+ │ ├── 📁 cache
21
+ │ │ └── 🐍 __init__.py (4101 bytes) (119 lines)
22
+ │ ├── 📁 cli
23
+ │ │ ├── 🐍 __init__.py (241 bytes) (4 lines)
24
+ │ │ ├── 🐍 commands.py (1768 bytes) (65 lines)
25
+ │ │ ├── 🐍 prompt_helpers.py (6094 bytes) (166 lines)
26
+ │ │ └── 📁 shell
27
+ │ │ ├── 🐍 __init__.py (0 bytes) (0 lines)
28
+ │ │ ├── 🐍 _base_command.py (2251 bytes) (74 lines)
29
+ │ │ ├── 🐍 _base_shell.py (14596 bytes) (390 lines)
30
+ │ │ └── 🐍 _common.py (669 bytes) (19 lines)
31
+ │ ├── 📁 config
32
+ │ │ ├── 🐍 __init__.py (289 bytes) (11 lines)
33
+ │ │ ├── 🐍 config_manager.py (2631 bytes) (92 lines)
34
+ │ │ ├── 🐍 dir_manager.py (1865 bytes) (64 lines)
35
+ │ │ └── 🐍 settings_manager.py (7484 bytes) (232 lines)
36
+ │ ├── 📁 constants
37
+ │ │ ├── 🐍 __init__.py (545 bytes) (16 lines)
38
+ │ │ ├── 🐍 _exceptions.py (137 bytes) (3 lines)
39
+ │ │ ├── 🐍 _lazy_typing.py (339 bytes) (15 lines)
40
+ │ │ ├── 🐍 date_related.py (935 bytes) (27 lines)
41
+ │ │ └── 🐍 time_related.py (638 bytes) (22 lines)
42
+ │ ├── 🛢️ database
43
+ │ │ ├── 🐍 __init__.py (111 bytes) (6 lines)
44
+ │ │ └── 🐍 _db_manager.py (3782 bytes) (104 lines)
45
+ │ ├── 📁 events
46
+ │ │ ├── 🐍 __init__.py (364 bytes) (16 lines)
47
+ │ │ ├── 🐍 events_class.py (1657 bytes) (52 lines)
48
+ │ │ └── 🐍 events_module.py (1852 bytes) (65 lines)
49
+ │ ├── 📁 extras
50
+ │ │ ├── 🐍 __init__.py (484 bytes) (17 lines)
51
+ │ │ ├── 🐍 _async_helpers.py (416 bytes) (15 lines)
52
+ │ │ ├── 🐍 _tools.py (5959 bytes) (174 lines)
53
+ │ │ ├── 🐍 platform_utils.py (1257 bytes) (53 lines)
54
+ │ │ └── 📁 wrappers
55
+ │ │ ├── 🐍 __init__.py (0 bytes) (0 lines)
56
+ │ │ └── 🐍 add_methods.py (4222 bytes) (98 lines)
57
+ │ ├── 📁 files
58
+ │ │ ├── 🐍 __init__.py (142 bytes) (4 lines)
59
+ │ │ ├── 🐍 ignore_parser.py (10678 bytes) (298 lines)
60
+ │ │ └── 📁 file_handlers
61
+ │ │ ├── 🐍 __init__.py (87 bytes) (3 lines)
62
+ │ │ ├── 🐍 _base_file_handler.py (3164 bytes) (93 lines)
63
+ │ │ ├── 🐍 file_handler_factory.py (9746 bytes) (278 lines)
64
+ │ │ ├── 🐍 json_file_handler.py (1482 bytes) (44 lines)
65
+ │ │ ├── 🐍 log_file_handler.py (1246 bytes) (33 lines)
66
+ │ │ ├── 🐍 txt_file_handler.py (1250 bytes) (34 lines)
67
+ │ │ └── 🐍 yaml_file_handler.py (2083 bytes) (57 lines)
68
+ │ ├── 📁 graphics
69
+ │ │ ├── 🐍 __init__.py (186 bytes) (4 lines)
70
+ │ │ ├── 🐍 bear_gradient.py (4769 bytes) (140 lines)
71
+ │ │ └── 🐍 image_helpers.py (1374 bytes) (39 lines)
72
+ │ ├── 📁 gui
73
+ │ │ ├── 🐍 __init__.py (118 bytes) (3 lines)
74
+ │ │ └── 📁 gui_tools
75
+ │ │ ├── 🐍 __init__.py (171 bytes) (5 lines)
76
+ │ │ ├── 🐍 _settings.py (1202 bytes) (37 lines)
77
+ │ │ ├── 🐍 _types.py (248 bytes) (12 lines)
78
+ │ │ ├── 🐍 qt_app.py (5520 bytes) (145 lines)
79
+ │ │ ├── 🐍 qt_color_picker.py (4437 bytes) (119 lines)
80
+ │ │ ├── 🐍 qt_file_handler.py (4325 bytes) (138 lines)
81
+ │ │ └── 🐍 qt_input_dialog.py (9224 bytes) (306 lines)
82
+ │ ├── 📁 logging
83
+ │ │ ├── 🐍 __init__.py (319 bytes) (12 lines)
84
+ │ │ ├── 🐍 loggers.py (4507 bytes) (91 lines)
85
+ │ │ └── 📁 logger_manager
86
+ │ │ ├── 🐍 __init__.py (0 bytes) (0 lines)
87
+ │ │ ├── 🐍 _common.py (1582 bytes) (47 lines)
88
+ │ │ ├── 🐍 _console_junk.py (4821 bytes) (131 lines)
89
+ │ │ ├── 🐍 _styles.py (2536 bytes) (91 lines)
90
+ │ │ └── 📁 loggers
91
+ │ │ ├── 🐍 __init__.py (0 bytes) (0 lines)
92
+ │ │ ├── 🐍 _base_logger.py (9453 bytes) (238 lines)
93
+ │ │ ├── 📄 _base_logger.pyi (2606 bytes) (50 lines)
94
+ │ │ ├── 🐍 _console_logger.py (9126 bytes) (243 lines)
95
+ │ │ ├── 📄 _console_logger.pyi (1470 bytes) (41 lines)
96
+ │ │ ├── 🐍 _file_logger.py (5365 bytes) (150 lines)
97
+ │ │ ├── 🐍 _level_sin.py (1712 bytes) (58 lines)
98
+ │ │ ├── 🐍 _logger.py (547 bytes) (18 lines)
99
+ │ │ ├── 🐍 _sub_logger.py (3471 bytes) (110 lines)
100
+ │ │ └── 📄 _sub_logger.pyi (1520 bytes) (38 lines)
101
+ │ ├── 📁 monitoring
102
+ │ │ ├── 🐍 __init__.py (168 bytes) (10 lines)
103
+ │ │ └── 🐍 host_monitor.py (12902 bytes) (350 lines)
104
+ │ └── 📁 time
105
+ │ ├── 🐍 __init__.py (398 bytes) (16 lines)
106
+ │ ├── 🐍 _helpers.py (2824 bytes) (91 lines)
107
+ │ ├── 🐍 _time_class.py (11425 bytes) (316 lines)
108
+ │ ├── 🐍 _timer.py (2463 bytes) (80 lines)
109
+ │ ├── 🐍 _tools.py (456 bytes) (17 lines)
110
+ │ └── 🐍 time_manager.py (7731 bytes) (218 lines)
111
+ └── 📁 tests
112
+ ├── 🐍 __init__.py (0 bytes) (0 lines)
113
+ ├── 🐍 test_add_ord_suffix.py (329 bytes) (12 lines)
114
+ ├── 🐍 test_clipboard.py (1799 bytes) (50 lines)
115
+ ├── 🐍 test_default_shell.py (154 bytes) (7 lines)
116
+ ├── 🐍 test_logger.py (8513 bytes) (227 lines)
117
+ ├── 🐍 test_platform_utils.py (922 bytes) (35 lines)
118
+ └── 🐍 test_time_parsing.py (414 bytes) (13 lines)
@@ -0,0 +1,57 @@
1
+ # Singleton Mask File
2
+
3
+ ## clean
4
+
5
+ > This command cleans the build artifacts
6
+
7
+ ```bash
8
+ rm -rf dist/
9
+ ```
10
+
11
+ ## bump (patch_version)
12
+
13
+ > Bump the version of the local project specifying the patch level: `minor`, `major`, `patch`
14
+
15
+ ```bash
16
+ bump2version ${patch_version} --allow-dirty
17
+ ```
18
+
19
+ ## build
20
+
21
+ > This command builds the project via uv
22
+
23
+ ```bash
24
+ uv build
25
+ ```
26
+
27
+ ## test
28
+
29
+ > This command runs the tests using pytest
30
+
31
+ ```bash
32
+ pytest -s
33
+ ```
34
+
35
+ ## publish (publish_location)
36
+
37
+ > This command publishes the package to PyPI (or locally) officially, isn't that great?
38
+
39
+ ```bash
40
+ if [ "${publish_location}" = "local" ]; then
41
+ twine upload -r local dist/* # uploads to a local repository
42
+ else
43
+ export UV_PUBLISH_TOKEN=$(op read "op://Private/PyPI Prod/api_key")
44
+ uv publish --index pypi dist/* --token $UV_PUBLISH_TOKEN
45
+ fi
46
+ ```
47
+
48
+ ## full (patch_version) (publish_location)
49
+
50
+ > This command runs the full build and publish process
51
+
52
+ ```bash
53
+ $MASK clean
54
+ $MASK bump ${patch_version}
55
+ $MASK build
56
+ $MASK publish ${publish_location}
57
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bear-utils"
3
- version = "0.7.14"
3
+ version = "0.7.15"
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"
@@ -22,8 +22,8 @@ dependencies = [
22
22
  ]
23
23
 
24
24
  [build-system]
25
- requires = ["poetry-core>=2.0.0,<3.0.0"]
26
- build-backend = "poetry.core.masonry.api"
25
+ requires = ["hatchling"]
26
+ build-backend = "hatchling.build"
27
27
 
28
28
  [dependency-groups]
29
29
  dev = [
@@ -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
@@ -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(str(self))
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:
@@ -0,0 +1,24 @@
1
+ from bear_utils.extras._tools import copy_to_clipboard_async
2
+
3
+
4
+ async def copy(output: str) -> int:
5
+ """
6
+ Asynchronously copy the output to the clipboard.
7
+
8
+ Args:
9
+ output (str): The output to copy to the clipboard.
10
+
11
+ Returns:
12
+ int: The return code of the command.
13
+ """
14
+ return await copy_to_clipboard_async(output)
15
+
16
+
17
+ if __name__ == "__main__":
18
+ import asyncio
19
+
20
+ async def main():
21
+ result = await copy("Hello, World!")
22
+ print(f"Copy result: {result}")
23
+
24
+ asyncio.run(main())
File without changes
@@ -0,0 +1,12 @@
1
+ import importlib
2
+
3
+
4
+ def test_add_ord_suffix_import():
5
+ module = importlib.import_module("src.bear_utils.time")
6
+ assert hasattr(module, "add_ord_suffix")
7
+ func = module.add_ord_suffix
8
+ assert callable(func)
9
+ assert func(1) == "1st"
10
+ assert func(2) == "2nd"
11
+ assert func(3) == "3rd"
12
+ assert func(4) == "4th"
@@ -0,0 +1,50 @@
1
+ from unittest.mock import patch
2
+
3
+ import pytest
4
+
5
+ from src.bear_utils.extras._tools import ClipboardManager
6
+ from bear_utils.extras.platform_utils import OS
7
+
8
+
9
+ @patch("src.bear_utils.extras._tools.get_platform", return_value=OS.DARWIN)
10
+ def test_macos_commands(mock_platform):
11
+ manager = ClipboardManager()
12
+ assert manager._copy.cmd == "pbcopy"
13
+ assert manager._paste.cmd == "pbpaste"
14
+
15
+
16
+ @patch("src.bear_utils.extras._tools.shutil.which")
17
+ @patch("src.bear_utils.extras._tools.get_platform", return_value=OS.LINUX)
18
+ def test_linux_wayland(mock_platform, mock_which):
19
+ mock_which.side_effect = lambda name: f"/usr/bin/{name}" if name in {"wl-copy", "wl-paste"} else None
20
+ manager = ClipboardManager()
21
+ assert manager._copy.cmd == "wl-copy"
22
+ assert manager._paste.cmd == "wl-paste"
23
+
24
+
25
+ @patch("src.bear_utils.extras._tools.shutil.which")
26
+ @patch("src.bear_utils.extras._tools.get_platform", return_value=OS.LINUX)
27
+ def test_linux_xclip(mock_platform, mock_which):
28
+ def which(name: str):
29
+ if name == "xclip":
30
+ return "/usr/bin/xclip"
31
+ return None
32
+
33
+ mock_which.side_effect = which
34
+ manager = ClipboardManager()
35
+ assert manager._copy.cmd == "xclip -selection clipboard"
36
+ assert manager._paste.cmd == "xclip -selection clipboard -o"
37
+
38
+
39
+ @patch("src.bear_utils.extras._tools.shutil.which", return_value=None)
40
+ @patch("src.bear_utils.extras._tools.get_platform", return_value=OS.LINUX)
41
+ def test_linux_no_clipboard(mock_platform, mock_which):
42
+ with pytest.raises(RuntimeError):
43
+ ClipboardManager()
44
+
45
+
46
+ @patch("src.bear_utils.extras._tools.get_platform", return_value=OS.WINDOWS)
47
+ def test_windows_commands(mock_platform):
48
+ manager = ClipboardManager()
49
+ assert manager._copy.cmd == "clip"
50
+ assert manager._paste.cmd == "powershell Get-Clipboard"
@@ -0,0 +1,7 @@
1
+ from pathlib import Path
2
+
3
+ from src.bear_utils.cli import DEFAULT_SHELL
4
+
5
+
6
+ def test_default_shell_exists() -> None:
7
+ assert Path(DEFAULT_SHELL).exists()
@@ -0,0 +1,49 @@
1
+ import pytest
2
+
3
+
4
+ @pytest.mark.visual
5
+ def test_gradients_visual():
6
+
7
+ from rich.color_triplet import ColorTriplet
8
+ from rich.console import Console
9
+
10
+ from src.bear_utils.graphics import ColorGradient
11
+
12
+ console = Console()
13
+
14
+ # Health meter goes from red (low health) to green (full health)
15
+ health_gradient = ColorGradient()
16
+
17
+ console.print("🏥 [bold]Health Meter Demonstration[/bold] 🏥\n")
18
+
19
+ # Normal health: Red (low) -> Green (high)
20
+ console.print("[bold green]Normal Health Levels (0% = Critical, 100% = Perfect):[/bold green]")
21
+ for health in range(0, 101, 10):
22
+ color: ColorTriplet = health_gradient.map_to_color(0, 100, health)
23
+ health_bar = "█" * (health // 5)
24
+ console.print(f"HP: {health:3d}/100 {health_bar:<20}", style=color.rgb)
25
+
26
+ console.print("\n" + "=" * 50 + "\n")
27
+
28
+ # Reversed: Infection/Damage meter (Green = good, Red = bad)
29
+ console.print("[bold red]Infection Level (0% = Healthy, 100% = Critical):[/bold red]")
30
+ health_gradient.reverse = True
31
+ for infection in range(0, 101, 10):
32
+ color: ColorTriplet = health_gradient.map_to_color(0, 100, infection)
33
+ infection_bar = "█" * (infection // 5)
34
+ status = "🦠" if infection > 70 else "⚠️" if infection > 30 else "✅"
35
+ console.print(f"Infection: {infection:3d}% {infection_bar:<20} {status}", style=color.rgb)
36
+
37
+ health_scenarios = [
38
+ (5, "💀 Nearly Dead"),
39
+ (25, "🩸 Critical Condition"),
40
+ (50, "⚠️ Wounded"),
41
+ (75, "😐 Recovering"),
42
+ (95, "💪 Almost Full Health"),
43
+ (100, "✨ Perfect Health"),
44
+ ]
45
+
46
+ console.print("[bold green]Health Status Examples:[/bold green]")
47
+ for hp, status in health_scenarios:
48
+ color: ColorTriplet = health_gradient.map_to_color(0, 100, hp)
49
+ console.print(f"{status}: {hp}/100 HP", style=color.rgb)