def get_next_pair():
 def get_cb():
  if (not parts):
   raise BadInput('missing command')
  cmd = parts.pop(0).lower()
  for command in ('return', 'fail', 'passthru'):
   if command.startswith(cmd):
    cmd = command
    break
  else:
   raise BadInput(('bad command: %s' % cmd))
  if (cmd in ('return', 'fail')):
   if (not parts):
    raise BadInput('missing argument')
   result = parts.pop(0)
   if (len(result) > 6):
    raise BadInput('result more than 6 chars long', result)
   return Callback(cmd, result)
  else:
   return Callback(cmd)
 try:
  line = raw_input()
 except EOFError:
  sys.exit()
 if (not line):
  return None
 parts = line.strip().split()
 (callback, errback) = (get_cb(), get_cb())
 if parts:
  raise BadInput('extra arguments')
 return (callback, errback)

def get_next_pair ( ) : def get_cb ( ) : if ( not parts ) : raise BadInput ( 'missing command' ) cmd = parts . pop ( 0 ) . lower ( ) for command in ( 'return' , 'fail' , 'passthru' ) : if command . startswith ( cmd ) : cmd = command break else : raise BadInput ( ( 'bad command: %s' % cmd ) ) if ( cmd in ( 'return' , 'fail' ) ) : if ( not parts ) : raise BadInput ( 'missing argument' ) result = parts . pop ( 0 ) if ( len ( result ) > 6 ) : raise BadInput ( 'result more than 6 chars long' , result ) return Callback ( cmd , result ) else : return Callback ( cmd ) try : line = raw_input ( ) except EOFError : sys . exit ( ) if ( not line ) : return None parts = line . strip ( ) . split ( ) ( callback , errback ) = ( get_cb ( ) , get_cb ( ) ) if parts : raise BadInput ( 'extra arguments' ) return ( callback , errback )
get the next callback/errback pair from the user .