Skip to main content

wrapworks

Introduction

The wrapworks package provides decorators and helper functions for various functionalities such as timing function execution, handling exceptions, and automatic function retries.

Installation

You can install wrapworks using pip:

pip install wrapworks

Features

  • timeit: Decorator to print the execution duration of a function.
  • tryexcept: Decorator to add a try-except block around a function.
  • retry: Decorator to automatically retry a function.

Usage

Timing Function Execution

from wrapworks import timeit

@timeit()
def my_function():
    pass

Handling Exceptions

from wrapworks import tryexcept

@tryexcept(default_return=None)
def another_function():
    pass

Automatic Function Retries

from wrapworks import retry

@retry(max_retries=3, delay=1, default_return=None)
def some_function():
    pass

Easy printing of exceptions

from wrapworks import eprint

def some_function():
    try:
        raise ValueError()
    except Exception as e:
        eprint(e , some_function)

Add current directory to system path and load environment variables

from wrapworks import cwdtoenv
cwdtoenv()

Customizing Output

You can customize the output behavior of the wrapworks decorators by specifying a level parameter when using them.

Additionally, you can further control the display of print statements based on the WRAPWORKSLEVEL environment variable as follows:

  • If the level parameter in a decorator is higher than the WRAPWORKSLEVEL environment variable, the print statement from that decorator will be displayed.
  • Set WRAPWORKSLEVEL to a specific level (e.g., 1, 2, 3, etc.) to control which decorators' print statements are shown based on their respective levels.
  • Print statements from decorators with a level lower than the WRAPWORKSLEVEL will be suppressed, providing a cleaner output in the console or log files.

Metadata

Release files for wrapworks 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wrapworks 1.1.2
File Size Uploaded
wrapworks-1.1.2.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wrapworks 1.1.2
File Interpreter ABI Platform
wrapworks-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / wrapworks-1.1.2.tar.gz

Download URL wrapworks-1.1.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
860000ef6a8eee24fc10ece375b27e790258550bf070de01206fcf3ff75bff65
BLAKE2b-256 checksum
How to use checksums
437784759910462b332007ae3ad6c651c1252a805c345d42706627f78376f6b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / wrapworks-1.1.2-py3-none-any.whl

Download URL wrapworks-1.1.2-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0c160d185d99fc787adbcedb3a03b7adcaf6a4ab5a5ac51147a88703484efbe
BLAKE2b-256 checksum
How to use checksums
6e7c475e0a414f4fad74e5bbfdc09a1af53294fb5f92c52a4db1cd4048bf46fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page