crcutil 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.
Files changed (45) hide show
  1. crcutil-1.0.0/.github/workflows/python-publish.yml +39 -0
  2. crcutil-1.0.0/.gitignore +171 -0
  3. crcutil-1.0.0/LICENSE +21 -0
  4. crcutil-1.0.0/PKG-INFO +120 -0
  5. crcutil-1.0.0/README.md +79 -0
  6. crcutil-1.0.0/__init__.py +0 -0
  7. crcutil-1.0.0/git-hooks/commit-msg +12 -0
  8. crcutil-1.0.0/git-hooks/pre-commit +4 -0
  9. crcutil-1.0.0/init.sh +40 -0
  10. crcutil-1.0.0/pyproject.toml +36 -0
  11. crcutil-1.0.0/requirements.txt +7 -0
  12. crcutil-1.0.0/ruff.toml +40 -0
  13. crcutil-1.0.0/setup.cfg +4 -0
  14. crcutil-1.0.0/src/crcutil/__init__.py +0 -0
  15. crcutil-1.0.0/src/crcutil/__main__.py +112 -0
  16. crcutil-1.0.0/src/crcutil/config/log_config.yaml +63 -0
  17. crcutil-1.0.0/src/crcutil/core/__init__.py +0 -0
  18. crcutil-1.0.0/src/crcutil/core/crc.py +290 -0
  19. crcutil-1.0.0/src/crcutil/core/prompt.py +177 -0
  20. crcutil-1.0.0/src/crcutil/dto/__init__.py +0 -0
  21. crcutil-1.0.0/src/crcutil/dto/bootstrap_paths_dto.py +10 -0
  22. crcutil-1.0.0/src/crcutil/dto/hash_diff_report_dto.py +17 -0
  23. crcutil-1.0.0/src/crcutil/dto/hash_dto.py +10 -0
  24. crcutil-1.0.0/src/crcutil/dto/user_instructions_dto.py +17 -0
  25. crcutil-1.0.0/src/crcutil/enums/__init__.py +0 -0
  26. crcutil-1.0.0/src/crcutil/enums/user_request.py +24 -0
  27. crcutil-1.0.0/src/crcutil/exception/__init__.py +0 -0
  28. crcutil-1.0.0/src/crcutil/exception/bootstrap_error.py +2 -0
  29. crcutil-1.0.0/src/crcutil/exception/corrupt_hash_error.py +2 -0
  30. crcutil-1.0.0/src/crcutil/exception/unexpected_argument_error.py +2 -0
  31. crcutil-1.0.0/src/crcutil/exception/user_error.py +2 -0
  32. crcutil-1.0.0/src/crcutil/serializer/__init__.py +0 -0
  33. crcutil-1.0.0/src/crcutil/serializer/hash_diff_report_serializer.py +26 -0
  34. crcutil-1.0.0/src/crcutil/serializer/hash_serializer.py +14 -0
  35. crcutil-1.0.0/src/crcutil/util/__init__.py +0 -0
  36. crcutil-1.0.0/src/crcutil/util/crcutil_logger.py +47 -0
  37. crcutil-1.0.0/src/crcutil/util/file_importer.py +178 -0
  38. crcutil-1.0.0/src/crcutil/util/keyboard_monitor.py +28 -0
  39. crcutil-1.0.0/src/crcutil/util/static.py +7 -0
  40. crcutil-1.0.0/src/crcutil.egg-info/PKG-INFO +120 -0
  41. crcutil-1.0.0/src/crcutil.egg-info/SOURCES.txt +43 -0
  42. crcutil-1.0.0/src/crcutil.egg-info/dependency_links.txt +1 -0
  43. crcutil-1.0.0/src/crcutil.egg-info/entry_points.txt +2 -0
  44. crcutil-1.0.0/src/crcutil.egg-info/requires.txt +9 -0
  45. crcutil-1.0.0/src/crcutil.egg-info/top_level.txt +1 -0
@@ -0,0 +1,39 @@
1
+ # This workflow will upload a Python Package using Twine when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ deploy:
20
+
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v3
27
+ with:
28
+ python-version: '3.11.6'
29
+ - name: Install dependencies
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install build
33
+ - name: Build package
34
+ run: python -m build
35
+ - name: Publish package
36
+ uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37
+ with:
38
+ user: __token__
39
+ password: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,171 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
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
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # PyPI configuration file
171
+ .pypirc
crcutil-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CARLOS FLOREZ
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.
crcutil-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.2
2
+ Name: crcutil
3
+ Version: 1.0.0
4
+ Author-email: Carlos Florez <carlos@florez.co.uk>
5
+ Maintainer-email: Carlos Florez <carlos@florez.co.uk>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 CARLOS FLOREZ
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/florez-carlos/crcutil
29
+ Classifier: Development Status :: 5 - Production/Stable
30
+ Classifier: Programming Language :: Python :: 3.11
31
+ Requires-Python: >=3.11.6
32
+ Description-Content-Type: text/markdown
33
+ License-File: LICENSE
34
+ Requires-Dist: alive-progress==3.1.5
35
+ Requires-Dist: pyyaml==6.0.1
36
+ Requires-Dist: toml==0.10.2
37
+ Requires-Dist: pywin32==306; sys_platform == "win32"
38
+ Requires-Dist: jsonschema==4.23.0
39
+ Requires-Dist: colorlog==6.4.0
40
+ Requires-Dist: pynput==1.7.7
41
+
42
+ # CRCUtil
43
+ Recursively traverses a given location and generates a hash.json containing a CRC value for every encountered file/dir
44
+
45
+ > [!NOTE]
46
+ > Installation is supported only for the following:
47
+ > - Windows
48
+ > - Linux
49
+
50
+ > [!NOTE]
51
+ > Development requires a fully configured [Dotfiles](https://github.com/florez-carlos/dotfiles) dev environment <br>
52
+
53
+ ## Table of Contents
54
+
55
+ * [Installation](#installation)
56
+ * [pip](#pip)
57
+ * [Usage](#usage)
58
+ * [hash](#hash)
59
+ * [diff](#diff)
60
+ * [pause/resume](#pauseresume)
61
+ * [Development](#development)
62
+
63
+ ## Installation
64
+ ### Pip
65
+ ```bash
66
+ python3 -m pip install crcutil
67
+ ```
68
+
69
+ ## Usage
70
+
71
+ ### Hash
72
+
73
+ -l The location for which to generate the hash
74
+
75
+ ```bash
76
+ crcutil hash -l C:\DESIRED\PATH
77
+ ```
78
+ This will generate a hash.json file in: <br >
79
+ - Windows
80
+ ```bash
81
+ C:\Users\<USERNAME>\Documents\crcutil\
82
+ ```
83
+ - Linux
84
+ ```bash
85
+ $HOME/crcutil
86
+ ```
87
+ ### Diff
88
+ If you hold 2 hashes generated from the same directory and would like to compare the differences.
89
+
90
+ -l The location of both hash files to compare
91
+
92
+ ```bash
93
+ crcutil diff -l C:\HASH_FILE_1.json C:\HASH_FILE_2.json
94
+ ```
95
+
96
+ This will compare both hash files and generate a diff.json in:
97
+ - Windows
98
+ ```bash
99
+ C:\Users\<USERNAME>\Documents\crcutil\
100
+ ```
101
+ - Linux
102
+ ```bash
103
+ $HOME/crcutil
104
+ ```
105
+ ### Pause/Resume
106
+ - The program can be paused/resumed at any time by pressing p, if a CRC is being calculated for a file
107
+ you have to wait for the calculation to complete before the program can pause.
108
+ - If you exit the program or it crashes unexpectedly mid operation, invoke the same command and the program will continue where it left off,
109
+ as long as the hash file is not corrupted
110
+
111
+ ## Development
112
+
113
+ > [!NOTE]
114
+ > Development requires a fully configured [Dotfiles](https://github.com/florez-carlos/dotfiles) dev environment <br>
115
+
116
+ ```bash
117
+ source init.sh
118
+ ```
119
+
120
+
@@ -0,0 +1,79 @@
1
+ # CRCUtil
2
+ Recursively traverses a given location and generates a hash.json containing a CRC value for every encountered file/dir
3
+
4
+ > [!NOTE]
5
+ > Installation is supported only for the following:
6
+ > - Windows
7
+ > - Linux
8
+
9
+ > [!NOTE]
10
+ > Development requires a fully configured [Dotfiles](https://github.com/florez-carlos/dotfiles) dev environment <br>
11
+
12
+ ## Table of Contents
13
+
14
+ * [Installation](#installation)
15
+ * [pip](#pip)
16
+ * [Usage](#usage)
17
+ * [hash](#hash)
18
+ * [diff](#diff)
19
+ * [pause/resume](#pauseresume)
20
+ * [Development](#development)
21
+
22
+ ## Installation
23
+ ### Pip
24
+ ```bash
25
+ python3 -m pip install crcutil
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### Hash
31
+
32
+ -l The location for which to generate the hash
33
+
34
+ ```bash
35
+ crcutil hash -l C:\DESIRED\PATH
36
+ ```
37
+ This will generate a hash.json file in: <br >
38
+ - Windows
39
+ ```bash
40
+ C:\Users\<USERNAME>\Documents\crcutil\
41
+ ```
42
+ - Linux
43
+ ```bash
44
+ $HOME/crcutil
45
+ ```
46
+ ### Diff
47
+ If you hold 2 hashes generated from the same directory and would like to compare the differences.
48
+
49
+ -l The location of both hash files to compare
50
+
51
+ ```bash
52
+ crcutil diff -l C:\HASH_FILE_1.json C:\HASH_FILE_2.json
53
+ ```
54
+
55
+ This will compare both hash files and generate a diff.json in:
56
+ - Windows
57
+ ```bash
58
+ C:\Users\<USERNAME>\Documents\crcutil\
59
+ ```
60
+ - Linux
61
+ ```bash
62
+ $HOME/crcutil
63
+ ```
64
+ ### Pause/Resume
65
+ - The program can be paused/resumed at any time by pressing p, if a CRC is being calculated for a file
66
+ you have to wait for the calculation to complete before the program can pause.
67
+ - If you exit the program or it crashes unexpectedly mid operation, invoke the same command and the program will continue where it left off,
68
+ as long as the hash file is not corrupted
69
+
70
+ ## Development
71
+
72
+ > [!NOTE]
73
+ > Development requires a fully configured [Dotfiles](https://github.com/florez-carlos/dotfiles) dev environment <br>
74
+
75
+ ```bash
76
+ source init.sh
77
+ ```
78
+
79
+
File without changes
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ commit_msg=$(cat "${1:?Missing commit message file}")
4
+
5
+ if ! echo "$commit_msg" | grep -Eq "^(build|chore|ci|docs|feat|feat!|fix|perf|refactor|revert|style|test)(\(.+\))?: .*$" ; then
6
+ printf "%s\n" "Invalid commit message"
7
+
8
+ exit 1
9
+
10
+ fi
11
+
12
+ echo "Commit message is valid!"
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ shellcheck source.init.sh
3
+ ruff check --fix
4
+ ruff format
crcutil-1.0.0/init.sh ADDED
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+
3
+ color_red=$(tput setaf 1)
4
+ color_green=$(tput setaf 2)
5
+ color_yellow=$(tput setaf 3)
6
+ color_normal=$(tput sgr0)
7
+ setopt aliases
8
+
9
+
10
+ required_python_version_path_name="3.11"
11
+ required_python_version="3.11.6"
12
+
13
+ if [ $UID -eq 0 ]; then
14
+ printf "%s\n" "${color_red}ERROR:${color_normal}Please DO NOT run this script with sudo"
15
+ return 1
16
+ fi
17
+
18
+ cp git-hooks/commit-msg ./.git/hooks
19
+ cp git-hooks/pre-commit ./.git/hooks
20
+
21
+ current_python_version=$(python -V | sed 's/Python //;s/+//')
22
+ if ! dpkg --compare-versions "$current_python_version" eq "$required_python_version";then
23
+ printf "%s\n" ""
24
+ printf "%s\n" "${color_red}ERROR${color_normal}: Current Python is $current_python_version but $required_python_version required"
25
+ printf "%s\n" ""
26
+ return 1
27
+ fi
28
+
29
+ python -m venv "$HOME"/venv/crcutil
30
+ # shellcheck source=/dev/null
31
+ . "$HOME"/venv/crcutil/bin/activate
32
+ if [ "$VIRTUAL_ENV" != "$HOME"/venv/crcutil ]; then
33
+ printf "%s\n" ""
34
+ printf "%s\n" "${color_red}ERROR${color_normal}: Attempted to set venv to: $HOME/venv/crcutil but current venv is $VIRTUAL_ENV"
35
+ printf "%s\n" ""
36
+ return 1
37
+ fi
38
+ pip install -r requirements.txt
39
+
40
+ export PYTHONPATH=$VIRTUAL_ENV/lib/python"$required_python_version_path_name"/site-packages/
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=71.1.0","setuptools_scm>=8"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "crcutil"
7
+ version = "1.0.0"
8
+ requires-python = ">=3.11.6"
9
+ authors = [
10
+ {name = "Carlos Florez", email = "carlos@florez.co.uk"}
11
+ ]
12
+ maintainers = [
13
+ {name = "Carlos Florez", email = "carlos@florez.co.uk"}
14
+ ]
15
+ description = ""
16
+ readme = "README.md"
17
+ license = {file = "LICENSE"}
18
+ classifiers = [
19
+ "Development Status :: 5 - Production/Stable",
20
+ "Programming Language :: Python :: 3.11",
21
+ ]
22
+ dependencies = [
23
+ "alive-progress==3.1.5",
24
+ "pyyaml==6.0.1",
25
+ "toml==0.10.2",
26
+ "pywin32==306;sys_platform == 'win32'",
27
+ "jsonschema==4.23.0",
28
+ "colorlog==6.4.0",
29
+ "pynput==1.7.7"
30
+ ]
31
+
32
+ [project.scripts]
33
+ crcutil = "crcutil.__main__:main"
34
+
35
+ [project.urls]
36
+ Repository = "https://github.com/florez-carlos/crcutil"
@@ -0,0 +1,7 @@
1
+ alive-progress==3.1.5
2
+ pyyaml==6.0.1
3
+ toml==0.10.2
4
+ pywin32==306;sys_platform == 'win32'
5
+ jsonschema==4.23.0
6
+ colorlog==6.4.0
7
+ pynput==1.7.7
@@ -0,0 +1,40 @@
1
+ line-length = 79
2
+ indent-width = 4
3
+
4
+ [lint]
5
+ select = ["ALL"]
6
+ ignore = ["D",
7
+ "C901",
8
+ "T201",
9
+ "PLR0912",
10
+ "PLR0913",
11
+ "PLR0915",
12
+ "SLF001",
13
+ "FBT",
14
+ "W191",
15
+ "E111",
16
+ "E114",
17
+ "E117",
18
+ "D206",
19
+ "D300",
20
+ "Q000",
21
+ "Q001",
22
+ "Q002",
23
+ "Q003",
24
+ "COM812",
25
+ "COM819",
26
+ "ISC001",
27
+ "ISC002",
28
+ "TRY003",
29
+ "TRY004",
30
+ "TRY300",
31
+ "RET505",
32
+ "RET506",
33
+ ]
34
+ # select = ["E4", "E7", "E9", "F", "B", "Q"]
35
+ # extend-select = ["E501"]
36
+
37
+ [format]
38
+ quote-style = "double"
39
+ indent-style = "space"
40
+ line-ending = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,112 @@
1
+ import json
2
+ import sys
3
+
4
+ from jsonschema.exceptions import ValidationError
5
+
6
+ from crcutil.core.crc import Crc
7
+ from crcutil.core.prompt import Prompt
8
+ from crcutil.exception.bootstrap_error import BootstrapError
9
+ from crcutil.exception.corrupt_hash_error import CorruptHashError
10
+ from crcutil.exception.unexpected_argument_error import UnexpectedArgumentError
11
+ from crcutil.exception.user_error import UserError
12
+ from crcutil.util.crcutil_logger import CrcutilLogger
13
+ from crcutil.util.file_importer import FileImporter
14
+
15
+
16
+ def main() -> None:
17
+ try:
18
+ bootstrap_paths_dto = FileImporter.bootstrap()
19
+
20
+ log_dir = bootstrap_paths_dto.log_dir
21
+ hash_file_location = bootstrap_paths_dto.hash_file
22
+ report_file_location = bootstrap_paths_dto.report_file
23
+
24
+ log_config_file_path = (
25
+ FileImporter.get_project_root()
26
+ / "crcutil"
27
+ / "config"
28
+ / "log_config.yaml"
29
+ )
30
+
31
+ log_config = FileImporter.get_logging_config(log_config_file_path)
32
+
33
+ CrcutilLogger(log_dir, log_config)
34
+
35
+ instructions_dto = Prompt.get_user_instructions_dto()
36
+ location = instructions_dto.location
37
+ user_request = instructions_dto.request
38
+ hash_diff_files = instructions_dto.hash_diff_files
39
+ hash_diff_dtos = []
40
+ if hash_diff_files:
41
+ hash_diff_dtos = [
42
+ FileImporter.get_hash(x) for x in hash_diff_files
43
+ ]
44
+
45
+ crc_obj = Crc(
46
+ location=location,
47
+ hash_file_location=hash_file_location,
48
+ user_request=user_request,
49
+ hash_diff_1=hash_diff_dtos[0] if hash_diff_dtos else [],
50
+ hash_diff_2=hash_diff_dtos[1] if hash_diff_dtos else [],
51
+ )
52
+ hash_diff_report = crc_obj.do()
53
+ if hash_diff_report:
54
+ FileImporter.save_hash_diff_report(
55
+ report_file_location, hash_diff_report
56
+ )
57
+
58
+ sys.exit(0)
59
+
60
+ except SystemExit as e:
61
+ if e.code == 0:
62
+ description = "Successful System Exit"
63
+ CrcutilLogger.get_logger().debug(description)
64
+ else:
65
+ description = "\n=====Unexpected Error=====\n" f"{e!s}"
66
+ CrcutilLogger.get_logger().exception(description)
67
+ raise
68
+
69
+ except UnexpectedArgumentError as e:
70
+ sys.tracebacklimit = 0
71
+ description = (
72
+ "\n=====User Argument Error=====\n"
73
+ "These arguments are unrecognized: \n"
74
+ )
75
+ for argument in e.args[0]:
76
+ description += "-> " + argument + "\n"
77
+ CrcutilLogger.get_logger().error(description)
78
+ sys.exit(1)
79
+
80
+ except UserError as e:
81
+ sys.tracebacklimit = 0
82
+ description = "\n=====User Error=====\n" f"{e!s}"
83
+ CrcutilLogger.get_logger().error(description)
84
+
85
+ except CorruptHashError as e:
86
+ sys.tracebacklimit = 0
87
+ description = "\n=====Corrupt Hash Error=====\n" f"{e!s}"
88
+ CrcutilLogger.get_logger().error(description)
89
+
90
+ except json.decoder.JSONDecodeError as e:
91
+ sys.tracebacklimit = 0
92
+ description = "\n=====Corrupt Hash Error=====\n" f"{e!s}"
93
+ CrcutilLogger.get_logger().error(description)
94
+
95
+ except ValidationError as e:
96
+ sys.tracebacklimit = 0
97
+ description = "\n=====Invalid Schema Error=====\n" f"{e!s}"
98
+ CrcutilLogger.get_logger().error(description)
99
+
100
+ # No regular logger can be expected to be initialized
101
+ except BootstrapError as e:
102
+ description = "\n=====Program Initialization Error=====\n" f"{e!s}"
103
+ e.args = (description,)
104
+ raise
105
+
106
+ except Exception as e: # noqa: BLE001
107
+ description = "\n=====Unexpected Error=====\n" f"{e!s}"
108
+ CrcutilLogger.get_logger().exception(description)
109
+
110
+
111
+ if __name__ == "__main__":
112
+ main()