Skip to main content

Easy Python functions making making functional Python functions easier.

Project description

hunterMakesPy

Utilities for converting mixed input to integers, calculating CPU limits, handling None values, importing code dynamically, and manipulating nested data.

pip install hunterMakesPy

Validate, Convert, and Parse Inputs

Convert Mixed Input to Validated Integers

Accepts strings, floats, complex numbers, and binary data and returns a list of validated integers. Ambiguous or incompatible values produce descriptive errors.

from hunterMakesPy.parseParameters import intInnit

ports = intInnit(["8080", 443, "22"], "server_ports")
# Returns: [8080, 443, 22]

Calculate Concurrency Limits from Flexible Specifications

Pass 0.75 for 75% of CPUs, True for 1 CPU, 4 for exactly 4 CPUs, or -2 to reserve 2 CPUs.

from hunterMakesPy.parseParameters import defineConcurrencyLimit

workers = defineConcurrencyLimit(limit=0.75)  # 6 on an 8-core machine

Interpret Strings as Boolean or None

Parse string values such as "true", "false", or "none" into their Python equivalents without raising exceptions on mismatch.

from hunterMakesPy.parseParameters import oopsieKwargsie

oopsieKwargsie("True")   # Returns: True
oopsieKwargsie("none")   # Returns: None
oopsieKwargsie("hello")  # Returns: "hello"

Eliminate None with Runtime Validation

Convert Type | None return annotations to Type by raising at runtime if the value is None. Removes None-checking noise from downstream code and satisfies type checkers.

from hunterMakesPy import raiseIfNone

config = raiseIfNone(getConfig(), "Missing configuration")

Replace Ambiguous Numeric Literals with Semantic Names

Use decreasing instead of -1, inclusive for boundary adjustments, and zeroIndexed for index conversions. Intent becomes explicit and the code reads as prose.

from hunterMakesPy import decreasing, inclusive, zeroIndexed

rangeEnd = lengthSequence + inclusive
indexLast = lengthSequence - zeroIndexed
step = decreasing

Import Modules by Dot-Notation Path or File Path

Load functions or classes from "scipy.signal.windows" or "path/to/file.py" without manual module-loading boilerplate.

from hunterMakesPy.filesystemToolkit import importLogicalPath2Identifier

windowFunction = importLogicalPath2Identifier("scipy.signal.windows", "hann")

Create Directories Safely and Write Files with Formatting

Write to "deep/nested/path/file.txt" and parent directories are created automatically. writePython removes unused imports and sorts import statements before writing.

from hunterMakesPy.filesystemToolkit import writeStringToHere, writePython

writeStringToHere("content", "nested/dirs/file.txt")  # Creates dirs
writePython(sourceCode, "output/module.py")           # Formats, then writes

Extract Strings from Arbitrarily Nested Data

Recursively traverse dictionaries, lists, tuples, and sets and collect every string value into a flat list.

from hunterMakesPy.dataStructures import stringItUp

strings = stringItUp({"users": ["alice"], "config": {"host": "localhost"}})
# Returns: ["users", "alice", "config", "host", "localhost"]

Merge Dictionaries with List Values

Combine {"a": [1, 2]} and {"a": [3], "b": [4]} into {"a": [1, 2, 3], "b": [4]} with optional deduplication and sorting.

from hunterMakesPy.dataStructures import updateExtendPolishDictionaryLists

merged = updateExtendPolishDictionaryLists(
    {"servers": ["chicago"]},
    {"servers": ["tokyo", "chicago"]},
    destroyDuplicates=True,
)
# Returns: {"servers": ["chicago", "tokyo"]}

Compress NumPy Arrays to Self-Decoding Strings

Encode repetitive patterns and consecutive sequences using run-length encoding and Python range syntax. The resulting string evaluates back to the original data.

from hunterMakesPy.dataStructures import autoDecodingRLE

encoded = autoDecodingRLE(arrayTarget)

Configure Package Metadata at Runtime

PackageSettings reads pyproject.toml automatically to resolve the package name and installation path.

from hunterMakesPy import PackageSettings

settings = PackageSettings(identifierPackageFALLBACK="myPackage")

Reuse Test Suites for Custom Implementations

Import parameterized test generators to validate custom functions that match the expected signatures.

from hunterMakesPy.tests.test_parseParameters import PytestFor_intInnit

@pytest.mark.parametrize("test_name,test_func", PytestFor_intInnit(myFunction))
def test_my_integer_validator(test_name, test_func):
    test_func()

My recovery

Static Badge YouTube Channel Subscribers

CC-BY-NC-4.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

huntermakespy-0.7.2.tar.gz (48.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

huntermakespy-0.7.2-py3-none-any.whl (52.7 kB view details)

Uploaded Python 3

File details

Details for the file huntermakespy-0.7.2.tar.gz.

File metadata

  • Download URL: huntermakespy-0.7.2.tar.gz
  • Upload date:
  • Size: 48.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for huntermakespy-0.7.2.tar.gz
Algorithm Hash digest
SHA256 dccf123e5b68a43ee625aaf5404d340fc7d7916682040209ba35a971a05c8a86
MD5 23d85a241a79457714ef2b03d4750c77
BLAKE2b-256 0945e2f994a2d4178ebb979a3800916022e2b9f03ec85ed4a6c844a8cc48b253

See more details on using hashes here.

File details

Details for the file huntermakespy-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: huntermakespy-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 52.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for huntermakespy-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b7badb7e9029a39807cee9f375290a808a45345aabccbeb8554394bc2384de60
MD5 656769c06f8638096ece9a49601ba423
BLAKE2b-256 ef09b7490c3847e0959178bf08e75ea88fa7e1973866a3cd998d6e12f9f82985

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page