Metadata-Version: 2.4
Name: hunterMakesPy
Version: 0.1.1
Summary: 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.
Author-email: Hunter Hogan <HunterHogan@pm.me>
License: CC-BY-NC-4.0
Project-URL: Donate, https://www.patreon.com/integrated
Project-URL: Homepage, https://github.com/hunterhogan/
Project-URL: Issues, https://github.com/hunterhogan/
Project-URL: Repository, https://github.com/hunterhogan/
Keywords: defensive programming,parameter validation,input validation,error propagation,concurrency limit,integer parsing,file system utilities,directory creation,dynamic import,module loading,attribute loading,string extraction,nested data structures,dictionary merging,package settings,configuration,pytest,test utilities
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Other Audience
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: charset_normalizer
Requires-Dist: more_itertools
Requires-Dist: numpy
Requires-Dist: python_minifier
Requires-Dist: tomli
Provides-Extra: testing
Requires-Dist: mypy; extra == "testing"
Requires-Dist: pytest; extra == "testing"
Requires-Dist: pytest-cov; extra == "testing"
Requires-Dist: pytest-xdist; extra == "testing"
Requires-Dist: pyupgrade; extra == "testing"
Requires-Dist: setuptools-scm; extra == "testing"
Dynamic: license-file

# hunterMakesPy

A modular Python toolkit for defensive programming, parameter validation, file system utilities, and flexible data structure manipulation.

[![pip install hunterMakesPy](https://img.shields.io/badge/pip%20install-hunterMakesPy-gray.svg?colorB=3b434b)](https://pypi.org/project/hunterMakesPy/)

## 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

```bash
pip install hunterMakesPy
```

## Defensive Programming

Utilities for handling `None` values and defensive programming patterns.

```python
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.

```python
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.

```python
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.

```python
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:

```python
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

[![Static Badge](https://img.shields.io/badge/2011_August-Homeless_since-blue?style=flat)](https://HunterThinks.com/support)
[![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UC3Gx7kz61009NbhpRtPP7tw)](https://www.youtube.com/@HunterHogan)

## How to code

Coding One Step at a Time:

0. WRITE CODE.
1. Don't write stupid code that's hard to revise.
2. Write good code.
3. When revising, write better code.

[![CC-BY-NC-4.0](https://github.com/hunterhogan/hunterMakesPy/blob/main/CC-BY-NC-4.0.svg)](https://creativecommons.org/licenses/by-nc/4.0/)
