progressmonitor/__init__.py
def monitored(total: int, name=None, message=None):
    """
    Decorate a function to automatically begin and end a task on the progressmonitor.
    The function must have a parameter called 'monitor'
    """
    def decorator(f):
        nonlocal name
        monitor_index = list(inspect.signature(f).parameters.keys()).index('monitor')
        if name is None:
            name=f.__name__
        @wraps(f)
        def wrapper(*args, **kargs):
            if len(args) > monitor_index:
                monitor = args[monitor_index]
            elif 'monitor' in kargs:
                monitor = kargs['monitor']
            else:
                monitor = kargs['monitor'] = NullMonitor()
            with monitor.task(total, name, message):
                f(*args, **kargs)
        return wrapper
    return decorator
def monitored(total: int, name=None, message=None):
    """
    Decorate a function to automatically begin and end a task on the progressmonitor.
    The function must have a parameter called 'monitor'
    """
    def decorator(f):
        nonlocal name
        monitor_index = list(inspect.signature(f).parameters.keys()).index('monitor')
        if name is None:
            name=f.__name__
        @wraps(f)
        def wrapper(*args, **kargs):
            if len(args) > monitor_index:
                monitor = args[monitor_index]
            elif 'monitor' in kargs:
                monitor = kargs['monitor']
            else:
                monitor = kargs['monitor'] = NullMonitor()
            with monitor.task(total, name, message):
                f(*args, **kargs)
        return wrapper
    return decorator
Decorate a function to automatically begin and end a task on the progressmonitor.
    The function must have a parameter called 'monitor'