<s> from libcloud . utils . py3 import httplib <EOL> __all__ = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] <EOL> class LibcloudError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , value , driver = None ) : <EOL> super ( LibcloudError , self ) . __init__ ( value ) <EOL> self . value = value <EOL> self . driver = driver <EOL> def __str__ ( self ) : <EOL> return self . __repr__ ( ) <EOL> def __repr__ ( self ) : <EOL> return ( "<STR_LIT>" + <EOL> repr ( self . driver ) + <EOL> "<STR_LIT:U+0020>" + <EOL> repr ( self . value ) + "<STR_LIT:>>" ) <EOL> class MalformedResponseError ( LibcloudError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , value , body = None , driver = None ) : <EOL> self . value = value <EOL> self . driver = driver <EOL> self . body = body <EOL> def __str__ ( self ) : <EOL> return self . __repr__ ( ) <EOL> def __repr__ ( self ) : <EOL> return ( "<STR_LIT>" + <EOL> repr ( self . driver ) + <EOL> "<STR_LIT:U+0020>" + <EOL> repr ( self . value ) + <EOL> "<STR_LIT>" + <EOL> repr ( self . body ) ) <EOL> class ProviderError ( LibcloudError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , value , http_code , driver = None ) : <EOL> super ( ProviderError , self ) . __init__ ( value = value , driver = driver ) <EOL> self . http_code = http_code <EOL> def __str__ ( self ) : <EOL> return self . __repr__ ( ) <EOL> def __repr__ ( self ) : <EOL> return repr ( self . value ) <EOL> class InvalidCredsError ( ProviderError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , value = '<STR_LIT>' , <EOL> driver = None ) : <EOL> super ( InvalidCredsError , self ) . __init__ ( value , <EOL> http_code = httplib . UNAUTHORIZED , <EOL> driver = driver ) <EOL> InvalidCredsException = InvalidCredsError <EOL> class LazyList ( object ) : <EOL> def __init__ ( self , get_more , value_dict = None ) : <EOL> self . _data = [ ] <EOL> self . _last_key = None <EOL> self . _exhausted = False <EOL> self . _all_loaded = False <EOL> self . _get_more = get_more <EOL> self . _value_dict = value_dict or { } <EOL> def __iter__ ( self ) : <EOL> if not self . _all_loaded : <EOL> self . _load_all ( ) <EOL> data = self . _data <EOL> for i in data : <EOL> yield i <EOL> def __getitem__ ( self , index ) : <EOL> if index >= len ( self . _data ) and not self . _all_loaded : <EOL> self . _load_all ( ) <EOL> return self . _data [ index ] <EOL> def __len__ ( self ) : <EOL> self . _load_all ( ) <EOL> return len ( self . _data ) <EOL> def __repr__ ( self ) : <EOL> self . _load_all ( ) <EOL> repr_string = '<STR_LIT:U+002CU+0020>' . join ( [ repr ( item ) for item in self . _data ] ) <EOL> repr_string = '<STR_LIT>' % ( repr_string ) <EOL> return repr_string <EOL> def _load_all ( self ) : <EOL> while not self . _exhausted : <EOL> newdata , self . _last_key , self . _exhausted = self . _get_more ( last_key = self . _last_key , <EOL> value_dict = self . _value_dict ) <EOL> self . _data . extend ( newdata ) <EOL> self . _all_loaded = True </s>
