<s> """<STR_LIT>""" <EOL> import sys <EOL> from functools import wraps <EOL> class CloudException ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class InvalidNameException ( CloudException ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class NotPermittedException ( CloudException ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class NoContainerException ( CloudException ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class NoObjectException ( CloudException ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class CloudExceptionWrapper ( object ) : <EOL> """<STR_LIT>""" <EOL> translations = { } <EOL> _excepts = None <EOL> def __new__ ( cls , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> obj = object . __new__ ( cls , * args , ** kwargs ) <EOL> if not obj . translations : <EOL> lazy_translations = cls . lazy_translations ( ) <EOL> if lazy_translations : <EOL> obj . translations = lazy_translations <EOL> return obj <EOL> @ classmethod <EOL> def excepts ( cls ) : <EOL> """<STR_LIT>""" <EOL> if cls . _excepts is None : <EOL> cls . _excepts = tuple ( cls . translations . keys ( ) ) <EOL> return cls . _excepts <EOL> def translate ( self , exc ) : <EOL> """<STR_LIT>""" <EOL> for key in self . translations . keys ( ) : <EOL> if isinstance ( exc , key ) : <EOL> return self . translations [ key ] ( unicode ( exc ) ) <EOL> return None <EOL> def __call__ ( self , operation ) : <EOL> """<STR_LIT>""" <EOL> @ wraps ( operation ) <EOL> def wrapped ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return operation ( * args , ** kwargs ) <EOL> except self . excepts ( ) , exc : <EOL> new_exc = self . translate ( exc ) <EOL> if new_exc : <EOL> raise new_exc . __class__ , new_exc , sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> else : <EOL> raise <EOL> return wrapped <EOL> @ classmethod <EOL> def lazy_translations ( cls ) : <EOL> """<STR_LIT>""" <EOL> return None </s>
