filedgr-pkg-utils 0.8.4__tar.gz → 0.9.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.
- filedgr_pkg_utils-0.9.0/.github/dependabot.yml +13 -0
- filedgr_pkg_utils-0.9.0/.github/workflows/ci.yml +41 -0
- filedgr_pkg_utils-0.9.0/.github/workflows/pr-iso-compliance.yml +45 -0
- filedgr_pkg_utils-0.9.0/.github/workflows/release.yml +104 -0
- filedgr_pkg_utils-0.9.0/.gitignore +14 -0
- filedgr_pkg_utils-0.9.0/LICENSE +21 -0
- filedgr_pkg_utils-0.9.0/Makefile +55 -0
- filedgr_pkg_utils-0.9.0/PKG-INFO +219 -0
- filedgr_pkg_utils-0.9.0/README.md +176 -0
- filedgr_pkg_utils-0.9.0/pyproject.toml +83 -0
- filedgr_pkg_utils-0.9.0/requirements-test.txt +6 -0
- filedgr_pkg_utils-0.9.0/requirements.txt +25 -0
- filedgr_pkg_utils-0.9.0/scripts/next_version.py +129 -0
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/__init__.py +8 -0
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/_optional.py +24 -0
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/caching/memoize.py +201 -0
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/canonicalization/__init__.py +25 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/canonicalization/canonical_json_mixin.py +21 -3
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/canonicalization/canonical_json_mixin_v2.py +113 -0
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/compression/__init__.py +29 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/compression/algorithms/compression_algorithm_brotli.py +3 -1
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/compression/algorithms/compression_algorithm_zstd.py +3 -1
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/cryptography/hashing/conversion_utils.py +12 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/cryptography/hashing/hash_algorithm.py +10 -4
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/cryptography/signing/__init__.py +29 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/cryptography/signing/secp256k1_evm_signature_algorithm.py +3 -1
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/cryptography/signing/secp256k1_signature_algorithm.py +8 -4
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/filesystem/atomic.py +3 -1
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/fldgr_logging/structured_logger.py +33 -10
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/hooks/decorators.py +77 -21
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/images/hashing/__init__.py +28 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/images/hashing/algorithms/image_hashing_algorithm_ahash.py +3 -14
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/images/hashing/algorithms/image_hashing_algorithm_dhash.py +3 -14
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/images/hashing/algorithms/image_hashing_algorithm_phash.py +3 -14
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/resilience/__init__.py +2 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/resilience/decorators.py +105 -47
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/security/sanitizer.py +91 -0
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils.egg-info/PKG-INFO +219 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils.egg-info/SOURCES.txt +49 -1
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils.egg-info/requires.txt +22 -8
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils.egg-info/scm_file_list.json +105 -0
- filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils.egg-info/scm_version.json +8 -0
- filedgr_pkg_utils-0.9.0/tests/caching/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/caching/test_memoize.py +405 -0
- filedgr_pkg_utils-0.9.0/tests/canonicalization/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/canonicalization/test_canonical_json_mixin.py +186 -0
- filedgr_pkg_utils-0.9.0/tests/canonicalization/test_canonical_json_mixin_v2.py +209 -0
- filedgr_pkg_utils-0.9.0/tests/compression/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/compression/test_compression.py +150 -0
- filedgr_pkg_utils-0.9.0/tests/converters/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/converters/test_converters.py +29 -0
- filedgr_pkg_utils-0.9.0/tests/crypto/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/crypto/hash_test.txt +4 -0
- filedgr_pkg_utils-0.9.0/tests/crypto/test_cryptography.py +56 -0
- filedgr_pkg_utils-0.9.0/tests/crypto/test_hashing.py +79 -0
- filedgr_pkg_utils-0.9.0/tests/filesystem/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/filesystem/test_atomic.py +98 -0
- filedgr_pkg_utils-0.9.0/tests/filesystem/test_tar_utils.py +94 -0
- filedgr_pkg_utils-0.9.0/tests/fldgr_logging/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/fldgr_logging/test_structured_logger.py +160 -0
- filedgr_pkg_utils-0.9.0/tests/hooks/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/hooks/test_decorators.py +367 -0
- filedgr_pkg_utils-0.9.0/tests/images/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/images/hashing/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/images/hashing/test_image_hash.py +114 -0
- filedgr_pkg_utils-0.9.0/tests/mixins/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/mixins/test_without_keys_mixin.py +17 -0
- filedgr_pkg_utils-0.9.0/tests/packaging/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/packaging/test_next_version.py +91 -0
- filedgr_pkg_utils-0.9.0/tests/packaging/test_optional_extras.py +154 -0
- filedgr_pkg_utils-0.9.0/tests/resilience/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/resilience/test_decorators.py +248 -0
- filedgr_pkg_utils-0.9.0/tests/security/__init__.py +0 -0
- filedgr_pkg_utils-0.9.0/tests/security/test_sanitize.py +138 -0
- filedgr_pkg_utils-0.9.0/tests/security/test_sanitizer_decorators.py +27 -0
- filedgr_pkg_utils-0.8.4/PKG-INFO +0 -171
- filedgr_pkg_utils-0.8.4/README.md +0 -138
- filedgr_pkg_utils-0.8.4/pyproject.toml +0 -64
- filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/__init__.py +0 -1
- filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/caching/memoize.py +0 -54
- filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/compression/__init__.py +0 -7
- filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/cryptography/hashing/conversion_utils.py +0 -4
- filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/cryptography/signing/__init__.py +0 -6
- filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/images/hashing/__init__.py +0 -6
- filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/security/sanitizer.py +0 -60
- filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils.egg-info/PKG-INFO +0 -171
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/setup.cfg +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/caching/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/canonicalization → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/compression/algorithms}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/compression/algorithms/compression_algorithm_zip.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/compression/algorithms/compression_algortihm_gzip.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/compression/compression_algorithm.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/compression/compression_utils.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/compression/algorithms → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/converters}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/converters/abstract_converter.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/converters → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/cryptography}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/cryptography → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/cryptography/hashing}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/cryptography/hashing/hash_utils.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/cryptography/signing/conversion_utils.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/cryptography/signing/hmac_signature_algorithm.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/cryptography/signing/signature_algorithm.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/cryptography/signing/signature_utils.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/evm/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/evm/hex_utils.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/filesystem/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/filesystem/tar_utils.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/fldgr_logging/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/fldgr_logging/sanitizer_logger_adapter.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/cryptography/hashing → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/hooks}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/hooks → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/images}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/images → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/images/hashing/algorithms}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/images/hashing/image_hash_algorithm.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/images/hashing/image_hash_utils.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/images/hashing/algorithms → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/mixins}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/mixins/without_keys_mixin.py +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/mixins → filedgr_pkg_utils-0.9.0/src/filedgr_pkg_utils/security}/__init__.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils/security/sanitizer_decorators.py +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils.egg-info/dependency_links.txt +0 -0
- {filedgr_pkg_utils-0.8.4 → filedgr_pkg_utils-0.9.0}/src/filedgr_pkg_utils.egg-info/top_level.txt +0 -0
- {filedgr_pkg_utils-0.8.4/src/filedgr_pkg_utils/security → filedgr_pkg_utils-0.9.0/tests}/__init__.py +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Dependabot configuration — minimal security-focused mode.
|
|
2
|
+
#
|
|
3
|
+
# Routine version updates are kept enabled but rate-limited to one open PR
|
|
4
|
+
# at a time (`open-pull-requests-limit: 1`) and only checked monthly.
|
|
5
|
+
# Dependabot SECURITY-update PRs are NOT subject to this limit; they fire
|
|
6
|
+
# automatically based on the repo's "Code security" settings.
|
|
7
|
+
version: 2
|
|
8
|
+
updates:
|
|
9
|
+
- package-ecosystem: "pip"
|
|
10
|
+
directory: "/"
|
|
11
|
+
schedule:
|
|
12
|
+
interval: "monthly"
|
|
13
|
+
open-pull-requests-limit: 1
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: CI - Checks & Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
# Read-only: this workflow must never push to the PR branch. A commit pushed by
|
|
9
|
+
# the workflow token starts no workflows, so it would become a PR head commit
|
|
10
|
+
# that required checks (iso-compliance) never report on, blocking the merge.
|
|
11
|
+
# The coverage badge is regenerated by the release workflow on main instead.
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
lint-and-test:
|
|
17
|
+
name: Lint & Test
|
|
18
|
+
runs-on: ubuntu-22.04
|
|
19
|
+
timeout-minutes: 15
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout Code
|
|
23
|
+
# Default ref for pull_request = the PR merged into main, i.e. what will be merged
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Setup Python
|
|
27
|
+
uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: '3.11'
|
|
30
|
+
cache: 'pip'
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
pip install -r requirements-test.txt
|
|
36
|
+
|
|
37
|
+
- name: Static Code Analysis (Lint)
|
|
38
|
+
run: make lint
|
|
39
|
+
|
|
40
|
+
- name: Run Tests with Coverage
|
|
41
|
+
run: make test-coverage
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: PR ISO Compliance
|
|
2
|
+
|
|
3
|
+
# ISO 27001 / SOC 2 control: enforce automated unit-test gate on every PR.
|
|
4
|
+
# Every PR must pass tests before it can be merged.
|
|
5
|
+
#
|
|
6
|
+
# The job name `iso-compliance` is the status-check context used by the
|
|
7
|
+
# org-level branch ruleset to require this check on every PR.
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
pull_request:
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
iso-compliance:
|
|
17
|
+
name: iso-compliance
|
|
18
|
+
runs-on: ubuntu-22.04
|
|
19
|
+
timeout-minutes: 15
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout code
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Python 3.12
|
|
25
|
+
uses: actions/setup-python@v6
|
|
26
|
+
with:
|
|
27
|
+
python-version: '3.12'
|
|
28
|
+
cache: 'pip'
|
|
29
|
+
|
|
30
|
+
- name: Cache venv
|
|
31
|
+
id: cache-venv
|
|
32
|
+
uses: actions/cache@v4
|
|
33
|
+
with:
|
|
34
|
+
path: .venv
|
|
35
|
+
key: venv-${{ runner.os }}-py3.12-${{ hashFiles('requirements.txt', 'requirements-test.txt') }}
|
|
36
|
+
|
|
37
|
+
- name: Install dependencies
|
|
38
|
+
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
39
|
+
run: |
|
|
40
|
+
python -m venv .venv
|
|
41
|
+
.venv/bin/pip install --upgrade pip
|
|
42
|
+
.venv/bin/pip install -r requirements-test.txt
|
|
43
|
+
|
|
44
|
+
- name: Run unit tests
|
|
45
|
+
run: .venv/bin/pytest tests
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
name: CD - Version & Publish
|
|
2
|
+
|
|
3
|
+
# Tag-based releases: nothing is committed to the repository. The released
|
|
4
|
+
# commit is tagged vX.Y.Z and the package version is taken from that tag at
|
|
5
|
+
# build time (setuptools-scm). This keeps main changeable only through reviewed
|
|
6
|
+
# pull requests, as its branch rules require.
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
- 'feature/*'
|
|
13
|
+
- 'bugfix/*'
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: write # Needed to push the release tag
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
release:
|
|
20
|
+
name: Tag and Publish
|
|
21
|
+
runs-on: ubuntu-22.04
|
|
22
|
+
# ONLY run if the commit message contains a release keyword
|
|
23
|
+
if: |
|
|
24
|
+
contains(github.event.head_commit.message, '#patch') ||
|
|
25
|
+
contains(github.event.head_commit.message, '#minor') ||
|
|
26
|
+
contains(github.event.head_commit.message, '#major') ||
|
|
27
|
+
contains(github.event.head_commit.message, '#alpha') ||
|
|
28
|
+
contains(github.event.head_commit.message, '#final')
|
|
29
|
+
timeout-minutes: 15
|
|
30
|
+
|
|
31
|
+
steps:
|
|
32
|
+
- name: Checkout Code
|
|
33
|
+
uses: actions/checkout@v4
|
|
34
|
+
with:
|
|
35
|
+
# Full history and tags: needed to find the latest release and by setuptools-scm
|
|
36
|
+
fetch-depth: 0
|
|
37
|
+
|
|
38
|
+
- name: Setup Python
|
|
39
|
+
uses: actions/setup-python@v5
|
|
40
|
+
with:
|
|
41
|
+
python-version: '3.11'
|
|
42
|
+
cache: 'pip'
|
|
43
|
+
|
|
44
|
+
# Rules (see scripts/next_version.py): #alpha on any branch; #patch,
|
|
45
|
+
# #minor, #major and #final only on main. A re-run reuses the tag
|
|
46
|
+
# already on this commit instead of bumping again.
|
|
47
|
+
- name: Determine Version
|
|
48
|
+
id: version
|
|
49
|
+
env:
|
|
50
|
+
# Passed via env, never pasted into the script: commit messages are untrusted input
|
|
51
|
+
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
|
52
|
+
BRANCH: ${{ github.ref_name }}
|
|
53
|
+
run: python scripts/next_version.py >> "$GITHUB_OUTPUT"
|
|
54
|
+
|
|
55
|
+
- name: Run Tests
|
|
56
|
+
run: |
|
|
57
|
+
python -m pip install --upgrade pip
|
|
58
|
+
pip install -r requirements-test.txt
|
|
59
|
+
make test-coverage
|
|
60
|
+
|
|
61
|
+
- name: Tag Release Commit
|
|
62
|
+
env:
|
|
63
|
+
VERSION: ${{ steps.version.outputs.version }}
|
|
64
|
+
run: |
|
|
65
|
+
if git rev-parse -q --verify "refs/tags/v$VERSION" >/dev/null; then
|
|
66
|
+
echo "Tag v$VERSION already exists (re-run); reusing it."
|
|
67
|
+
else
|
|
68
|
+
git -c user.name="github-actions[bot]" \
|
|
69
|
+
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
|
|
70
|
+
tag -a "v$VERSION" -m "Release $VERSION"
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
- name: Build Package (sdist and wheel)
|
|
74
|
+
run: |
|
|
75
|
+
pip install build twine
|
|
76
|
+
python -m build
|
|
77
|
+
|
|
78
|
+
- name: Check Package Build
|
|
79
|
+
env:
|
|
80
|
+
VERSION: ${{ steps.version.outputs.version }}
|
|
81
|
+
run: |
|
|
82
|
+
twine check dist/*
|
|
83
|
+
# setuptools-scm must have picked up the tag exactly (no dev/local suffix)
|
|
84
|
+
ls dist/
|
|
85
|
+
test -f "dist/filedgr_pkg_utils-$VERSION-py3-none-any.whl"
|
|
86
|
+
test -f "dist/filedgr_pkg_utils-$VERSION.tar.gz"
|
|
87
|
+
|
|
88
|
+
# Pushed before publishing so a failed publish can be re-run with the same version.
|
|
89
|
+
- name: Push Release Tag
|
|
90
|
+
env:
|
|
91
|
+
VERSION: ${{ steps.version.outputs.version }}
|
|
92
|
+
run: |
|
|
93
|
+
if git ls-remote --exit-code --tags origin "refs/tags/v$VERSION" >/dev/null; then
|
|
94
|
+
echo "Tag v$VERSION is already on GitHub."
|
|
95
|
+
else
|
|
96
|
+
git push origin "refs/tags/v$VERSION"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
- name: Publish to PyPI
|
|
100
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
101
|
+
with:
|
|
102
|
+
user: __token__
|
|
103
|
+
password: ${{ secrets.PYPI_TOKEN }}
|
|
104
|
+
skip-existing: true
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Filedgr
|
|
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,55 @@
|
|
|
1
|
+
PROJECT_NAME = filedgr_pkg_utils
|
|
2
|
+
DATE ?= $(shell date +%FT%T%z)
|
|
3
|
+
MIN = 70
|
|
4
|
+
|
|
5
|
+
.PHONY: version package upload-package test-coverage lint clean help
|
|
6
|
+
|
|
7
|
+
# Helper to check if a CLI tool exists; if not, install its pip package.
|
|
8
|
+
define require_cmd
|
|
9
|
+
@command -v $(1) >/dev/null 2>&1 || { echo "Installing $(2)..."; pip install $(2); }
|
|
10
|
+
endef
|
|
11
|
+
|
|
12
|
+
# Helper to check if a Python module exists; if not, install its pip package.
|
|
13
|
+
define require_module
|
|
14
|
+
@python -c "import $(1)" 2>/dev/null || { echo "Installing $(2)..."; pip install $(2); }
|
|
15
|
+
endef
|
|
16
|
+
|
|
17
|
+
########## PACKAGING ##########
|
|
18
|
+
version: ## Show the version a build of this checkout gets (releases are git tags vX.Y.Z, created by CI)
|
|
19
|
+
$(call require_module,setuptools_scm,setuptools-scm)
|
|
20
|
+
@python -m setuptools_scm
|
|
21
|
+
|
|
22
|
+
package: ## Build the package
|
|
23
|
+
$(call require_module,build,build)
|
|
24
|
+
@python -m build
|
|
25
|
+
|
|
26
|
+
upload-package: ## Upload the package using twine
|
|
27
|
+
$(call require_cmd,twine,twine)
|
|
28
|
+
@twine upload --repository codeartifact dist/*
|
|
29
|
+
|
|
30
|
+
########## TESTING & BADGES ##########
|
|
31
|
+
test-coverage: ## Runs the coverage tests for the python package
|
|
32
|
+
$(call require_module,pytest,pytest)
|
|
33
|
+
@python -c "import pytest_cov" 2>/dev/null || pip install -r requirements-test.txt
|
|
34
|
+
@pytest tests --cov=src/filedgr_pkg_utils --cov-fail-under=${MIN} --cov-report term-missing
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
########## UTILITIES ##########
|
|
38
|
+
lint: ## Lint the codebase
|
|
39
|
+
$(call require_cmd,flake8,flake8)
|
|
40
|
+
@flake8 src
|
|
41
|
+
|
|
42
|
+
clean: ## Cleans the workspace
|
|
43
|
+
rm -rf .mypy_cache
|
|
44
|
+
rm -rf .pytest_cache
|
|
45
|
+
rm -rf dist
|
|
46
|
+
rm -f .coverage
|
|
47
|
+
rm -rf */*.egg-info
|
|
48
|
+
|
|
49
|
+
help: ## Show the help
|
|
50
|
+
@echo ""
|
|
51
|
+
@echo "usage: make <target>"
|
|
52
|
+
@echo ""
|
|
53
|
+
@echo "targets:"
|
|
54
|
+
@awk 'BEGIN {FS=":.*##"} /^[a-zA-Z0-9_-]+:.*##/ {printf " %-18s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
55
|
+
@echo ""
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: filedgr-pkg-utils
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: A library of python based utils needed in the filedgr code stack
|
|
5
|
+
Author-email: Filedgr <code@filedgr.com>
|
|
6
|
+
Project-URL: repository, https://github.com/Filedgr/filedgr-pkg-utils
|
|
7
|
+
Keywords: filedgr,pkg,utils
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Provides-Extra: canonical
|
|
15
|
+
Requires-Dist: pydantic<3.0.0,>=2.12.5; extra == "canonical"
|
|
16
|
+
Requires-Dist: orjson<4.0.0,>=3.11.5; extra == "canonical"
|
|
17
|
+
Requires-Dist: rfc8785<0.2.0,>=0.1.4; extra == "canonical"
|
|
18
|
+
Provides-Extra: crypto
|
|
19
|
+
Requires-Dist: cryptography<50.0.0,>=49.0.0; extra == "crypto"
|
|
20
|
+
Provides-Extra: evm
|
|
21
|
+
Requires-Dist: eth-account<1.0.0,>=0.13.6; extra == "evm"
|
|
22
|
+
Requires-Dist: eth-hash[pycryptodome]<1.0.0,>=0.7.0; extra == "evm"
|
|
23
|
+
Provides-Extra: compression
|
|
24
|
+
Requires-Dist: zstandard<1.0.0,>=0.22.0; extra == "compression"
|
|
25
|
+
Requires-Dist: Brotli<2.0.0,>=1.1.0; extra == "compression"
|
|
26
|
+
Provides-Extra: async
|
|
27
|
+
Requires-Dist: aiofiles<26.0.0,>=25.1.0; extra == "async"
|
|
28
|
+
Provides-Extra: images
|
|
29
|
+
Requires-Dist: ImageHash<5.0.0,>=4.3.0; extra == "images"
|
|
30
|
+
Requires-Dist: Pillow<14.0.0,>=13.0.0; extra == "images"
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Requires-Dist: filedgr-pkg-utils[async,canonical,compression,crypto,evm,images]; extra == "all"
|
|
33
|
+
Provides-Extra: build
|
|
34
|
+
Requires-Dist: build; extra == "build"
|
|
35
|
+
Requires-Dist: twine; extra == "build"
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: black; extra == "dev"
|
|
38
|
+
Requires-Dist: isort; extra == "dev"
|
|
39
|
+
Requires-Dist: mypy; extra == "dev"
|
|
40
|
+
Requires-Dist: pytest; extra == "dev"
|
|
41
|
+
Requires-Dist: flake8; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# filedgr-pkg-utils
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
[](https://github.com/Filedgr/filedgr-pkg-utils/tags)
|
|
48
|
+

|
|
49
|
+
[](https://pypi.org/project/filedgr-pkg-utils/)
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
A comprehensive, production-ready Python utility toolkit for modern distributed systems, Web3 integrations, and data-heavy microservices.
|
|
53
|
+
|
|
54
|
+
`filedgr-pkg-utils` provides a unified, protocol-driven API for cryptography, resilient networking, deterministic data serialization, compression, and structured logging.
|
|
55
|
+
|
|
56
|
+
## 📦 Installation
|
|
57
|
+
|
|
58
|
+
The base package has **no third-party dependencies**. Add extras for the features you use:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install filedgr-pkg-utils # base only
|
|
62
|
+
pip install "filedgr-pkg-utils[evm,compression]" # pick extras
|
|
63
|
+
pip install "filedgr-pkg-utils[all]" # everything
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| Extra | Installs | Enables |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| *(base)* | — | resilience & hook decorators, `ttl_cache`, PII sanitizer, JSON logging, atomic file writes, tar utils, EVM hex helpers, SHA-256/SHA-512/BLAKE2b hashing, HMAC signing, zip/gzip compression |
|
|
69
|
+
| `canonical` | pydantic, orjson, rfc8785 | `CanonicalJsonMixin`, `CanonicalJsonMixinV2` |
|
|
70
|
+
| `crypto` | cryptography | `Secp256k1Algorithm` |
|
|
71
|
+
| `evm` | eth-account, eth-hash | `Keccak256Algorithm`, `Secp256k1EvmAlgorithm` |
|
|
72
|
+
| `compression` | zstandard, Brotli | `ZstdAlgorithm`, `BrotliAlgorithm` |
|
|
73
|
+
| `async` | aiofiles | `async_atomic_write` |
|
|
74
|
+
| `images` | ImageHash, Pillow | perceptual image hashing |
|
|
75
|
+
| `all` | all of the above | everything |
|
|
76
|
+
|
|
77
|
+
Using a feature without its extra raises an `ImportError` that names the extra to install.
|
|
78
|
+
|
|
79
|
+
> **Upgrading from 0.8.x:** earlier versions installed pydantic, orjson, cryptography, web3, zstandard, Brotli and aiofiles by default. To keep the same features, depend on `filedgr-pkg-utils[all]`, or on just the extras you use. `web3` is no longer installed at all: the EVM features only need `eth-account` and `eth-hash`, so add `web3` to your own dependencies if your code imports it directly.
|
|
80
|
+
|
|
81
|
+
## 🚀 Prominent Features & Examples
|
|
82
|
+
|
|
83
|
+
### 1. Resilience & Aspect-Oriented Hooks
|
|
84
|
+
|
|
85
|
+
Stop writing try/except blocks with `time.sleep()`. Stack our context-aware decorators to build bulletproof network calls and clean up your business logic.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from filedgr_pkg_utils.resilience.decorators import retry, circuit_breaker, fallback
|
|
89
|
+
from filedgr_pkg_utils.hooks.decorators import post_action
|
|
90
|
+
|
|
91
|
+
def audit_log(result, *args, **kwargs):
|
|
92
|
+
print(f"Audit: Successfully fetched data {result}")
|
|
93
|
+
|
|
94
|
+
def serve_stale_data(*args, **kwargs):
|
|
95
|
+
return {"status": "stale", "data": []}
|
|
96
|
+
|
|
97
|
+
@post_action(callback=audit_log)
|
|
98
|
+
@fallback(fallback_function=serve_stale_data)
|
|
99
|
+
@circuit_breaker(failure_threshold=5, recovery_timeout_seconds=30)
|
|
100
|
+
@retry(max_attempts=3, backoff_multiplier=2.0)
|
|
101
|
+
async def fetch_web3_data(node_url: str):
|
|
102
|
+
# This function is completely protected.
|
|
103
|
+
# It will retry on failure, trip a circuit breaker if the node is down,
|
|
104
|
+
# serve stale data if all else fails, and log the result when successful.
|
|
105
|
+
pass
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 2. Unified Compression
|
|
109
|
+
|
|
110
|
+
A single, clean protocol for zip, gzip, zstd, and brotli. Easily swap algorithms without changing your application code.
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from filedgr_pkg_utils.compression import CompressionUtils, ZstdAlgorithm, ZipAlgorithm
|
|
114
|
+
|
|
115
|
+
# Swap from standard Zip to high-performance Zstd in one line
|
|
116
|
+
utils = CompressionUtils(ZstdAlgorithm(level=3))
|
|
117
|
+
|
|
118
|
+
# Compress bytes
|
|
119
|
+
compressed_data = utils.compress(b"Hello World")
|
|
120
|
+
|
|
121
|
+
# Compress files and directories
|
|
122
|
+
utils.compress_file("data.json", "data.json.zst")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 3. Canonical Serialization & Cryptography
|
|
126
|
+
|
|
127
|
+
Generate deterministic, whitespace-free, sorted-key JSON for verifiable hashes and signatures.
|
|
128
|
+
|
|
129
|
+
**Use `CanonicalJsonMixinV2` for new payloads.** It implements [RFC 8785 (JSON Canonicalization Scheme)](https://www.rfc-editor.org/rfc/rfc8785), so a verifier in any language with a JCS library rebuilds the same bytes. On top of the RFC, datetimes are always UTC, ISO 8601, millisecond precision, with a `Z` suffix.
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from datetime import datetime, timezone
|
|
133
|
+
from filedgr_pkg_utils.canonicalization import CanonicalJsonMixinV2
|
|
134
|
+
|
|
135
|
+
class BlockchainPayload(CanonicalJsonMixinV2):
|
|
136
|
+
z_field: str
|
|
137
|
+
a_field: float
|
|
138
|
+
timestamp: datetime
|
|
139
|
+
|
|
140
|
+
payload = BlockchainPayload(
|
|
141
|
+
z_field="last",
|
|
142
|
+
a_field=1.0,
|
|
143
|
+
timestamp=datetime(2023, 10, 25, 12, 30, 0, tzinfo=timezone.utc),
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
payload.canonical_json()
|
|
147
|
+
# {"a_field":1,"timestamp":"2023-10-25T12:30:00.000Z","z_field":"last"}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
V2 rejects (with `ValueError`) anything that can't be signed unambiguously: naive datetimes, `NaN`/infinity, and integers beyond ±2^53−1 (model large amounts such as wei as strings). Set `canonical_datetime_precision = "microseconds"` on a subclass to keep microseconds.
|
|
151
|
+
|
|
152
|
+
**`CanonicalJsonMixin` (V1) is frozen** so existing signatures keep verifying. Its datetimes use pydantic's format (`2023-10-25T12:30:00Z`, offsets kept as given) and floats keep `.0`, so it is not RFC 8785 compliant. Don't switch an existing payload type from V1 to V2 without re-signing: the bytes differ for every payload containing a datetime or a whole-number float. Recording the format version inside new signed payloads makes later migrations safe.
|
|
153
|
+
|
|
154
|
+
### 4. Zero-Config Structured JSON Logging
|
|
155
|
+
|
|
156
|
+
Output logs as deterministic JSON for flawless Datadog or AWS CloudWatch ingestion. Fully integrates with Python's standard logging library.
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from filedgr_pkg_utils.fldgr_logging import LoggerFactory
|
|
160
|
+
|
|
161
|
+
logger = LoggerFactory.get_logger(__name__)
|
|
162
|
+
|
|
163
|
+
logger.info("Processing file", extra={"file_id": "ABC-123", "access_token": "abc"})
|
|
164
|
+
# Output: {"timestamp": "2026-05-14T12:00:00.000Z", "level": "INFO", "logger": "__main__", "message": "Processing file", "file_id": "ABC-123", "access_token": "*****"}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
| Parameter | Environment variable | Default | Effect |
|
|
168
|
+
|---|---|---|---|
|
|
169
|
+
| `sanitize_pii` | `FILEDGR_SANITIZE_LOGS` | `true` | Masks sensitive keys (tokens, passwords, API keys, ...) in `extra`. |
|
|
170
|
+
| `propagate` | `FILEDGR_LOG_PROPAGATE` | unchanged (`true`) | Set to `false` where the platform adds its own root handler (e.g. AWS Lambda) so lines aren't logged twice. |
|
|
171
|
+
|
|
172
|
+
An explicit parameter always overrides the environment variable.
|
|
173
|
+
|
|
174
|
+
### 5. Perceptual Image Hashing (Optional)
|
|
175
|
+
|
|
176
|
+
Detect visually similar images, compression artifacts, and resized duplicates using Hamming distance.
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from filedgr_pkg_utils.images.hashing import PHashAlgorithm, ImageHashUtils
|
|
180
|
+
|
|
181
|
+
utils = ImageHashUtils(PHashAlgorithm())
|
|
182
|
+
|
|
183
|
+
hash_orig = utils.hash_image("original.png")
|
|
184
|
+
hash_comp = utils.hash_image("compressed_artifact.jpg")
|
|
185
|
+
|
|
186
|
+
if utils.is_similar(hash_orig, hash_comp, max_distance=5):
|
|
187
|
+
print("These images are visually similar!")
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## 🛠️ Development & Testing
|
|
191
|
+
|
|
192
|
+
This project enforces high coverage and clean coding standards.
|
|
193
|
+
|
|
194
|
+
To run the test suite with coverage:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
make test-coverage
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
To run the linter:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
make lint
|
|
204
|
+
```
|
|
205
|
+
## 🚢 Releasing
|
|
206
|
+
|
|
207
|
+
Releases are git tags; nothing is committed to `main` by CI. When a commit whose message contains a release keyword lands on a branch, the release workflow runs the tests, tags that commit `vX.Y.Z`, builds the package with that version and publishes it to PyPI.
|
|
208
|
+
|
|
209
|
+
| Keyword | Result (from latest `v0.9.0`) | Allowed on |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| `#patch` | `0.9.1` | `main` |
|
|
212
|
+
| `#minor` | `0.10.0` | `main` |
|
|
213
|
+
| `#major` | `1.0.0` | `main` |
|
|
214
|
+
| `#alpha` | `0.9.1a1`, then `0.9.1a2`, … | any release branch (`main`, `feature/*`, `bugfix/*`) |
|
|
215
|
+
| `#final` | promotes the latest alpha, e.g. `0.9.1a2` → `0.9.1` | `main` |
|
|
216
|
+
|
|
217
|
+
The workflow reads the message of the commit that lands on the branch. With "Create a merge commit", put the keyword in the **pull request title**; with "Squash and merge" or "Rebase and merge" it can also be in a commit message.
|
|
218
|
+
|
|
219
|
+
If a release fails after tagging (e.g. at the PyPI upload), re-run the failed job: it reuses the existing tag instead of bumping again. `make version` shows the version a build of your checkout would get.
|