<s> import os <EOL> import os . path <EOL> import base . paths <EOL> class DirectoryCache ( object ) : <EOL> def __init__ ( self , directory ) : <EOL> self . _directory = directory <EOL> base . paths . ensure_exists ( directory ) <EOL> def get ( self , key ) : <EOL> path = self . _path ( key ) <EOL> if not os . path . exists ( path ) : <EOL> return None <EOL> with open ( path , "<STR_LIT:r>" ) as file : <EOL> return file . read ( ) <EOL> def set ( self , key , value ) : <EOL> with open ( self . _path ( key ) , "<STR_LIT:w>" ) as file : <EOL> file . write ( value ) <EOL> def _path ( self , key ) : <EOL> return os . path . join ( self . _directory , key ) </s>
