linkcheck.decorators

Simple decorators (usable in Python >= 2.4).

Example:

@synchronized(thread.allocate_lock())
def f():
    "Synchronized function"
    print("i am synchronized:", f, f.__doc__)

:deprecated
def g():
    "this function is deprecated"
    pass

@notimplemented
def h():
    "todo"
    pass

Functions

deprecated(func)

A decorator which can be used to mark functions as deprecated.

notimplemented(func)

Raises a NotImplementedError if the function is called.

signal_handler(signal_number)

From http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410666

synchronize(lock, func[, log_duration_secs])

Return synchronized function acquiring the given lock.

synchronized(lock)

A decorator calling a function with acquired lock.

timed([log, limit])

Decorator to run a function with timing info.

timeit(func, log, limit)

Print execution time of the function.

update_func_meta(fake_func, real_func)

Set meta information (eg.

Classes

curried(func, *a)

Decorator that returns a function that keeps returning functions until all arguments are supplied; then the original function is evaluated.

class linkcheck.decorators.curried(func, *a)[source]

Bases: object

Decorator that returns a function that keeps returning functions until all arguments are supplied; then the original function is evaluated.

Store function and arguments.

linkcheck.decorators.deprecated(func)[source]

A decorator which can be used to mark functions as deprecated. It emits a warning when the function is called.

linkcheck.decorators.notimplemented(func)[source]

Raises a NotImplementedError if the function is called.

linkcheck.decorators.signal_handler(signal_number)[source]

From http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410666

A decorator to set the specified function as handler for a signal. This function is the ‘outer’ decorator, called with only the (non-function) arguments. If signal_number is not a valid signal (for example signal.SIGN), no handler is set.

linkcheck.decorators.synchronize(lock, func, log_duration_secs=0)[source]

Return synchronized function acquiring the given lock.

linkcheck.decorators.synchronized(lock)[source]

A decorator calling a function with acquired lock.

linkcheck.decorators.timed(log=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, limit=2.0)[source]

Decorator to run a function with timing info.

linkcheck.decorators.timeit(func, log, limit)[source]

Print execution time of the function. For quick’n’dirty profiling.

linkcheck.decorators.update_func_meta(fake_func, real_func)[source]

Set meta information (eg. __doc__) of fake function to that of the real function. :return fake_func