<s> from __future__ import absolute_import , unicode_literals <EOL> import warnings <EOL> class FeedParserDict ( dict ) : <EOL> keymap = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:id>' , <EOL> '<STR_LIT:date>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:description>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT:url>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> def __getitem__ ( self , key ) : <EOL> '''<STR_LIT>''' <EOL> if key == '<STR_LIT>' : <EOL> try : <EOL> return dict . __getitem__ ( self , '<STR_LIT>' ) [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> except IndexError : <EOL> raise KeyError ( "<STR_LIT>" ) <EOL> elif key == '<STR_LIT>' : <EOL> norel = lambda link : FeedParserDict ( [ ( name , value ) for ( name , value ) in link . items ( ) if name != '<STR_LIT>' ] ) <EOL> return [ norel ( link ) for link in dict . __getitem__ ( self , '<STR_LIT>' ) if link [ '<STR_LIT>' ] == '<STR_LIT>' ] <EOL> elif key == '<STR_LIT>' : <EOL> for link in dict . __getitem__ ( self , '<STR_LIT>' ) : <EOL> if link [ '<STR_LIT>' ] == '<STR_LIT>' and '<STR_LIT>' in link : <EOL> return link [ '<STR_LIT>' ] <EOL> elif key == '<STR_LIT>' : <EOL> if not dict . __contains__ ( self , '<STR_LIT>' ) and dict . __contains__ ( self , '<STR_LIT>' ) : <EOL> warnings . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , DeprecationWarning ) <EOL> return dict . __getitem__ ( self , '<STR_LIT>' ) <EOL> return dict . __getitem__ ( self , '<STR_LIT>' ) <EOL> elif key == '<STR_LIT>' : <EOL> if not dict . __contains__ ( self , '<STR_LIT>' ) and dict . __contains__ ( self , '<STR_LIT>' ) : <EOL> warnings . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> DeprecationWarning ) <EOL> return dict . __getitem__ ( self , '<STR_LIT>' ) <EOL> return dict . __getitem__ ( self , '<STR_LIT>' ) <EOL> else : <EOL> realkey = self . keymap . get ( key , key ) <EOL> if isinstance ( realkey , list ) : <EOL> for k in realkey : <EOL> if dict . __contains__ ( self , k ) : <EOL> return dict . __getitem__ ( self , k ) <EOL> elif dict . __contains__ ( self , realkey ) : <EOL> return dict . __getitem__ ( self , realkey ) <EOL> return dict . __getitem__ ( self , key ) <EOL> def __contains__ ( self , key ) : <EOL> if key in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> return dict . __contains__ ( self , key ) <EOL> try : <EOL> self . __getitem__ ( key ) <EOL> except KeyError : <EOL> return False <EOL> else : <EOL> return True <EOL> has_key = __contains__ <EOL> def get ( self , key , default = None ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> return self . __getitem__ ( key ) <EOL> except KeyError : <EOL> return default <EOL> def __setitem__ ( self , key , value ) : <EOL> key = self . keymap . get ( key , key ) <EOL> if isinstance ( key , list ) : <EOL> key = key [ <NUM_LIT:0> ] <EOL> return dict . __setitem__ ( self , key , value ) <EOL> def setdefault ( self , key , value ) : <EOL> if key not in self : <EOL> self [ key ] = value <EOL> return value <EOL> return self [ key ] <EOL> def __getattr__ ( self , key ) : <EOL> try : <EOL> return self . __getitem__ ( key ) <EOL> except KeyError : <EOL> raise AttributeError ( "<STR_LIT>" % key ) <EOL> def __hash__ ( self ) : <EOL> return id ( self ) </s>
