def check_header(filename):
 try:
  with open(filename, 'r') as pyfile:
   buf = ''
   for lineno in range(1, 8):
    line = pyfile.readline()
    if ((lineno == 1) and line.startswith('#!')):
     line = pyfile.readline()
    if line.startswith('# Copyright'):
     year = line[12:(-4)]
     if (not re.match('20\\d\\d', year)):
      return False
     line = ('# Copyright YYYY' + line[16:])
    buf += line
   return (buf == EXPECTED_HEADER)
 except IOError:
  return False

def check_header ( filename ) : try : with open ( filename , 'r' ) as pyfile : buf = '' for lineno in range ( 1 , 8 ) : line = pyfile . readline ( ) if ( ( lineno == 1 ) and line . startswith ( '#!' ) ) : line = pyfile . readline ( ) if line . startswith ( '# Copyright' ) : year = line [ 12 : ( - 4 ) ] if ( not re . match ( '20\\d\\d' , year ) ) : return False line = ( '# Copyright YYYY' + line [ 16 : ] ) buf += line return ( buf == EXPECTED_HEADER ) except IOError : return False
check if a given header is set correctly .