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

pip install hunterMakesPy

What This Package Does

  1. Convert strings, floats, binary data to validated integers — Accepts messy input like ["1", 2.0, b"3"] and returns [1, 2, 3] or fails with descriptive errors.

  2. Calculate CPU/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.

  3. Eliminate type checker warnings about None — Convert Type | None returns to Type by validating at runtime that values are not None.

  4. Import Python code from dot-notation paths or file paths — Load functions or classes from "scipy.signal.windows" or "path/to/file.py" without manual module loading.

  5. Create nested directories without error handling — Write to "deep/nested/path/file.txt" and parent directories are created automatically, existing directories are silently skipped.

  6. Format and write Python source code automatically — Removes unused imports, sorts import statements, applies consistent formatting before writing files.

  7. Extract all strings from arbitrarily nested data — Recursively traverse dictionaries, lists, tuples, sets and collect every string value into a flat list.

  8. Merge multiple 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.

  9. Compress NumPy arrays to compact string representations — Encode repetitive patterns and sequences using run-length encoding and Python range syntax that evaluates back to the original data.

  10. Replace ambiguous numeric literals with semantic names — Use decreasing instead of -1, inclusive for boundary adjustments, zeroIndexed for index conversions, making intent explicit.

Examples

import hunterMakesPy as humpy

# Integer validation from mixed sources
ports = humpy.intInnit(["8080", 443, "22"], "server_ports")

# Flexible CPU limit calculation
workers = humpy.defineConcurrencyLimit(limit=0.75)  # 6 CPUs on 8-core machine

# None-checking without type errors
config = humpy.raiseIfNone(getConfig(), "Missing configuration")

# Dynamic imports
windowFunc = humpy.importLogicalPath2Identifier("scipy.signal.windows", "hann")

# Safe file writing
humpy.writeStringToHere("content", "nested/dirs/file.txt")  # Creates dirs

# String extraction from nested data
strings = humpy.stringItUp({"users": ["alice"], "config": {"host": "localhost"}})
# Returns: ["users", "alice", "config", "host", "localhost"]

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

Testing Your Own Code

Import test suites 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.4.3.tar.gz (68.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.4.3-py3-none-any.whl (55.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for huntermakespy-0.4.3.tar.gz
Algorithm Hash digest
SHA256 a79120765d479613524c80bb1c6ee675ae92ccb0b03fa8cb2027ebfeedf73552
MD5 b1f680d7b6557896a59c2a4d0d14fb09
BLAKE2b-256 d57c466405210d33eb273137c8220517c2c276fb8b53d5b39e0d8a5d5a6fd130

See more details on using hashes here.

Provenance

The following attestation bundles were made for huntermakespy-0.4.3.tar.gz:

Publisher: pypiRelease.yml on hunterhogan/hunterMakesPy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

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

File hashes

Hashes for huntermakespy-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4580f9e3b5e5cb139c49c9911ac094931b70a9eb7ca46d651e068eacd95e6784
MD5 faeb77bf5ca6eed0b51eb17261e1c657
BLAKE2b-256 a4d300a7fd7fda3186ace7e0d7c414da18209aeda41027966e6e127bc95c2041

See more details on using hashes here.

Provenance

The following attestation bundles were made for huntermakespy-0.4.3-py3-none-any.whl:

Publisher: pypiRelease.yml on hunterhogan/hunterMakesPy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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