<s> from modoboa . lib . cryptutils import decrypt <EOL> class ConnectionsManager ( type ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( cls , name , bases , ctx ) : <EOL> super ( ConnectionsManager , cls ) . __init__ ( name , bases , ctx ) <EOL> cls . instances = { } <EOL> def __call__ ( cls , ** kwargs ) : <EOL> key = None <EOL> if "<STR_LIT:user>" in kwargs : <EOL> key = kwargs [ "<STR_LIT:user>" ] <EOL> else : <EOL> return None <EOL> if key not in cls . instances : <EOL> cls . instances [ key ] = None <EOL> if "<STR_LIT:password>" in kwargs : <EOL> kwargs [ "<STR_LIT:password>" ] = decrypt ( kwargs [ "<STR_LIT:password>" ] ) <EOL> if cls . instances [ key ] is None : <EOL> cls . instances [ key ] = super ( ConnectionsManager , cls ) . __call__ ( ** kwargs ) <EOL> else : <EOL> cls . instances [ key ] . refresh ( key , kwargs [ "<STR_LIT:password>" ] ) <EOL> return cls . instances [ key ] <EOL> class ConnectionError ( Exception ) : <EOL> pass </s>
