Easy Python functions making making functional Python functions easier.
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"),
"I could not find Configuration 'database', but I need it to continue."
)
Parameter Validation
Parameter validation, integer parsing, and concurrency handling.
import hunterMakesPy as humpy
# Smart concurrency limit calculation
cpuLimit = humpy.defineConcurrencyLimit(limit=0.75) # Use 75% of available CPUs
cpuLimit = humpy.defineConcurrencyLimit(limit=True) # Use exactly 1 CPU
cpuLimit = humpy.defineConcurrencyLimit(limit=4) # Use exactly 4 CPUs
# Robust integer validation
validatedIntegers = humpy.intInnit([1, "2", 3.0, "4"], "port_numbers")
# String-to-boolean conversion for configuration
userInput = "True"
booleanValue = humpy.oopsieKwargsie(userInput) # Returns True
File System Utilities
Safe file operations and dynamic module importing.
import hunterMakesPy as humpy
# Dynamic imports
gcdFunction = humpy.importLogicalPath2Identifier("math", "gcd")
customFunction = humpy.importPathFilename2Identifier("path/to/module.py", "functionName")
# Safe file operations
pathFilename = Path("deep/nested/directory/file.txt")
humpy.writeStringToHere("content", pathFilename) # Creates directories automatically
Data Structure Manipulation
Utilities for string extraction, data flattening, and array compression.
import hunterMakesPy as humpy
import numpy
# Extract all strings from nested data structures
nestedData = {"config": [1, "host", {"port": 8080}], "users": ["alice", "bob"]}
allStrings = humpy.stringItUp(nestedData) # ['config', 'host', 'port', 'users', 'alice', 'bob']
# Merge dictionaries containing lists
dictionaryAlpha = {"servers": ["chicago", "tokyo"], "databases": ["elm"]}
dictionaryBeta = {"servers": ["mumbai"], "databases": ["oak", "cedar"]}
merged = humpy.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 = humpy.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.tests.test_parseParameters 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
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.3.3.tar.gz.
File metadata
- Download URL: huntermakespy-0.3.3.tar.gz
- Upload date:
- Size: 37.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c30e9059ff0a68206a3d1dd2b99aaf17d196cadb924fa14c0ad005f8c0ae273
|
|
| MD5 |
2f8a19d241730351ce93087846dd0544
|
|
| BLAKE2b-256 |
e7b622b082120eb501c4752fcadad773097207ceb678547e382141dc5c370e50
|
Provenance
The following attestation bundles were made for huntermakespy-0.3.3.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.3.3.tar.gz -
Subject digest:
6c30e9059ff0a68206a3d1dd2b99aaf17d196cadb924fa14c0ad005f8c0ae273 - Sigstore transparency entry: 824169575
- Sigstore integration time:
-
Permalink:
hunterhogan/hunterMakesPy@8b796e42ce5207ef8b1328ce98be17be535cdb1f -
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@8b796e42ce5207ef8b1328ce98be17be535cdb1f -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file huntermakespy-0.3.3-py3-none-any.whl.
File metadata
- Download URL: huntermakespy-0.3.3-py3-none-any.whl
- Upload date:
- Size: 40.0 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 |
9587942dbe6b4aa14b1328fb254ca62c20b3c4e20a77f20fba674f92d83dd97e
|
|
| MD5 |
446a9af62914ca679424477e526343dd
|
|
| BLAKE2b-256 |
e1254670ad817ae2457f0e62fa8b6744e6940c6ac7611210fd0b750b16c4ce17
|
Provenance
The following attestation bundles were made for huntermakespy-0.3.3-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.3.3-py3-none-any.whl -
Subject digest:
9587942dbe6b4aa14b1328fb254ca62c20b3c4e20a77f20fba674f92d83dd97e - Sigstore transparency entry: 824169650
- Sigstore integration time:
-
Permalink:
hunterhogan/hunterMakesPy@8b796e42ce5207ef8b1328ce98be17be535cdb1f -
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@8b796e42ce5207ef8b1328ce98be17be535cdb1f -
Trigger Event:
workflow_run
-
Statement type: