def _GetFD(filename, file_pos, fd_cache):
 if (filename in fd_cache):
  (at, fd) = fd_cache[filename]
  fd_cache[filename] = (time.time(), fd)
  return fd
 if (len(fd_cache) == MAX_OPEN_FILES):
  lru = sorted(fd_cache.items(), key=itemgetter(1))[:int((0.1 * MAX_OPEN_FILES))]
  for (key, (at, fd)) in lru:
   fd.close()
   del fd_cache[key]
 if (filename.endswith('.gz') or filename.endswith('.gz.tmp')):
  fd = gzip.open(filename, 'rb')
 else:
  fd = open(filename, 'r')
 fd.seek(file_pos)
 fd_cache[filename] = (time.time(), fd)
 return fd

def _GetFD ( filename , file_pos , fd_cache ) : if ( filename in fd_cache ) : ( at , fd ) = fd_cache [ filename ] fd_cache [ filename ] = ( time . time ( ) , fd ) return fd if ( len ( fd_cache ) == MAX_OPEN_FILES ) : lru = sorted ( fd_cache . items ( ) , key = itemgetter ( 1 ) ) [ : int ( ( 0.1 * MAX_OPEN_FILES ) ) ] for ( key , ( at , fd ) ) in lru : fd . close ( ) del fd_cache [ key ] if ( filename . endswith ( '.gz' ) or filename . endswith ( '.gz.tmp' ) ) : fd = gzip . open ( filename , 'rb' ) else : fd = open ( filename , 'r' ) fd . seek ( file_pos ) fd_cache [ filename ] = ( time . time ( ) , fd ) return fd
returns the file descriptor matching "filename" if present in the cache .