A modular Python toolkit for defensive programming, parameter validation, file system utilities, and flexible data structure manipulation. Provides helpers for error propagation, input validation, concurrency limits, safe directory creation, dynamic module loading, string extraction from nested structures, and dictionary merging.
Project description
hunterMakesPy
A modular Python toolkit for defensive programming, parameter validation, file system utilities, and flexible data structure manipulation.
Overview
hunterMakesPy provides utilities for safe error handling, flexible input validation, dynamic module and attribute importing, and merging or transforming complex data structures. The package emphasizes clear identifiers, robust type handling, and reusable components for building reliable Python applications.
Installation
pip install hunterMakesPy
Defensive Programming
Utilities for handling None values and defensive programming patterns.
from hunterMakesPy import raiseIfNone
# Ensure a function result is not None
def findConfiguration(configName: str) -> dict[str, str] | None:
# ... search logic ...
return None
config = raiseIfNone(
findConfiguration("database"),
"Configuration 'database' is required but not found"
)
Parameter Validation
Parameter validation, integer parsing, and concurrency handling.
from hunterMakesPy import defineConcurrencyLimit, intInnit, oopsieKwargsie
# Smart concurrency limit calculation
cpuLimit = defineConcurrencyLimit(limit=0.75) # Use 75% of available CPUs
cpuLimit = defineConcurrencyLimit(limit=True) # Use exactly 1 CPU
cpuLimit = defineConcurrencyLimit(limit=4) # Use exactly 4 CPUs
# Robust integer validation
validatedIntegers = intInnit([1, "2", 3.0, "4"], "port_numbers")
# String-to-boolean conversion for configuration
userInput = "True"
booleanValue = oopsieKwargsie(userInput) # Returns True
File System Utilities
Safe file operations and dynamic module importing.
from hunterMakesPy import (
importLogicalPath2Identifier,
importPathFilename2Identifier,
makeDirsSafely,
writeStringToHere
)
# Dynamic imports
gcdFunction = importLogicalPath2Identifier("math", "gcd")
customFunction = importPathFilename2Identifier("path/to/module.py", "functionName")
# Safe file operations
pathFilename = Path("deep/nested/directory/file.txt")
writeStringToHere("content", pathFilename) # Creates directories automatically
Data Structure Manipulation
Utilities for string extraction, data flattening, and array compression.
from hunterMakesPy import stringItUp, updateExtendPolishDictionaryLists, autoDecodingRLE
import numpy
# Extract all strings from nested data structures
nestedData = {"config": [1, "host", {"port": 8080}], "users": ["alice", "bob"]}
allStrings = stringItUp(nestedData) # ['config', 'host', 'port', 'users', 'alice', 'bob']
# Merge dictionaries containing lists
dictionaryAlpha = {"servers": ["web1", "web2"], "databases": ["db1"]}
dictionaryBeta = {"servers": ["web3"], "databases": ["db2", "db3"]}
merged = updateExtendPolishDictionaryLists(dictionaryAlpha, dictionaryBeta, destroyDuplicates=True)
# Compress NumPy arrays with run-length encoding
arrayData = numpy.array([1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9])
compressed = autoDecodingRLE(arrayData) # "[1,*range(2,6)]+[5]*2+[*range(6,10)]"
Testing
The package includes comprehensive test suites that you can import and run:
from hunterMakesPy.pytestForYourUse import (
PytestFor_defineConcurrencyLimit,
PytestFor_intInnit,
PytestFor_oopsieKwargsie
)
# Run tests on the built-in functions
listOfTests = PytestFor_defineConcurrencyLimit()
for nameOfTest, callablePytest in listOfTests:
callablePytest()
# Or test your own compatible functions
@pytest.mark.parametrize("nameOfTest,callablePytest",
PytestFor_intInnit(callableToTest=myFunction))
def test_myFunction(nameOfTest, callablePytest):
callablePytest()
My recovery
How to code
Coding One Step at a Time:
- WRITE CODE.
- Don't write stupid code that's hard to revise.
- Write good code.
- When revising, write better code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file huntermakespy-0.1.1.tar.gz.
File metadata
- Download URL: huntermakespy-0.1.1.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e313c288991b30ab15f77b0ce58f29b0dca353dd14f7a16f74e52e15c8ab4563
|
|
| MD5 |
dcc7bd8610daae30d29b7f2eba579bcc
|
|
| BLAKE2b-256 |
b9a97ffd0b1300efba318f928ea95bcbb493fd7bb73681f96a849669f912fc2e
|
Provenance
The following attestation bundles were made for huntermakespy-0.1.1.tar.gz:
Publisher:
pypiRelease.yml on hunterhogan/hunterMakesPy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
huntermakespy-0.1.1.tar.gz -
Subject digest:
e313c288991b30ab15f77b0ce58f29b0dca353dd14f7a16f74e52e15c8ab4563 - Sigstore transparency entry: 264955362
- Sigstore integration time:
-
Permalink:
hunterhogan/hunterMakesPy@52db7fed58cc63d5ce9b2e3c6828e7aa2f497e2b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hunterhogan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypiRelease.yml@52db7fed58cc63d5ce9b2e3c6828e7aa2f497e2b -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file huntermakespy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: huntermakespy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5735ab670e65a4b50c0d29d1bed485ff7e95deb1f3fbd04d4c1e779c67f1ff48
|
|
| MD5 |
5f6dc4f694a30dcc5577d5f92c999669
|
|
| BLAKE2b-256 |
bed716fa866f73291f8ce788f58af4997212393f50c5a50e3b01b1c292eebe34
|
Provenance
The following attestation bundles were made for huntermakespy-0.1.1-py3-none-any.whl:
Publisher:
pypiRelease.yml on hunterhogan/hunterMakesPy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
huntermakespy-0.1.1-py3-none-any.whl -
Subject digest:
5735ab670e65a4b50c0d29d1bed485ff7e95deb1f3fbd04d4c1e779c67f1ff48 - Sigstore transparency entry: 264955367
- Sigstore integration time:
-
Permalink:
hunterhogan/hunterMakesPy@52db7fed58cc63d5ce9b2e3c6828e7aa2f497e2b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hunterhogan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypiRelease.yml@52db7fed58cc63d5ce9b2e3c6828e7aa2f497e2b -
Trigger Event:
workflow_run
-
Statement type: