<s> import six <EOL> class HeaderKeyDict ( dict ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , base_headers = None , ** kwargs ) : <EOL> if base_headers : <EOL> self . update ( base_headers ) <EOL> self . update ( kwargs ) <EOL> def update ( self , other ) : <EOL> if hasattr ( other , '<STR_LIT>' ) : <EOL> for key in other . keys ( ) : <EOL> self [ key . title ( ) ] = other [ key ] <EOL> else : <EOL> for key , value in other : <EOL> self [ key . title ( ) ] = value <EOL> def __getitem__ ( self , key ) : <EOL> return dict . get ( self , key . title ( ) ) <EOL> def __setitem__ ( self , key , value ) : <EOL> if value is None : <EOL> self . pop ( key . title ( ) , None ) <EOL> elif isinstance ( value , six . text_type ) : <EOL> return dict . __setitem__ ( self , key . title ( ) , value . encode ( '<STR_LIT:utf-8>' ) ) <EOL> else : <EOL> return dict . __setitem__ ( self , key . title ( ) , str ( value ) ) <EOL> def __contains__ ( self , key ) : <EOL> return dict . __contains__ ( self , key . title ( ) ) <EOL> def __delitem__ ( self , key ) : <EOL> return dict . __delitem__ ( self , key . title ( ) ) <EOL> def get ( self , key , default = None ) : <EOL> return dict . get ( self , key . title ( ) , default ) <EOL> def setdefault ( self , key , value = None ) : <EOL> if key not in self : <EOL> self [ key ] = value <EOL> return self [ key ] <EOL> def pop ( self , key , default = None ) : <EOL> return dict . pop ( self , key . title ( ) , default ) </s>
