<s> """<STR_LIT>""" <EOL> import collections <EOL> from . compat import OrderedDict <EOL> class CaseInsensitiveDict ( collections . MutableMapping ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , data = None , ** kwargs ) : <EOL> self . _store = OrderedDict ( ) <EOL> if data is None : <EOL> data = { } <EOL> self . update ( data , ** kwargs ) <EOL> def __setitem__ ( self , key , value ) : <EOL> self . _store [ key . lower ( ) ] = ( key , value ) <EOL> def __getitem__ ( self , key ) : <EOL> return self . _store [ key . lower ( ) ] [ <NUM_LIT:1> ] <EOL> def __delitem__ ( self , key ) : <EOL> del self . _store [ key . lower ( ) ] <EOL> def __iter__ ( self ) : <EOL> return ( casedkey for casedkey , mappedvalue in self . _store . values ( ) ) <EOL> def __len__ ( self ) : <EOL> return len ( self . _store ) <EOL> def lower_items ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( <EOL> ( lowerkey , keyval [ <NUM_LIT:1> ] ) <EOL> for ( lowerkey , keyval ) <EOL> in self . _store . items ( ) <EOL> ) <EOL> def __eq__ ( self , other ) : <EOL> if isinstance ( other , collections . Mapping ) : <EOL> other = CaseInsensitiveDict ( other ) <EOL> else : <EOL> return NotImplemented <EOL> return dict ( self . lower_items ( ) ) == dict ( other . lower_items ( ) ) <EOL> def copy ( self ) : <EOL> return CaseInsensitiveDict ( self . _store . values ( ) ) <EOL> def __repr__ ( self ) : <EOL> return str ( dict ( self . items ( ) ) ) <EOL> class LookupDict ( dict ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name = None ) : <EOL> self . name = name <EOL> super ( LookupDict , self ) . __init__ ( ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . name ) <EOL> def __getitem__ ( self , key ) : <EOL> return self . __dict__ . get ( key , None ) <EOL> def get ( self , key , default = None ) : <EOL> return self . __dict__ . get ( key , default ) </s>
