<s> from importlib import import_module <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from stripe . error import APIConnectionError as ProcessorConnectionError <EOL> from stripe . error import StripeError as ProcessorError <EOL> from stripe . error import CardError as BaseCardError <EOL> from . . import settings <EOL> class CardError ( BaseCardError ) : <EOL> def __unicode__ ( self ) : <EOL> if self . code == '<STR_LIT>' : <EOL> return "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> return self . _message <EOL> def processor_details ( self ) : <EOL> return super ( CardError , self ) . __unicode__ ( ) <EOL> def load_backend ( path ) : <EOL> dot_pos = path . rfind ( '<STR_LIT:.>' ) <EOL> module , attr = path [ : dot_pos ] , path [ dot_pos + <NUM_LIT:1> : ] <EOL> try : <EOL> mod = import_module ( module ) <EOL> except ( ImportError , ValueError ) as err : <EOL> raise ImproperlyConfigured ( <EOL> '<STR_LIT>' % ( path , err ) ) <EOL> try : <EOL> cls = getattr ( mod , attr ) <EOL> except AttributeError : <EOL> raise ImproperlyConfigured ( '<STR_LIT>' '<STR_LIT>' % ( module , attr ) ) <EOL> return cls ( ) <EOL> def get_processor_backend ( provider ) : <EOL> if settings . PROCESSOR_BACKEND_CALLABLE : <EOL> from saas . compat import import_string <EOL> func = import_string ( settings . PROCESSOR_BACKEND_CALLABLE ) <EOL> processor_backend = func ( provider ) <EOL> else : <EOL> processor_backend = load_backend ( <EOL> '<STR_LIT>' ) <EOL> return processor_backend </s>
