def tamper_dir(inputpath, *args, **kwargs):
    """ Randomly tamper the files content in a directory tree, recursively """
    silent = kwargs.get('silent', False)
    if 'silent' in kwargs: del kwargs['silent']

    filescount = 0
    for _ in tqdm(recwalk(inputpath), desc='Precomputing', disable=silent):
        filescount += 1

    files_tampered = 0
    tamper_count = 0
    total_size = 0
    for dirname, filepath in tqdm(recwalk(inputpath), total=filescount, leave=True, desc='Tamper file n.', disable=silent):
        tcount, tsize = tamper_file(os.path.join(dirname, filepath), *args, **kwargs)
        if tcount > 0:
            tamper_count += tcount
            files_tampered += 1
        total_size += tsize
    return [files_tampered, filescount, tamper_count, total_size]
def tamper_dir ( inputpath , * args , ** kwargs ) : silent = kwargs . get ( 'silent' , False ) if 'silent' in kwargs : del kwargs [ 'silent' ] filescount = 0 for _ in tqdm ( recwalk ( inputpath ) , desc = 'Precomputing' , disable = silent ) : filescount += 1 files_tampered = 0 tamper_count = 0 total_size = 0 for dirname , filepath in tqdm ( recwalk ( inputpath ) , total = filescount , leave = True , desc = 'Tamper file n.' , disable = silent ) : tcount , tsize = tamper_file ( os . path . join ( dirname , filepath ) , * args , ** kwargs ) if tcount > 0 : tamper_count += tcount files_tampered += 1 total_size += tsize return [ files_tampered , filescount , tamper_count , total_size ]
Randomly tamper the files content in a directory tree, recursively