qlogicae-cor 1.0.0__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.
- qlogicae_cor-1.0.0/.gitignore +220 -0
- qlogicae_cor-1.0.0/LICENSE +21 -0
- qlogicae_cor-1.0.0/PKG-INFO +29 -0
- qlogicae_cor-1.0.0/README.md +17 -0
- qlogicae_cor-1.0.0/library/__init__.py +0 -0
- qlogicae_cor-1.0.0/library/abstract_manager.py +81 -0
- qlogicae_cor-1.0.0/library/abstract_manager_configurations.py +97 -0
- qlogicae_cor-1.0.0/library/error_manager.py +107 -0
- qlogicae_cor-1.0.0/library/error_manager_configurations.py +137 -0
- qlogicae_cor-1.0.0/library/singleton_manager.py +107 -0
- qlogicae_cor-1.0.0/library/singleton_manager_configurations.py +10 -0
- qlogicae_cor-1.0.0/project/asset/qlogicae1.png +0 -0
- qlogicae_cor-1.0.0/pyproject.toml +103 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
*.lcov
|
|
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
|
+
# UV
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
# poetry.lock
|
|
110
|
+
# poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
# pdm.lock
|
|
117
|
+
# pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
# pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi/*
|
|
127
|
+
!.pixi/config.toml
|
|
128
|
+
|
|
129
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
130
|
+
__pypackages__/
|
|
131
|
+
|
|
132
|
+
# Celery stuff
|
|
133
|
+
celerybeat-schedule*
|
|
134
|
+
celerybeat.pid
|
|
135
|
+
|
|
136
|
+
# Redis
|
|
137
|
+
*.rdb
|
|
138
|
+
*.aof
|
|
139
|
+
*.pid
|
|
140
|
+
|
|
141
|
+
# RabbitMQ
|
|
142
|
+
mnesia/
|
|
143
|
+
rabbitmq/
|
|
144
|
+
rabbitmq-data/
|
|
145
|
+
|
|
146
|
+
# ActiveMQ
|
|
147
|
+
activemq-data/
|
|
148
|
+
|
|
149
|
+
# SageMath parsed files
|
|
150
|
+
*.sage.py
|
|
151
|
+
|
|
152
|
+
# Environments
|
|
153
|
+
.env
|
|
154
|
+
.envrc
|
|
155
|
+
.venv
|
|
156
|
+
env/
|
|
157
|
+
venv/
|
|
158
|
+
ENV/
|
|
159
|
+
env.bak/
|
|
160
|
+
venv.bak/
|
|
161
|
+
|
|
162
|
+
# Spyder project settings
|
|
163
|
+
.spyderproject
|
|
164
|
+
.spyproject
|
|
165
|
+
|
|
166
|
+
# Rope project settings
|
|
167
|
+
.ropeproject
|
|
168
|
+
|
|
169
|
+
# mkdocs documentation
|
|
170
|
+
/site
|
|
171
|
+
|
|
172
|
+
# mypy
|
|
173
|
+
.mypy_cache/
|
|
174
|
+
.dmypy.json
|
|
175
|
+
dmypy.json
|
|
176
|
+
|
|
177
|
+
# Pyre type checker
|
|
178
|
+
.pyre/
|
|
179
|
+
|
|
180
|
+
# pytype static type analyzer
|
|
181
|
+
.pytype/
|
|
182
|
+
|
|
183
|
+
# Cython debug symbols
|
|
184
|
+
cython_debug/
|
|
185
|
+
|
|
186
|
+
# PyCharm
|
|
187
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
188
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
189
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
190
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
191
|
+
# .idea/
|
|
192
|
+
|
|
193
|
+
# Abstra
|
|
194
|
+
# Abstra is an AI-powered process automation framework.
|
|
195
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
196
|
+
# Learn more at https://abstra.io/docs
|
|
197
|
+
.abstra/
|
|
198
|
+
|
|
199
|
+
# Visual Studio Code
|
|
200
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
201
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
202
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
203
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
204
|
+
# .vscode/
|
|
205
|
+
# Temporary file for partial code execution
|
|
206
|
+
tempCodeRunnerFile.py
|
|
207
|
+
|
|
208
|
+
# Ruff stuff:
|
|
209
|
+
.ruff_cache/
|
|
210
|
+
|
|
211
|
+
# PyPI configuration file
|
|
212
|
+
.pypirc
|
|
213
|
+
|
|
214
|
+
# Marimo
|
|
215
|
+
marimo/_static/
|
|
216
|
+
marimo/_lsp/
|
|
217
|
+
__marimo__/
|
|
218
|
+
|
|
219
|
+
# Streamlit
|
|
220
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vaughn Cedric L. Araneta
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qlogicae-cor
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The core library for QLogicae projects
|
|
5
|
+
Author-email: "Vaughn Cedric L. Araneta" <vaughncedriclipardoaraneta@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.14
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
</br>
|
|
14
|
+
|
|
15
|
+
<div style="width: 100%; display: flex; justify-content: center;">
|
|
16
|
+
<image alt="The QLogicae Logo" src="./project/asset/qlogicae1.png" width="256px">
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
</br>
|
|
20
|
+
|
|
21
|
+
<div style="text-align: center;">
|
|
22
|
+
<h1>QLogicae Cor</h1>
|
|
23
|
+
<p style="font-style: italic;">Python</p>
|
|
24
|
+
<div style="margin: 32px 64px;">
|
|
25
|
+
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
</br>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
</br>
|
|
2
|
+
|
|
3
|
+
<div style="width: 100%; display: flex; justify-content: center;">
|
|
4
|
+
<image alt="The QLogicae Logo" src="./project/asset/qlogicae1.png" width="256px">
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
</br>
|
|
8
|
+
|
|
9
|
+
<div style="text-align: center;">
|
|
10
|
+
<h1>QLogicae Cor</h1>
|
|
11
|
+
<p style="font-style: italic;">Python</p>
|
|
12
|
+
<div style="margin: 32px 64px;">
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
</br>
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from library.abstract_manager_configurations import (
|
|
4
|
+
AbstractManagerConfigurations,
|
|
5
|
+
)
|
|
6
|
+
from library.error_manager import ErrorManager
|
|
7
|
+
from library.singleton_manager import SingletonManager
|
|
8
|
+
|
|
9
|
+
Configurations = TypeVar(
|
|
10
|
+
"Configurations",
|
|
11
|
+
bound=AbstractManagerConfigurations,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AbstractManager[Configurations: AbstractManagerConfigurations]:
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
new_configurations: Configurations,
|
|
19
|
+
) -> None:
|
|
20
|
+
self.configurations = new_configurations
|
|
21
|
+
|
|
22
|
+
def setup(
|
|
23
|
+
self,
|
|
24
|
+
new_configurations: Configurations,
|
|
25
|
+
) -> bool:
|
|
26
|
+
try:
|
|
27
|
+
if self.configurations.is_disabled_for_handling(
|
|
28
|
+
new_configurations is None,
|
|
29
|
+
):
|
|
30
|
+
return False
|
|
31
|
+
|
|
32
|
+
self.configurations = new_configurations
|
|
33
|
+
|
|
34
|
+
return True
|
|
35
|
+
|
|
36
|
+
except Exception as exception:
|
|
37
|
+
self.handle_error_outputs(exception)
|
|
38
|
+
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
def reset(
|
|
42
|
+
self,
|
|
43
|
+
) -> bool:
|
|
44
|
+
try:
|
|
45
|
+
if self.configurations.is_disabled_for_handling():
|
|
46
|
+
return False
|
|
47
|
+
|
|
48
|
+
self.configurations = type(
|
|
49
|
+
self.configurations,
|
|
50
|
+
)()
|
|
51
|
+
|
|
52
|
+
return True
|
|
53
|
+
|
|
54
|
+
except Exception as exception:
|
|
55
|
+
self.handle_error_outputs(exception)
|
|
56
|
+
|
|
57
|
+
return False
|
|
58
|
+
|
|
59
|
+
def handle_error_outputs(
|
|
60
|
+
self,
|
|
61
|
+
error: str | Exception,
|
|
62
|
+
message: str | None = None,
|
|
63
|
+
) -> bool:
|
|
64
|
+
error_manager = SingletonManager.get_singleton(
|
|
65
|
+
ErrorManager,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if isinstance(error, Exception):
|
|
69
|
+
return error_manager.handle_error_outputs(
|
|
70
|
+
error,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
if message is not None:
|
|
74
|
+
return error_manager.handle_error_outputs(
|
|
75
|
+
error,
|
|
76
|
+
message,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return error_manager.handle_error_outputs(
|
|
80
|
+
error,
|
|
81
|
+
)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
class AbstractManagerConfigurations:
|
|
2
|
+
def __init__(self) -> None:
|
|
3
|
+
self._is_override_enabled: bool = False
|
|
4
|
+
self._is_enabled: bool = True
|
|
5
|
+
self._is_runtime_execution_handling_enabled: bool = True
|
|
6
|
+
self._is_edge_case_handling_enabled: bool = True
|
|
7
|
+
self._is_error_handling_enabled: bool = True
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def is_override_enabled(self) -> bool:
|
|
11
|
+
return self._is_override_enabled
|
|
12
|
+
|
|
13
|
+
@is_override_enabled.setter
|
|
14
|
+
def is_override_enabled(
|
|
15
|
+
self,
|
|
16
|
+
value: bool,
|
|
17
|
+
) -> None:
|
|
18
|
+
self._is_override_enabled = value
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def is_enabled(self) -> bool:
|
|
22
|
+
return self._is_enabled
|
|
23
|
+
|
|
24
|
+
@is_enabled.setter
|
|
25
|
+
def is_enabled(
|
|
26
|
+
self,
|
|
27
|
+
value: bool,
|
|
28
|
+
) -> None:
|
|
29
|
+
self._is_enabled = value
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def is_runtime_execution_handling_enabled(self) -> bool:
|
|
33
|
+
return self._is_runtime_execution_handling_enabled
|
|
34
|
+
|
|
35
|
+
@is_runtime_execution_handling_enabled.setter
|
|
36
|
+
def is_runtime_execution_handling_enabled(
|
|
37
|
+
self,
|
|
38
|
+
value: bool,
|
|
39
|
+
) -> None:
|
|
40
|
+
self._is_runtime_execution_handling_enabled = value
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def is_edge_case_handling_enabled(self) -> bool:
|
|
44
|
+
return self._is_edge_case_handling_enabled
|
|
45
|
+
|
|
46
|
+
@is_edge_case_handling_enabled.setter
|
|
47
|
+
def is_edge_case_handling_enabled(
|
|
48
|
+
self,
|
|
49
|
+
value: bool,
|
|
50
|
+
) -> None:
|
|
51
|
+
self._is_edge_case_handling_enabled = value
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def is_error_handling_enabled(self) -> bool:
|
|
55
|
+
return self._is_error_handling_enabled
|
|
56
|
+
|
|
57
|
+
@is_error_handling_enabled.setter
|
|
58
|
+
def is_error_handling_enabled(
|
|
59
|
+
self,
|
|
60
|
+
value: bool,
|
|
61
|
+
) -> None:
|
|
62
|
+
self._is_error_handling_enabled = value
|
|
63
|
+
|
|
64
|
+
def is_disabled_for_handling(
|
|
65
|
+
self,
|
|
66
|
+
conditions: bool = False,
|
|
67
|
+
) -> bool:
|
|
68
|
+
return not self.is_enabled_for_runtime_execution_handling() or (
|
|
69
|
+
self.is_enabled_for_edge_case_handling() and conditions
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
def is_enabled_for_runtime_execution_handling(
|
|
73
|
+
self,
|
|
74
|
+
) -> bool:
|
|
75
|
+
return (
|
|
76
|
+
self.is_enabled
|
|
77
|
+
if self.is_override_enabled
|
|
78
|
+
else self.is_runtime_execution_handling_enabled
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def is_enabled_for_edge_case_handling(
|
|
82
|
+
self,
|
|
83
|
+
) -> bool:
|
|
84
|
+
return (
|
|
85
|
+
self.is_enabled
|
|
86
|
+
if self.is_override_enabled
|
|
87
|
+
else self.is_edge_case_handling_enabled
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def is_enabled_for_error_handling(
|
|
91
|
+
self,
|
|
92
|
+
) -> bool:
|
|
93
|
+
return (
|
|
94
|
+
self.is_enabled
|
|
95
|
+
if self.is_override_enabled
|
|
96
|
+
else self.is_error_handling_enabled
|
|
97
|
+
)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
from library.error_manager_configurations import (
|
|
2
|
+
ErrorManagerConfigurations,
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ErrorManager:
|
|
7
|
+
def __init__(self) -> None:
|
|
8
|
+
self._configurations = ErrorManagerConfigurations()
|
|
9
|
+
|
|
10
|
+
def setup(
|
|
11
|
+
self,
|
|
12
|
+
new_configurations: ErrorManagerConfigurations,
|
|
13
|
+
) -> bool:
|
|
14
|
+
try:
|
|
15
|
+
if self._configurations.is_disabled_for_handling(
|
|
16
|
+
new_configurations is None,
|
|
17
|
+
):
|
|
18
|
+
return False
|
|
19
|
+
|
|
20
|
+
self._configurations = new_configurations
|
|
21
|
+
|
|
22
|
+
return True
|
|
23
|
+
|
|
24
|
+
except Exception as exception:
|
|
25
|
+
self.handle_error_outputs(exception)
|
|
26
|
+
|
|
27
|
+
return False
|
|
28
|
+
|
|
29
|
+
def reset(
|
|
30
|
+
self,
|
|
31
|
+
) -> bool:
|
|
32
|
+
try:
|
|
33
|
+
if self._configurations.is_disabled_for_handling():
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
self._configurations = ErrorManagerConfigurations()
|
|
37
|
+
|
|
38
|
+
return True
|
|
39
|
+
|
|
40
|
+
except Exception as exception:
|
|
41
|
+
self.handle_error_outputs(exception)
|
|
42
|
+
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
def transform_to_error_log(
|
|
46
|
+
self,
|
|
47
|
+
value1: str | Exception,
|
|
48
|
+
value2: str | None = None,
|
|
49
|
+
) -> str:
|
|
50
|
+
if isinstance(value1, Exception):
|
|
51
|
+
return (
|
|
52
|
+
f"{type(value1).__name__}"
|
|
53
|
+
f"{self._configurations.title_message_separator}"
|
|
54
|
+
f"{value1}"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if value2 is not None:
|
|
58
|
+
return f"{value1}{self._configurations.title_message_separator}{value2}"
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
f"{self._configurations.title}"
|
|
62
|
+
f"{self._configurations.title_message_separator}"
|
|
63
|
+
f"{value1}"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def handle_error_outputs(
|
|
67
|
+
self,
|
|
68
|
+
error: str | Exception,
|
|
69
|
+
message: str | None = None,
|
|
70
|
+
) -> bool:
|
|
71
|
+
if isinstance(error, Exception):
|
|
72
|
+
self.handle_error_output_conditions(
|
|
73
|
+
self.transform_to_error_log(error),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
return True
|
|
77
|
+
|
|
78
|
+
if message is not None:
|
|
79
|
+
self.handle_error_output_conditions(
|
|
80
|
+
self.transform_to_error_log(
|
|
81
|
+
error,
|
|
82
|
+
message,
|
|
83
|
+
),
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
return True
|
|
87
|
+
|
|
88
|
+
self.handle_error_output_conditions(
|
|
89
|
+
self.transform_to_error_log(error),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return True
|
|
93
|
+
|
|
94
|
+
def handle_error_output_conditions(
|
|
95
|
+
self,
|
|
96
|
+
error_log: str,
|
|
97
|
+
) -> bool:
|
|
98
|
+
if not self._configurations.is_enabled_for_runtime_execution_handling():
|
|
99
|
+
return False
|
|
100
|
+
|
|
101
|
+
if self._configurations.is_enabled_for_console_output():
|
|
102
|
+
print(error_log)
|
|
103
|
+
|
|
104
|
+
if self._configurations.is_enabled_for_runtime_throw_output():
|
|
105
|
+
raise RuntimeError(error_log)
|
|
106
|
+
|
|
107
|
+
return True
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
from library.abstract_manager_configurations import (
|
|
2
|
+
AbstractManagerConfigurations,
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ErrorManagerConfigurations(
|
|
7
|
+
AbstractManagerConfigurations,
|
|
8
|
+
):
|
|
9
|
+
def __init__(self) -> None:
|
|
10
|
+
super().__init__()
|
|
11
|
+
|
|
12
|
+
self._is_output_enabled: bool = True
|
|
13
|
+
self._is_output_override_enabled: bool = False
|
|
14
|
+
self._is_asynchronous_output_enabled: bool = True
|
|
15
|
+
self._is_asynchronous_output_override_enabled: bool = False
|
|
16
|
+
self._is_console_output_enabled: bool = True
|
|
17
|
+
self._is_runtime_throw_output_enabled: bool = False
|
|
18
|
+
self._title: str = "error at 'qlogicae-cor1'"
|
|
19
|
+
self._message: str = "something went wrong here"
|
|
20
|
+
self._title_message_separator: str = " - "
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def is_output_enabled(self) -> bool:
|
|
24
|
+
return self._is_output_enabled
|
|
25
|
+
|
|
26
|
+
@is_output_enabled.setter
|
|
27
|
+
def is_output_enabled(
|
|
28
|
+
self,
|
|
29
|
+
value: bool,
|
|
30
|
+
) -> None:
|
|
31
|
+
self._is_output_enabled = value
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def is_output_override_enabled(self) -> bool:
|
|
35
|
+
return self._is_output_override_enabled
|
|
36
|
+
|
|
37
|
+
@is_output_override_enabled.setter
|
|
38
|
+
def is_output_override_enabled(
|
|
39
|
+
self,
|
|
40
|
+
value: bool,
|
|
41
|
+
) -> None:
|
|
42
|
+
self._is_output_override_enabled = value
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def is_asynchronous_output_enabled(self) -> bool:
|
|
46
|
+
return self._is_asynchronous_output_enabled
|
|
47
|
+
|
|
48
|
+
@is_asynchronous_output_enabled.setter
|
|
49
|
+
def is_asynchronous_output_enabled(
|
|
50
|
+
self,
|
|
51
|
+
value: bool,
|
|
52
|
+
) -> None:
|
|
53
|
+
self._is_asynchronous_output_enabled = value
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def is_asynchronous_output_override_enabled(self) -> bool:
|
|
57
|
+
return self._is_asynchronous_output_override_enabled
|
|
58
|
+
|
|
59
|
+
@is_asynchronous_output_override_enabled.setter
|
|
60
|
+
def is_asynchronous_output_override_enabled(
|
|
61
|
+
self,
|
|
62
|
+
value: bool,
|
|
63
|
+
) -> None:
|
|
64
|
+
self._is_asynchronous_output_override_enabled = value
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def is_console_output_enabled(self) -> bool:
|
|
68
|
+
return self._is_console_output_enabled
|
|
69
|
+
|
|
70
|
+
@is_console_output_enabled.setter
|
|
71
|
+
def is_console_output_enabled(
|
|
72
|
+
self,
|
|
73
|
+
value: bool,
|
|
74
|
+
) -> None:
|
|
75
|
+
self._is_console_output_enabled = value
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def is_runtime_throw_output_enabled(self) -> bool:
|
|
79
|
+
return self._is_runtime_throw_output_enabled
|
|
80
|
+
|
|
81
|
+
@is_runtime_throw_output_enabled.setter
|
|
82
|
+
def is_runtime_throw_output_enabled(
|
|
83
|
+
self,
|
|
84
|
+
value: bool,
|
|
85
|
+
) -> None:
|
|
86
|
+
self._is_runtime_throw_output_enabled = value
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def title(self) -> str:
|
|
90
|
+
return self._title
|
|
91
|
+
|
|
92
|
+
@title.setter
|
|
93
|
+
def title(
|
|
94
|
+
self,
|
|
95
|
+
value: str,
|
|
96
|
+
) -> None:
|
|
97
|
+
self._title = value
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def message(self) -> str:
|
|
101
|
+
return self._message
|
|
102
|
+
|
|
103
|
+
@message.setter
|
|
104
|
+
def message(
|
|
105
|
+
self,
|
|
106
|
+
value: str,
|
|
107
|
+
) -> None:
|
|
108
|
+
self._message = value
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def title_message_separator(self) -> str:
|
|
112
|
+
return self._title_message_separator
|
|
113
|
+
|
|
114
|
+
@title_message_separator.setter
|
|
115
|
+
def title_message_separator(
|
|
116
|
+
self,
|
|
117
|
+
value: str,
|
|
118
|
+
) -> None:
|
|
119
|
+
self._title_message_separator = value
|
|
120
|
+
|
|
121
|
+
def is_enabled_for_runtime_throw_output(
|
|
122
|
+
self,
|
|
123
|
+
) -> bool:
|
|
124
|
+
return (
|
|
125
|
+
self.is_output_enabled
|
|
126
|
+
if self.is_output_override_enabled
|
|
127
|
+
else self.is_runtime_throw_output_enabled
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
def is_enabled_for_console_output(
|
|
131
|
+
self,
|
|
132
|
+
) -> bool:
|
|
133
|
+
return (
|
|
134
|
+
self.is_output_enabled
|
|
135
|
+
if self.is_output_override_enabled
|
|
136
|
+
else self.is_console_output_enabled
|
|
137
|
+
)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from typing import Any, TypeVar
|
|
3
|
+
|
|
4
|
+
from library.singleton_manager_configurations import (
|
|
5
|
+
SingletonManagerConfigurations,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
Type = TypeVar("Type")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SingletonManager:
|
|
12
|
+
configurations: SingletonManagerConfigurations = SingletonManagerConfigurations()
|
|
13
|
+
|
|
14
|
+
_singletons: dict[
|
|
15
|
+
Callable[[], Any],
|
|
16
|
+
Any,
|
|
17
|
+
] = {}
|
|
18
|
+
|
|
19
|
+
_singleton_arrays: dict[
|
|
20
|
+
Callable[[], Any],
|
|
21
|
+
list[Any],
|
|
22
|
+
] = {}
|
|
23
|
+
|
|
24
|
+
def __init__(self) -> None:
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def setup(
|
|
29
|
+
self,
|
|
30
|
+
new_configurations: SingletonManagerConfigurations,
|
|
31
|
+
) -> bool:
|
|
32
|
+
try:
|
|
33
|
+
if self.configurations.is_disabled_for_handling(
|
|
34
|
+
new_configurations is None,
|
|
35
|
+
):
|
|
36
|
+
return False
|
|
37
|
+
|
|
38
|
+
self.configurations = new_configurations
|
|
39
|
+
|
|
40
|
+
return True
|
|
41
|
+
|
|
42
|
+
except Exception:
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
@classmethod
|
|
46
|
+
def reset(
|
|
47
|
+
self,
|
|
48
|
+
) -> bool:
|
|
49
|
+
try:
|
|
50
|
+
if self.configurations.is_disabled_for_handling():
|
|
51
|
+
return False
|
|
52
|
+
|
|
53
|
+
self.configurations = SingletonManagerConfigurations()
|
|
54
|
+
|
|
55
|
+
self._singletons.clear()
|
|
56
|
+
self._singleton_arrays.clear()
|
|
57
|
+
|
|
58
|
+
return True
|
|
59
|
+
|
|
60
|
+
except Exception:
|
|
61
|
+
return False
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def get_singleton(
|
|
65
|
+
self,
|
|
66
|
+
constructor: Callable[[], Type],
|
|
67
|
+
) -> Type:
|
|
68
|
+
try:
|
|
69
|
+
instance = self._singletons.get(constructor)
|
|
70
|
+
|
|
71
|
+
if instance is None:
|
|
72
|
+
instance = constructor()
|
|
73
|
+
self._singletons[constructor] = instance
|
|
74
|
+
|
|
75
|
+
return instance
|
|
76
|
+
|
|
77
|
+
except Exception as exception:
|
|
78
|
+
raise RuntimeError(
|
|
79
|
+
"error at 'qlogicae-cor' - something went wrong here"
|
|
80
|
+
) from exception
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def get_singleton_from_pool(
|
|
84
|
+
self,
|
|
85
|
+
constructor: Callable[[], Type],
|
|
86
|
+
instance_count: int,
|
|
87
|
+
index: int,
|
|
88
|
+
) -> Type:
|
|
89
|
+
try:
|
|
90
|
+
if instance_count <= 0:
|
|
91
|
+
raise ValueError("error at 'qlogicae-cor' - something went wrong here")
|
|
92
|
+
|
|
93
|
+
instances = self._singleton_arrays.get(
|
|
94
|
+
constructor,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if instances is None:
|
|
98
|
+
instances = [constructor() for _ in range(instance_count)]
|
|
99
|
+
|
|
100
|
+
self._singleton_arrays[constructor] = instances
|
|
101
|
+
|
|
102
|
+
return instances[abs(index) % instance_count]
|
|
103
|
+
|
|
104
|
+
except Exception as exception:
|
|
105
|
+
raise RuntimeError(
|
|
106
|
+
"error at 'qlogicae-cor' - something went wrong here"
|
|
107
|
+
) from exception
|
|
Binary file
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "qlogicae-cor"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "The core library for QLogicae projects"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.14"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Vaughn Cedric L. Araneta", email = "vaughncedriclipardoaraneta@gmail.com" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Operating System :: OS Independent"
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
dependencies = []
|
|
23
|
+
|
|
24
|
+
[tool.setuptools]
|
|
25
|
+
package-dir = {"" = "library"}
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.packages.find]
|
|
28
|
+
where = ["library"]
|
|
29
|
+
|
|
30
|
+
[tool.pytest.ini_options]
|
|
31
|
+
pythonpath = ["."]
|
|
32
|
+
testpaths = ["test"]
|
|
33
|
+
|
|
34
|
+
[tool.mypy]
|
|
35
|
+
strict = true
|
|
36
|
+
warn_return_any = true
|
|
37
|
+
warn_unused_configs = true
|
|
38
|
+
warn_unreachable = true
|
|
39
|
+
warn_no_return = true
|
|
40
|
+
disallow_any_generics = true
|
|
41
|
+
disallow_any_unimported = true
|
|
42
|
+
explicit_package_bases = true
|
|
43
|
+
namespace_packages = true
|
|
44
|
+
files = ["library", "test"]
|
|
45
|
+
|
|
46
|
+
[tool.ruff]
|
|
47
|
+
line-length = 88
|
|
48
|
+
target-version = "py314"
|
|
49
|
+
exclude = [
|
|
50
|
+
".venv",
|
|
51
|
+
".git",
|
|
52
|
+
"__pycache__",
|
|
53
|
+
".output",
|
|
54
|
+
"output",
|
|
55
|
+
".outputs",
|
|
56
|
+
"outputs",
|
|
57
|
+
".dist",
|
|
58
|
+
"dist",
|
|
59
|
+
".build",
|
|
60
|
+
"build",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.ruff.lint]
|
|
64
|
+
select = ["E", "F", "I", "B", "UP"]
|
|
65
|
+
ignore = []
|
|
66
|
+
fixable = ["ALL"]
|
|
67
|
+
unfixable = []
|
|
68
|
+
|
|
69
|
+
[tool.ruff.format]
|
|
70
|
+
quote-style = "double"
|
|
71
|
+
indent-style = "space"
|
|
72
|
+
|
|
73
|
+
[tool.hatch.envs.default.scripts]
|
|
74
|
+
lint = "ruff check . --fix"
|
|
75
|
+
format = "ruff format ."
|
|
76
|
+
audit-security = "pip-audit"
|
|
77
|
+
deploy-check = "twine check ./output/build/*"
|
|
78
|
+
clean-build = "rm -rf ./output/build && mkdir -p ./output/build"
|
|
79
|
+
clean-test-unit = "rm -rf ./output/test/unit && mkdir -p ./output/test/unit"
|
|
80
|
+
clean-test-benchmark = "rm -rf ./output/test/benchmark && mkdir -p ./output/test/benchmark"
|
|
81
|
+
build = "hatch run clean-build && hatch build && mv dist/* ./output/build"
|
|
82
|
+
workflow-test-unit = "hatch run clean-test-unit && pytest -vv --cov=library --cov-branch --cov-report=term-missing --cov-report=html:./output/test/unit/html --cov-report=xml:./output/test/unit/coverage.xml --cov-report=json:./output/test/unit/coverage.json --junitxml=./output/test/unit/junit.xml"
|
|
83
|
+
workflow-test-benchmark = "clean-test-benchmark && pytest -vv --benchmark-enable --benchmark-json=./output/test/benchmark/benchmark.json"
|
|
84
|
+
workflow-deploy-check = "hatch run build && hatch run deploy-check"
|
|
85
|
+
workflow-deploy = "hatch run build && twine upload --verbose ./output/build/*"
|
|
86
|
+
|
|
87
|
+
[tool.hatch.build]
|
|
88
|
+
include = [
|
|
89
|
+
"library/**/*.py",
|
|
90
|
+
"project/**/*",
|
|
91
|
+
"README.md",
|
|
92
|
+
"LICENSE",
|
|
93
|
+
"pyproject.toml",
|
|
94
|
+
]
|
|
95
|
+
exclude = [
|
|
96
|
+
"**/__pycache__/**",
|
|
97
|
+
"**/*.pyc",
|
|
98
|
+
".github/**",
|
|
99
|
+
"test/**",
|
|
100
|
+
"docs/**",
|
|
101
|
+
"docs/**",
|
|
102
|
+
]
|
|
103
|
+
|