def getcfs(key, filename, filter=None):
 try:
  t = stat(filename).st_mtime
 except OSError:
  return (filter() if callable(filter) else '')
 cfs_lock.acquire()
 item = cfs.get(key, None)
 cfs_lock.release()
 if (item and (item[0] == t)):
  return item[1]
 if (not callable(filter)):
  data = read_file(filename)
 else:
  data = filter()
 cfs_lock.acquire()
 cfs[key] = (t, data)
 cfs_lock.release()
 return data

def getcfs ( key , filename , filter = None ) : try : t = stat ( filename ) . st_mtime except OSError : return ( filter ( ) if callable ( filter ) else '' ) cfs_lock . acquire ( ) item = cfs . get ( key , None ) cfs_lock . release ( ) if ( item and ( item [ 0 ] == t ) ) : return item [ 1 ] if ( not callable ( filter ) ) : data = read_file ( filename ) else : data = filter ( ) cfs_lock . acquire ( ) cfs [ key ] = ( t , data ) cfs_lock . release ( ) return data
caches the *filtered* file filename with key until the file is modified .