def process_file(fname, action, verbose=True):
    if (not _valid_file(fname, verbose)):
        return True
    with open(fname, 'rb') as f:
        lines = f.readlines()
    if (not lines):
        return True
    if _has_license(lines):
        return True
    elif (action == 'check'):
        return False
    (_, ext) = os.path.splitext(fname)
    with open(fname, 'wb') as f:
        if lines[0].startswith(b'#!'):
            f.write((lines[0].rstrip() + b'\n\n'))
            del lines[0]
        f.write(str.encode(_get_license(_LANGS[ext])))
        for l in lines:
            f.write((l.rstrip() + b'\n'))
    print(('added license header to ' + fname))
    return False
def process_file(fname, action, verbose=True):
    if (not _valid_file(fname, verbose)):
        return True
    with open(fname, 'rb') as f:
        lines = f.readlines()
    if (not lines):
        return True
    if _has_license(lines):
        return True
    elif (action == 'check'):
        return False
    (_, ext) = os.path.splitext(fname)
    with open(fname, 'wb') as f:
        if lines[0].startswith(b'#!'):
            f.write((lines[0].rstrip() + b'\n\n'))
            del lines[0]
        f.write(str.encode(_get_license(_LANGS[ext])))
        for l in lines:
            f.write((l.rstrip() + b'\n'))
    print(('added license header to ' + fname))
    return False