Skip to main content

A set of helper functions

Project description

Boilerplate Tools

A collection of utility functions and tools to simplify common development tasks.

Installation

pip install boilerplate-tools

Features

  • Smart String Formatting: String templating with variable validation
  • Configuration Management: Load and process configuration files
  • JSON I/O: Simple functions for reading, writing, and appending JSON data
  • Path Management: Easily handle Python path configuration

Usage Examples

Smart Format

from boilerplate_tools import smart_format

# Format a string with required variables
result = smart_format("Hello, {name}!", {"name": "World"})
print(result)  # Output: Hello, World!

# Will raise KeyError for missing variables
try:
    smart_format("Hello, {name}!", {})
except KeyError as e:
    print(e)  # Missing required template variable: 'name'

# Will warn about unused variables
import warnings
with warnings.catch_warnings(record=True) as w:
    smart_format("Hello, {name}!", {"name": "World", "unused": "value"})
    if w:
        print(w[0].message)  # Unused variables provided that are not in the template: unused

Configuration Loading

from boilerplate_tools import load_config

# Load a configuration file with variable resolution
config = load_config("config.yaml")
print(config.some_key)

JSON I/O

from boilerplate_tools import read_json, write_json, append_json

# Read a JSON file
data = read_json("data.json")

# Write a JSON file
write_json("output.json", {"name": "John", "age": 30})

# Append to a JSON list file
append_json("list.json", [{"name": "John"}, {"name": "Jane"}])

Path Management

from boilerplate_tools import setup_root

# Add the current directory to sys.path
setup_root()

# Add the parent directory to sys.path
setup_root(n_up=1)

# Get the root directory path
root_dir = setup_root(n_up=1, return_root=True)
print(f"Root directory: {root_dir}")

Development

Distribution creation:

python setup.py sdist bdist_wheel

Upload to PyPI:

twine upload dist/*

TODO

  • Add Pytest tests for all functions

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

bolerplate_tools-0.1.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

bolerplate_tools-0.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file bolerplate_tools-0.1.1.tar.gz.

File metadata

  • Download URL: bolerplate_tools-0.1.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for bolerplate_tools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6b2d9cb94856c09ae5edcb1aafb95dc8f31f25089290990f59c2e2a6319cc548
MD5 c7c03b3bb7b712deb8ff0cd2885ca524
BLAKE2b-256 54e2924d96cf004b9ad295aaa0eb5db16dc146379ed4ce3fed6a51265aabd8d7

See more details on using hashes here.

File details

Details for the file bolerplate_tools-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bolerplate_tools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 37af3af4577171d2c6f27fcdf68d162de2184a434fd9270ee116d838ebf83a32
MD5 a4d08d097c995e87bedb498b64b0dfab
BLAKE2b-256 a4cbc6af5c275c079e589b9f507a6961880a373e6a6e94ea1602129f6767ca73

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