iker-python-common 1.0.1__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 (64) hide show
  1. iker_python_common-1.0.1/.editorconfig +80 -0
  2. iker_python_common-1.0.1/.github/workflows/pr.yml +45 -0
  3. iker_python_common-1.0.1/.github/workflows/push.yml +28 -0
  4. iker_python_common-1.0.1/.gitignore +187 -0
  5. iker_python_common-1.0.1/MANIFEST.in +1 -0
  6. iker_python_common-1.0.1/PKG-INFO +39 -0
  7. iker_python_common-1.0.1/README.md +25 -0
  8. iker_python_common-1.0.1/VERSION +1 -0
  9. iker_python_common-1.0.1/pyproject.toml +72 -0
  10. iker_python_common-1.0.1/resources/unittest/shutils/dir.baz/file.bar.baz +0 -0
  11. iker_python_common-1.0.1/resources/unittest/shutils/dir.baz/file.foo.bar +0 -0
  12. iker_python_common-1.0.1/resources/unittest/shutils/dir.baz/file.foo.baz +0 -0
  13. iker_python_common-1.0.1/resources/unittest/shutils/dir.foo/dir.foo.bar/dir.foo.bar.baz/file.foo.bar.baz +0 -0
  14. iker_python_common-1.0.1/resources/unittest/shutils/dir.foo/dir.foo.bar/file.bar.baz +0 -0
  15. iker_python_common-1.0.1/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.bar +0 -0
  16. iker_python_common-1.0.1/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.baz +0 -0
  17. iker_python_common-1.0.1/resources/unittest/shutils/dir.foo/file.bar +0 -0
  18. iker_python_common-1.0.1/resources/unittest/shutils/dir.foo/file.baz +0 -0
  19. iker_python_common-1.0.1/resources/unittest/shutils/dir.foo/file.foo +0 -0
  20. iker_python_common-1.0.1/setup.cfg +4 -0
  21. iker_python_common-1.0.1/setup.py +13 -0
  22. iker_python_common-1.0.1/src/iker/common/__init__.py +6 -0
  23. iker_python_common-1.0.1/src/iker/common/core/__init__.py +0 -0
  24. iker_python_common-1.0.1/src/iker/common/core/exceptions.py +64 -0
  25. iker_python_common-1.0.1/src/iker/common/utils/__init__.py +0 -0
  26. iker_python_common-1.0.1/src/iker/common/utils/config.py +117 -0
  27. iker_python_common-1.0.1/src/iker/common/utils/dbutils.py +203 -0
  28. iker_python_common-1.0.1/src/iker/common/utils/dockerutils.py +223 -0
  29. iker_python_common-1.0.1/src/iker/common/utils/dtutils.py +187 -0
  30. iker_python_common-1.0.1/src/iker/common/utils/funcutils.py +101 -0
  31. iker_python_common-1.0.1/src/iker/common/utils/logger.py +67 -0
  32. iker_python_common-1.0.1/src/iker/common/utils/numutils.py +103 -0
  33. iker_python_common-1.0.1/src/iker/common/utils/randutils.py +147 -0
  34. iker_python_common-1.0.1/src/iker/common/utils/retry.py +182 -0
  35. iker_python_common-1.0.1/src/iker/common/utils/s3utils.py +270 -0
  36. iker_python_common-1.0.1/src/iker/common/utils/sequtils.py +394 -0
  37. iker_python_common-1.0.1/src/iker/common/utils/shutils.py +229 -0
  38. iker_python_common-1.0.1/src/iker/common/utils/stream.py +188 -0
  39. iker_python_common-1.0.1/src/iker/common/utils/strutils.py +159 -0
  40. iker_python_common-1.0.1/src/iker/common/utils/testutils.py +171 -0
  41. iker_python_common-1.0.1/src/iker_python_common.egg-info/PKG-INFO +39 -0
  42. iker_python_common-1.0.1/src/iker_python_common.egg-info/SOURCES.txt +62 -0
  43. iker_python_common-1.0.1/src/iker_python_common.egg-info/dependency_links.txt +1 -0
  44. iker_python_common-1.0.1/src/iker_python_common.egg-info/not-zip-safe +1 -0
  45. iker_python_common-1.0.1/src/iker_python_common.egg-info/requires.txt +33 -0
  46. iker_python_common-1.0.1/src/iker_python_common.egg-info/top_level.txt +1 -0
  47. iker_python_common-1.0.1/test/iker_tests/__init__.py +15 -0
  48. iker_python_common-1.0.1/test/iker_tests/common/core/exceptions_test.py +20 -0
  49. iker_python_common-1.0.1/test/iker_tests/common/utils/config_test.py +388 -0
  50. iker_python_common-1.0.1/test/iker_tests/common/utils/dbutils_test.py +346 -0
  51. iker_python_common-1.0.1/test/iker_tests/common/utils/dockerutils_test.py +548 -0
  52. iker_python_common-1.0.1/test/iker_tests/common/utils/dtutils_test.py +131 -0
  53. iker_python_common-1.0.1/test/iker_tests/common/utils/funcutils_test.py +377 -0
  54. iker_python_common-1.0.1/test/iker_tests/common/utils/logger_test.py +21 -0
  55. iker_python_common-1.0.1/test/iker_tests/common/utils/numutils_test.py +394 -0
  56. iker_python_common-1.0.1/test/iker_tests/common/utils/randutils_test.py +132 -0
  57. iker_python_common-1.0.1/test/iker_tests/common/utils/retry_test.py +206 -0
  58. iker_python_common-1.0.1/test/iker_tests/common/utils/s3utils_test.py +416 -0
  59. iker_python_common-1.0.1/test/iker_tests/common/utils/sequtils_test.py +1079 -0
  60. iker_python_common-1.0.1/test/iker_tests/common/utils/shutils_test.py +566 -0
  61. iker_python_common-1.0.1/test/iker_tests/common/utils/strutils_test.py +393 -0
  62. iker_python_common-1.0.1/test/iker_tests/common/utils/testutils_test.py +359 -0
  63. iker_python_common-1.0.1/test/iker_tests/docker_fixtures.py +79 -0
  64. iker_python_common-1.0.1/test/iker_tests/iker_test.py +13 -0
@@ -0,0 +1,80 @@
1
+ root = true
2
+
3
+ [*.py]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ trim_trailing_whitespace = true
8
+ indent_style = space
9
+ indent_size = 4
10
+
11
+ ij_python_align_collections_and_comprehensions = true
12
+ ij_python_align_multiline_imports = true
13
+ ij_python_align_multiline_parameters = true
14
+ ij_python_align_multiline_parameters_in_calls = true
15
+ ij_python_blank_line_at_file_end = true
16
+ ij_python_blank_lines_after_imports = 1
17
+ ij_python_blank_lines_after_local_imports = 0
18
+ ij_python_blank_lines_around_class = 1
19
+ ij_python_blank_lines_around_method = 1
20
+ ij_python_blank_lines_around_top_level_classes_functions = 2
21
+ ij_python_blank_lines_before_first_method = 0
22
+ ij_python_call_parameters_new_line_after_left_paren = false
23
+ ij_python_call_parameters_right_paren_on_new_line = false
24
+ ij_python_call_parameters_wrap = normal
25
+ ij_python_dict_alignment = 0
26
+ ij_python_dict_new_line_after_left_brace = false
27
+ ij_python_dict_new_line_before_right_brace = false
28
+ ij_python_dict_wrapping = 1
29
+ ij_python_from_import_new_line_after_left_parenthesis = false
30
+ ij_python_from_import_new_line_before_right_parenthesis = false
31
+ ij_python_from_import_parentheses_force_if_multiline = false
32
+ ij_python_from_import_trailing_comma_if_multiline = false
33
+ ij_python_from_import_wrapping = 1
34
+ ij_python_hang_closing_brackets = false
35
+ ij_python_keep_blank_lines_in_code = 1
36
+ ij_python_keep_blank_lines_in_declarations = 1
37
+ ij_python_keep_indents_on_empty_lines = false
38
+ ij_python_keep_line_breaks = true
39
+ ij_python_method_parameters_new_line_after_left_paren = false
40
+ ij_python_method_parameters_right_paren_on_new_line = false
41
+ ij_python_method_parameters_wrap = normal
42
+ ij_python_new_line_after_colon = false
43
+ ij_python_new_line_after_colon_multi_clause = true
44
+ ij_python_optimize_imports_always_split_from_imports = false
45
+ ij_python_optimize_imports_case_insensitive_order = false
46
+ ij_python_optimize_imports_join_from_imports_with_same_source = false
47
+ ij_python_optimize_imports_sort_by_type_first = true
48
+ ij_python_optimize_imports_sort_imports = true
49
+ ij_python_optimize_imports_sort_names_in_from_imports = true
50
+ ij_python_space_after_comma = true
51
+ ij_python_space_after_number_sign = true
52
+ ij_python_space_after_py_colon = true
53
+ ij_python_space_before_backslash = true
54
+ ij_python_space_before_comma = false
55
+ ij_python_space_before_for_semicolon = false
56
+ ij_python_space_before_lbracket = false
57
+ ij_python_space_before_method_call_parentheses = false
58
+ ij_python_space_before_method_parentheses = false
59
+ ij_python_space_before_number_sign = true
60
+ ij_python_space_before_py_colon = false
61
+ ij_python_space_within_empty_method_call_parentheses = false
62
+ ij_python_space_within_empty_method_parentheses = false
63
+ ij_python_spaces_around_additive_operators = true
64
+ ij_python_spaces_around_assignment_operators = true
65
+ ij_python_spaces_around_bitwise_operators = true
66
+ ij_python_spaces_around_eq_in_keyword_argument = false
67
+ ij_python_spaces_around_eq_in_named_parameter = false
68
+ ij_python_spaces_around_equality_operators = true
69
+ ij_python_spaces_around_multiplicative_operators = true
70
+ ij_python_spaces_around_power_operator = true
71
+ ij_python_spaces_around_relational_operators = true
72
+ ij_python_spaces_around_shift_operators = true
73
+ ij_python_spaces_within_braces = false
74
+ ij_python_spaces_within_brackets = false
75
+ ij_python_spaces_within_method_call_parentheses = false
76
+ ij_python_spaces_within_method_parentheses = false
77
+ ij_python_use_continuation_indent_for_arguments = false
78
+ ij_python_use_continuation_indent_for_collection_and_comprehensions = false
79
+ ij_python_use_continuation_indent_for_parameters = false
80
+ ij_python_wrap_long_lines = false
@@ -0,0 +1,45 @@
1
+ name: Pull Request
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ "master" ]
6
+
7
+ env:
8
+ BUILD_NUMBER: ${{ github.run_number }}
9
+
10
+ jobs:
11
+ build-python311:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Setup Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.11"
18
+
19
+ - name: Checkout
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Build and Test
23
+ run: |
24
+ sudo apt-get install libxml2-dev libxslt1-dev llvm-14-dev
25
+ python -m pip install --upgrade pip
26
+ python -m pip install .[test]
27
+ python -m pytest . --cov --cov-config pyproject.toml
28
+
29
+ build-python312:
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - name: Setup Python
33
+ uses: actions/setup-python@v5
34
+ with:
35
+ python-version: "3.12"
36
+
37
+ - name: Checkout
38
+ uses: actions/checkout@v4
39
+
40
+ - name: Build and Test
41
+ run: |
42
+ sudo apt-get install libxml2-dev libxslt1-dev llvm-14-dev
43
+ python -m pip install --upgrade pip
44
+ python -m pip install .[test]
45
+ python -m pytest . --cov --cov-config pyproject.toml
@@ -0,0 +1,28 @@
1
+ name: Push
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+
7
+ env:
8
+ BUILD_NUMBER: ${{ github.run_number }}
9
+
10
+ jobs:
11
+ push:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Setup Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.12"
18
+
19
+ - name: Checkout
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Build and Upload
23
+ run: |
24
+ sudo apt-get install libxml2-dev libxslt1-dev llvm-14-dev
25
+ python -m pip install --upgrade pip build twine
26
+ python -m pip install .
27
+ python -m build -sw .
28
+ python -m twine upload --username __token__ --password ${{ secrets.PYPI_TOKEN }} dist/*
@@ -0,0 +1,187 @@
1
+ # System junks
2
+ *.[oa]
3
+ *~
4
+ .DS_Store
5
+ Thumbs.db
6
+
7
+ # Git
8
+ .git/
9
+
10
+ # General
11
+ target/
12
+ output/
13
+ build/
14
+ opt/
15
+ gen/
16
+ tmp/
17
+ temp/
18
+
19
+ # IDEs
20
+ *.iml
21
+ .idea/
22
+ .classpath
23
+ .project
24
+ .settings/
25
+ .vscode/
26
+
27
+
28
+ # Byte-compiled / optimized / DLL files
29
+ __pycache__/
30
+ *.py[cod]
31
+ *$py.class
32
+
33
+ # C extensions
34
+ *.so
35
+
36
+ # Distribution / packaging
37
+ .Python
38
+ build/
39
+ develop-eggs/
40
+ dist/
41
+ downloads/
42
+ eggs/
43
+ .eggs/
44
+ lib/
45
+ lib64/
46
+ parts/
47
+ sdist/
48
+ var/
49
+ wheels/
50
+ share/python-wheels/
51
+ *.egg-info/
52
+ .installed.cfg
53
+ *.egg
54
+ MANIFEST
55
+
56
+ # PyInstaller
57
+ # Usually these files are written by a python script from a template
58
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
59
+ *.manifest
60
+ *.spec
61
+
62
+ # Installer logs
63
+ pip-log.txt
64
+ pip-delete-this-directory.txt
65
+
66
+ # Unit test / coverage reports
67
+ htmlcov/
68
+ .tox/
69
+ .nox/
70
+ .coverage
71
+ .coverage.*
72
+ .cache
73
+ nosetests.xml
74
+ coverage.xml
75
+ *.cover
76
+ *.py,cover
77
+ .hypothesis/
78
+ .pytest_cache/
79
+ cover/
80
+
81
+ # Translations
82
+ *.mo
83
+ *.pot
84
+
85
+ # Django stuff:
86
+ *.log
87
+ local_settings.py
88
+ db.sqlite3
89
+ db.sqlite3-journal
90
+
91
+ # Flask stuff:
92
+ instance/
93
+ .webassets-cache
94
+
95
+ # Scrapy stuff:
96
+ .scrapy
97
+
98
+ # Sphinx documentation
99
+ docs/_build/
100
+
101
+ # PyBuilder
102
+ .pybuilder/
103
+ target/
104
+
105
+ # Jupyter Notebook
106
+ .ipynb_checkpoints
107
+
108
+ # IPython
109
+ profile_default/
110
+ ipython_config.py
111
+
112
+ # pyenv
113
+ # For a library or package, you might want to ignore these files since the code is
114
+ # intended to run in multiple environments; otherwise, check them in:
115
+ # .python-version
116
+
117
+ # pipenv
118
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
119
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
120
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
121
+ # install all needed dependencies.
122
+ #Pipfile.lock
123
+
124
+ # poetry
125
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
126
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
127
+ # commonly ignored for libraries.
128
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
129
+ #poetry.lock
130
+
131
+ # pdm
132
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
133
+ #pdm.lock
134
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
135
+ # in version control.
136
+ # https://pdm.fming.dev/#use-with-ide
137
+ .pdm.toml
138
+
139
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
140
+ __pypackages__/
141
+
142
+ # Celery stuff
143
+ celerybeat-schedule
144
+ celerybeat.pid
145
+
146
+ # SageMath parsed files
147
+ *.sage.py
148
+
149
+ # Environments
150
+ .env
151
+ .venv
152
+ env/
153
+ venv/
154
+ ENV/
155
+ env.bak/
156
+ venv.bak/
157
+
158
+ # Spyder project settings
159
+ .spyderproject
160
+ .spyproject
161
+
162
+ # Rope project settings
163
+ .ropeproject
164
+
165
+ # mkdocs documentation
166
+ /site
167
+
168
+ # mypy
169
+ .mypy_cache/
170
+ .dmypy.json
171
+ dmypy.json
172
+
173
+ # Pyre type checker
174
+ .pyre/
175
+
176
+ # pytype static type analyzer
177
+ .pytype/
178
+
179
+ # Cython debug symbols
180
+ cython_debug/
181
+
182
+ # PyCharm
183
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
184
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
185
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
186
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
187
+ #.idea/
@@ -0,0 +1 @@
1
+ include VERSION
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.1
2
+ Name: iker-python-common
3
+ Version: 1.0.1
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Python :: 3.11
6
+ Classifier: Programming Language :: Python :: 3.12
7
+ Requires-Python: <3.13,>=3.11
8
+ Requires-Dist: boto3~=1.34
9
+ Requires-Dist: brotli~=1.0
10
+ Requires-Dist: docker~=7.1
11
+ Requires-Dist: jsonpath-ng~=1.6
12
+ Requires-Dist: jsonschema~=4.23
13
+ Requires-Dist: llvmlite~=0.43
14
+ Requires-Dist: lxml~=4.9
15
+ Requires-Dist: munch~=4.0
16
+ Requires-Dist: numpy~=2.1
17
+ Requires-Dist: pandas~=2.2
18
+ Requires-Dist: psycopg2-binary~=2.9
19
+ Requires-Dist: pygeodesy~=23.12
20
+ Requires-Dist: pymysql~=1.1
21
+ Requires-Dist: pyparsing~=3.1
22
+ Requires-Dist: pyquaternion~=0.9
23
+ Requires-Dist: pysocks~=1.7
24
+ Requires-Dist: python-dateutil~=2.8
25
+ Requires-Dist: pyyaml~=6.0
26
+ Requires-Dist: requests~=2.31
27
+ Requires-Dist: scipy~=1.14
28
+ Requires-Dist: shapely~=2.0
29
+ Requires-Dist: sqlalchemy~=2.0
30
+ Requires-Dist: ujson~=5.10
31
+ Provides-Extra: test
32
+ Requires-Dist: ddt~=1.7; extra == "test"
33
+ Requires-Dist: moto[all,ec2,s3]~=4.2; extra == "test"
34
+ Requires-Dist: pytest-cov~=5.0; extra == "test"
35
+ Requires-Dist: pytest-mock~=3.14; extra == "test"
36
+ Requires-Dist: pytest-mysql~=3.0; extra == "test"
37
+ Requires-Dist: pytest-order~=1.2; extra == "test"
38
+ Requires-Dist: pytest-postgresql~=6.0; extra == "test"
39
+ Requires-Dist: pytest~=8.3; extra == "test"
@@ -0,0 +1,25 @@
1
+ # Iker's Python Common Module
2
+
3
+ ## Build and Deploy
4
+
5
+ ### Using Conda
6
+
7
+ We recommend using Conda. You need to install Anaconda packages from
8
+ the [official site](https://www.anaconda.com/products/distribution)
9
+
10
+ Create a Conda environment and install the modules and their dependencies in it
11
+
12
+ ```shell
13
+ conda create -n iker python=3.12
14
+ conda activate iker
15
+
16
+ pip install .
17
+
18
+ conda deactivate
19
+ ```
20
+
21
+ To remove the existing Conda environment (and create a brand new one)
22
+
23
+ ```shell
24
+ conda env remove -n iker
25
+ ```
@@ -0,0 +1 @@
1
+ 1.0
@@ -0,0 +1,72 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools~=72.0",
4
+ "setuptools-scm~=8.0",
5
+ "iker-python-setup~=1.0",
6
+ ]
7
+ build-backend = "setuptools.build_meta"
8
+
9
+ [project]
10
+ name = "iker-python-common"
11
+ dynamic = ["version"]
12
+ requires-python = ">=3.11,<3.13"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.11",
16
+ "Programming Language :: Python :: 3.12",
17
+ ]
18
+ dependencies = [
19
+ "boto3~=1.34",
20
+ "brotli~=1.0",
21
+ "docker~=7.1",
22
+ "jsonpath-ng~=1.6",
23
+ "jsonschema~=4.23",
24
+ "llvmlite~=0.43",
25
+ "lxml~=4.9",
26
+ "munch~=4.0",
27
+ "numpy~=2.1",
28
+ "pandas~=2.2",
29
+ "psycopg2-binary~=2.9",
30
+ "pygeodesy~=23.12",
31
+ "pymysql~=1.1",
32
+ "pyparsing~=3.1",
33
+ "pyquaternion~=0.9",
34
+ "pysocks~=1.7",
35
+ "python-dateutil~=2.8",
36
+ "pyyaml~=6.0",
37
+ "requests~=2.31",
38
+ "scipy~=1.14",
39
+ "shapely~=2.0",
40
+ "sqlalchemy~=2.0",
41
+ "ujson~=5.10",
42
+ ]
43
+
44
+ [project.optional-dependencies]
45
+ test = [
46
+ "ddt~=1.7",
47
+ "moto[ec2,s3,all]~=4.2",
48
+ "pytest-cov~=5.0",
49
+ "pytest-mock~=3.14",
50
+ "pytest-mysql~=3.0",
51
+ "pytest-order~=1.2",
52
+ "pytest-postgresql~=6.0",
53
+ "pytest~=8.3",
54
+ ]
55
+
56
+ [tool.setuptools]
57
+ package-dir = { "" = "src" }
58
+ zip-safe = false
59
+ include-package-data = true
60
+
61
+ [tool.setuptools.packages.find]
62
+ where = ["src"]
63
+ namespaces = true
64
+
65
+ [tool.pytest.ini_options]
66
+ pythonpath = ["test"]
67
+
68
+ [tool.coverage.run]
69
+ include = [
70
+ "src/iker/common/*",
71
+ "*/site-packages/iker/common/*",
72
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ import argparse
2
+
3
+ from iker.setup import setup, version_string
4
+
5
+ if __name__ == "__main__":
6
+ parser = argparse.ArgumentParser(description="setup script integrating dynamic version printer")
7
+ parser.add_argument("--print-version-string", action="store_true", help="print version string and exit")
8
+
9
+ args, _ = parser.parse_known_args()
10
+ if args.print_version_string:
11
+ print(version_string())
12
+ else:
13
+ setup()
@@ -0,0 +1,6 @@
1
+ import importlib.metadata
2
+
3
+ try:
4
+ __version__ = importlib.metadata.version("iker-python-common")
5
+ except importlib.metadata.PackageNotFoundError:
6
+ __version__ = "unknown"
@@ -0,0 +1,64 @@
1
+ import traceback
2
+
3
+
4
+ class BaseTraceableException(Exception):
5
+ """
6
+ Base class of traceable exceptions and errors
7
+ """
8
+
9
+ def __init__(self, message: str, *args, **kwargs):
10
+ super(BaseTraceableException, self).__init__()
11
+ self.message = message
12
+ self.args = args
13
+ self.cause = kwargs.get("cause")
14
+ self.traceback = "" if kwargs.get("cause") is None else traceback.format_exc()
15
+
16
+ def __str__(self) -> str:
17
+ return self.message % self.args
18
+
19
+ def __traceback(self):
20
+ if self.cause is None or not isinstance(self.cause, BaseTraceableException):
21
+ return self.traceback
22
+ return self.traceback + self.cause.__traceback()
23
+
24
+ @staticmethod
25
+ def format_traceback(error):
26
+ if isinstance(error, BaseTraceableException):
27
+ return traceback.format_exc() + error.__traceback()
28
+ return traceback.format_exc()
29
+
30
+
31
+ class RuntimeException(BaseTraceableException):
32
+ """
33
+ Represents runtime exception
34
+ """
35
+
36
+ def __init__(self, message: str, *args, **kwargs):
37
+ super(RuntimeException, self).__init__(message, *args, **kwargs)
38
+
39
+
40
+ class InvalidTypeException(BaseTraceableException):
41
+ """
42
+ Represents invalid type exception
43
+ """
44
+
45
+ def __init__(self, message: str, *args, **kwargs):
46
+ super(InvalidTypeException, self).__init__(message, *args, **kwargs)
47
+
48
+
49
+ class InvalidKeyException(BaseTraceableException):
50
+ """
51
+ Represents invalid key exception
52
+ """
53
+
54
+ def __init__(self, message: str, *args, **kwargs):
55
+ super(InvalidKeyException, self).__init__(message, *args, **kwargs)
56
+
57
+
58
+ class InvalidValueException(BaseTraceableException):
59
+ """
60
+ Represents invalid value exception
61
+ """
62
+
63
+ def __init__(self, message: str, *args, **kwargs):
64
+ super(InvalidValueException, self).__init__(message, *args, **kwargs)