

def get_scan_index():
    try:
        return int(get_setting("ScanIndex"))
    except:
        return 1

def processScanPars_decorator(func):
    def wrapper(scan, pars):
        if 'name' not in pars:
            index = get_scan_index()
            set_exec_pars(name=str(index))
            set_setting("ScanIndex", index+1)
        func(scan, pars)
    return wrapper


processScanPars = processScanPars_decorator(processScanPars)