<s> import logging <EOL> logger = logging . getLogger ( '<STR_LIT>' ) <EOL> class AmqpError ( Exception ) : pass <EOL> class AmqpStatusError ( AmqpError ) : pass <EOL> class Enum ( object ) : <EOL> def __init__ ( self , * names ) : <EOL> self . _names = set ( names ) <EOL> def __getattr__ ( self , name ) : <EOL> if name in self . _names : <EOL> return name <EOL> raise AttributeError <EOL> class WithFields ( object ) : <EOL> _fields = [ ] <EOL> def __init__ ( self , ** kargs ) : <EOL> fnames = [ fname for fname , ftype in self . _fields ] <EOL> unvalid_kargs = set ( kargs . keys ( ) ) - set ( fnames ) <EOL> if unvalid_kargs : <EOL> raise AttributeError ( '<STR_LIT>' % unvalid_kargs ) <EOL> for fn in fnames : <EOL> setattr ( self , fn , kargs . get ( fn ) ) <EOL> def __repr__ ( self ) : <EOL> fs = [ '<STR_LIT>' % ( f , getattr ( self , f ) ) for f , _ in self . _fields ] <EOL> t = type ( self ) <EOL> klass = ( getattr ( self , '<STR_LIT>' , None ) or <EOL> '<STR_LIT>' % ( t . __module__ , t . __name__ ) ) <EOL> return '<STR_LIT>' % ( klass , '<STR_LIT:U+002CU+0020>' . join ( fs ) ) <EOL> def add_method ( klass ) : <EOL> def decorator ( f ) : <EOL> setattr ( klass , f . __name__ , f ) <EOL> return decorator </s>
