def FindSentinel(filename, blocksize=(2 ** 16), error_fh=sys.stderr):
 if (filename == '-'):
  StatusUpdate("Can't combine --append with output to stdout.", error_fh)
  sys.exit(2)
 try:
  fp = open(filename, 'rb')
 except IOError as err:
  StatusUpdate(("Append mode disabled: can't read %r: %s." % (filename, err)), error_fh)
  return None
 try:
  fp.seek(0, 2)
  fp.seek(max(0, (fp.tell() - blocksize)))
  lines = fp.readlines()
  del lines[:1]
  sentinel = None
  for line in lines:
   if (not line.startswith(' DCTB ')):
    sentinel = line
  if (not sentinel):
   StatusUpdate(("Append mode disabled: can't find sentinel in %r." % filename), error_fh)
   return None
  return sentinel.rstrip('\n')
 finally:
  fp.close()

def FindSentinel ( filename , blocksize = ( 2 ** 16 ) , error_fh = sys . stderr ) : if ( filename == '-' ) : StatusUpdate ( "Can't combine --append with output to stdout." , error_fh ) sys . exit ( 2 ) try : fp = open ( filename , 'rb' ) except IOError as err : StatusUpdate ( ( "Append mode disabled: can't read %r: %s." % ( filename , err ) ) , error_fh ) return None try : fp . seek ( 0 , 2 ) fp . seek ( max ( 0 , ( fp . tell ( ) - blocksize ) ) ) lines = fp . readlines ( ) del lines [ : 1 ] sentinel = None for line in lines : if ( not line . startswith ( ' DCTB ' ) ) : sentinel = line if ( not sentinel ) : StatusUpdate ( ( "Append mode disabled: can't find sentinel in %r." % filename ) , error_fh ) return None return sentinel . rstrip ( '\n' ) finally : fp . close ( )
return the sentinel line from the output file .