Skip to main content

Hyper charge your productivity

Project description

Hyperp - hyper productive utility functions for Python

Hyperp is a small utility library designed to simplify everyday coding tasks.
It embraces safe defaults over exceptions — for example, read() returns a default value if the file can’t be read, helping you gracefully handle edge cases without extra boilerplate.

Purpose

I run a software consultancy where we build products for clients and internal projects.
To stay Hyper Productive (hence "hyperp"), I created this library to streamline development and encourage safer patterns.

It also helps my team write more robust code with minimal effort.

Need simple, beautiful software frontend, backend or design? Checkout BaunIT.com

General Utility Functions

Documentation by example

from hyperp import *


# to_int: Convert to int, or return default on failure
to_int("42", 0)     # 42
to_int("x", 0)      # 0
to_int(None, -1)    # -1

# is_int: Check if input is an integer
is_int("123")       # True
is_int("abc")       # False

# is_float: Check if input is a float
is_float("3.14")    # True
is_float("hello")   # False

# is_ip4: Check if input is a valid IPv4 address
is_ip4("192.168.1.1")   # True
is_ip4("999.999.0.1")   # False

# mkdir: Create a directory and all parents if needed
mkdir("path/to/dir")

# mkdir_file: Create parent directories for a file path
mkdir_file("logs/output.log")  # Creates the 'logs' directory if missing

# write: Write string data to a file, creating dirs if needed
write("out/data.txt", "hello world")

# read: Read a file, return default on error
read("out/data.txt", "default")    # "hello world" or "default" if not found

# rmdir: Remove a directory and its contents, ignore errors
rmdir("path/to/remove")

# sanitize: Make filename safe for storage/use
sanitize("my*unsafe:file?.txt")    # "myunsafefile.txt"

# send_file: Upload file to a URL as multipart/form-data
send_file("https://example.com/upload", "report.pdf")  # Returns dict with msg and response

Django specific

Documentation by example

from hyperp.django import *

# cache: Shorthand for Django's cache_control with flexible time units
@cache(seconds=30, minutes=5, hours=1, days=1, public=False)
def my_view(request):
    ...

# get_csrf: Return CSRF token input element for forms
def form_view(request):
    csrf = get_csrf(request)
    return HttpResponse(f"<form>{csrf}<input name='x'></form>")

# get_ip: Extract client IP address from request headers
def log_request(request):
    ip = get_ip(request)
    # Use the IP (e.g., for logging, rate limiting, etc.)

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

hyperp-1.0.13.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

hyperp-1.0.13-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file hyperp-1.0.13.tar.gz.

File metadata

  • Download URL: hyperp-1.0.13.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for hyperp-1.0.13.tar.gz
Algorithm Hash digest
SHA256 609dc2a093a31b1b21a4b13844b43e4fa94247a9abd494fe0457edc5fc10de19
MD5 c27716d69d24c9cd25a303ff17b40ef3
BLAKE2b-256 2b16ea5fae46991739eaf8691aebb28162487194ee758342be7788aef903a6c4

See more details on using hashes here.

File details

Details for the file hyperp-1.0.13-py3-none-any.whl.

File metadata

  • Download URL: hyperp-1.0.13-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for hyperp-1.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 4898bae30b686cf2e3c16d68cf06cdbf07a5d95178f213d4039fb83dd10091cd
MD5 a9d0c6d8aa5eeb1bf99461bcac21b637
BLAKE2b-256 d673dba23337ed054f7150c2c593e7eb8059c34ae259a0dbf457766fe1a68d3d

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