def process_folder(root, action):
    excepts = []
    for (root, _, files) in os.walk(root):
        for f in files:
            fname = os.path.normpath(os.path.join(root, f))
            if (not process_file(fname, action)):
                excepts.append(fname)
    if ((action == 'check') and excepts):
        raise Exception((('The following files do not contain a valid license, ' + 'you can use `python tools/license_header.py add` to add') + 'them automatically'), excepts)
def process_folder(root, action):
    excepts = []
    for (root, _, files) in os.walk(root):
        for f in files:
            fname = os.path.normpath(os.path.join(root, f))
            if (not process_file(fname, action)):
                excepts.append(fname)
    if ((action == 'check') and excepts):
        raise Exception((('The following files do not contain a valid license, ' + 'you can use `python tools/license_header.py add` to add') + 'them automatically'), excepts)