def _get_lines(file_path, line_prefixes, parameter):
 try:
  remaining_prefixes = list(line_prefixes)
  (proc_file, results) = (open(file_path), {})
  for line in proc_file:
   if (not remaining_prefixes):
    break
   for prefix in remaining_prefixes:
    if line.startswith(prefix):
     results[prefix] = line
     remaining_prefixes.remove(prefix)
     break
  proc_file.close()
  if remaining_prefixes:
   if (len(remaining_prefixes) == 1):
    msg = ('%s did not contain a %s entry' % (file_path, remaining_prefixes[0]))
   else:
    msg = ('%s did not contain %s entries' % (file_path, ', '.join(remaining_prefixes)))
   raise IOError(msg)
  else:
   return results
 except IOError as exc:
  _log_failure(parameter, exc)
  raise exc

def _get_lines ( file_path , line_prefixes , parameter ) : try : remaining_prefixes = list ( line_prefixes ) ( proc_file , results ) = ( open ( file_path ) , { } ) for line in proc_file : if ( not remaining_prefixes ) : break for prefix in remaining_prefixes : if line . startswith ( prefix ) : results [ prefix ] = line remaining_prefixes . remove ( prefix ) break proc_file . close ( ) if remaining_prefixes : if ( len ( remaining_prefixes ) == 1 ) : msg = ( '%s did not contain a %s entry' % ( file_path , remaining_prefixes [ 0 ] ) ) else : msg = ( '%s did not contain %s entries' % ( file_path , ', ' . join ( remaining_prefixes ) ) ) raise IOError ( msg ) else : return results except IOError as exc : _log_failure ( parameter , exc ) raise exc
fetches lines with the given prefixes from a file .