def run_checks(hooks_all, hooks_modified, modified, path):
    retcode = 0
    for command in hooks_all:
        if not isinstance(command, list):
            command = shlex.split(command)
        retcode |= subprocess.call(command, env={'PATH': path})

    for pattern, command in hooks_modified:
        if not isinstance(command, list):
            command = shlex.split(command)
        for filename in modified:
            if not fnmatch.fnmatch(filename, pattern):
                continue
            printed_filename = False
            proc = subprocess.Popen(command + [filename],
                                    env={'PATH': path},
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT)
            output = proc.communicate()[0]
            if proc.returncode != 0:
                if not printed_filename:
                    print(filename)
                    print('=' * len(filename))
                    printed_filename = True
                print(command[0])
                print('-' * len(command[0]))
                print(output)
                retcode |= proc.returncode

    return retcode
Run selected checks on the current git index
dataset/ETHPy150Open mathcamp/pypicloud/git_hooks/hook.py/run_checks