<s> """<STR_LIT>""" <EOL> from os import stat <EOL> import thread <EOL> import logging <EOL> from gluon . fileutils import read_file <EOL> cfs = { } <EOL> cfs_lock = thread . allocate_lock ( ) <EOL> def getcfs ( key , filename , filter = None ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> t = stat ( filename ) . st_mtime <EOL> except OSError : <EOL> return filter ( ) if callable ( filter ) else '<STR_LIT>' <EOL> cfs_lock . acquire ( ) <EOL> item = cfs . get ( key , None ) <EOL> cfs_lock . release ( ) <EOL> if item and item [ <NUM_LIT:0> ] == t : <EOL> return item [ <NUM_LIT:1> ] <EOL> if not callable ( filter ) : <EOL> data = read_file ( filename ) <EOL> else : <EOL> data = filter ( ) <EOL> cfs_lock . acquire ( ) <EOL> cfs [ key ] = ( t , data ) <EOL> cfs_lock . release ( ) <EOL> return data </s>
