<s> import sys <EOL> from . import __version__ as bf_version <EOL> class Cache ( dict ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ** kw ) : <EOL> dict . __init__ ( self , kw ) <EOL> self . __dict__ = self <EOL> class HierarchicalCache ( Cache ) : <EOL> """<STR_LIT>""" <EOL> def __getattr__ ( self , attr ) : <EOL> if not attr . startswith ( "<STR_LIT:_>" ) and "<STR_LIT:(>" not in attr and "<STR_LIT:[>" not in attr and attr != "<STR_LIT>" : <EOL> c = HierarchicalCache ( ) <EOL> Cache . __setitem__ ( self , attr , c ) <EOL> return c <EOL> else : <EOL> raise AttributeError <EOL> def __getitem__ ( self , item ) : <EOL> if ( type ( item ) == slice or not hasattr ( item , "<STR_LIT>" ) ) : <EOL> raise TypeError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> dotted_parts = item . split ( "<STR_LIT:.>" ) <EOL> try : <EOL> c = self . __getattribute__ ( dotted_parts [ <NUM_LIT:0> ] ) <EOL> except AttributeError : <EOL> c = self . __getattr__ ( item ) <EOL> for dotted_part in dotted_parts [ <NUM_LIT:1> : ] : <EOL> c = getattr ( c , dotted_part ) <EOL> return c <EOL> def __call__ ( self ) : <EOL> raise TypeError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def __setitem__ ( self , key , item ) : <EOL> c = self <EOL> try : <EOL> try : <EOL> dotted_parts = key . split ( "<STR_LIT:.>" ) <EOL> except AttributeError : <EOL> return <EOL> if len ( dotted_parts ) > <NUM_LIT:1> : <EOL> c = self . __getitem__ ( "<STR_LIT:.>" . join ( dotted_parts [ : - <NUM_LIT:1> ] ) ) <EOL> key = dotted_parts [ - <NUM_LIT:1> ] <EOL> finally : <EOL> Cache . __setitem__ ( c , key , item ) <EOL> bf = HierarchicalCache ( ) <EOL> def setup_bf ( ) : <EOL> global bf <EOL> sys . modules [ '<STR_LIT>' ] = bf <EOL> bf . __version__ = bf_version <EOL> bf . cache = sys . modules [ '<STR_LIT>' ] <EOL> def reset_bf ( assign_modules = True ) : <EOL> global bf <EOL> bf . clear ( ) <EOL> setup_bf ( ) <EOL> if assign_modules : <EOL> from . import config , util , server , filter , controller , template <EOL> bf . config = config <EOL> bf . util = util <EOL> bf . server = server <EOL> bf . filter = filter <EOL> bf . controller = controller <EOL> bf . template = template <EOL> return bf <EOL> setup_bf ( ) </s>
