def _sanity_check(fh):
 pos = fh.tell()
 try:
  line = fh.readline()
 finally:
  fh.seek(pos, 0)
 if (not line.startswith('StartFontMetrics')):
  raise RuntimeError('Not an AFM file')

def _sanity_check ( fh ) : pos = fh . tell ( ) try : line = fh . readline ( ) finally : fh . seek ( pos , 0 ) if ( not line . startswith ( 'StartFontMetrics' ) ) : raise RuntimeError ( 'Not an AFM file' )
check if the file at least looks like afm .