<s> """<STR_LIT>""" <EOL> from . . helpers import to_python <EOL> from pprint import pprint <EOL> import sys <EOL> if sys . version_info > ( <NUM_LIT:3> , <NUM_LIT:0> ) : <EOL> from urllib . parse import quote <EOL> else : <EOL> from urllib import quote <EOL> class BaseResource ( object ) : <EOL> _strs = [ ] <EOL> _ints = [ ] <EOL> _dates = [ ] <EOL> _bools = [ ] <EOL> _dicts = [ ] <EOL> _map = { } <EOL> _arrays = { } <EOL> _pks = [ ] <EOL> order_by = '<STR_LIT:id>' <EOL> def __init__ ( self ) : <EOL> self . _bootstrap ( ) <EOL> self . _h = None <EOL> super ( BaseResource , self ) . __init__ ( ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . _id ) <EOL> def _bootstrap ( self ) : <EOL> """<STR_LIT>""" <EOL> for attr in self . _keys ( ) : <EOL> setattr ( self , attr , None ) <EOL> def _keys ( self ) : <EOL> return self . _strs + self . _ints + self . _dates + self . _bools + list ( self . _map . keys ( ) ) + list ( self . _arrays . keys ( ) ) <EOL> @ property <EOL> def _id ( self ) : <EOL> try : <EOL> return getattr ( self , self . _pks [ <NUM_LIT:0> ] ) <EOL> except IndexError : <EOL> return None <EOL> @ property <EOL> def _ids ( self ) : <EOL> """<STR_LIT>""" <EOL> for pk in self . _pks : <EOL> yield getattr ( self , pk ) <EOL> for pk in self . _pks : <EOL> try : <EOL> yield str ( getattr ( self , pk ) ) <EOL> except ValueError : <EOL> pass <EOL> def dict ( self ) : <EOL> d = dict ( ) <EOL> for k in self . _keys ( ) : <EOL> d [ k ] = self . __dict__ . get ( k ) <EOL> return d <EOL> def change_connection ( self , h ) : <EOL> self . _h = h <EOL> return self <EOL> @ classmethod <EOL> def new_from_dict ( cls , d , h = None , ** kwargs ) : <EOL> d = to_python ( <EOL> obj = cls ( ) , <EOL> in_dict = d , <EOL> str_keys = cls . _strs , <EOL> int_keys = cls . _ints , <EOL> date_keys = cls . _dates , <EOL> bool_keys = cls . _bools , <EOL> dict_keys = cls . _dicts , <EOL> object_map = cls . _map , <EOL> array_map = cls . _arrays , <EOL> _h = h <EOL> ) <EOL> d . __dict__ . update ( kwargs ) <EOL> return d <EOL> class Price ( BaseResource ) : <EOL> """<STR_LIT>""" <EOL> _strs = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> _pks = [ '<STR_LIT>' ] <EOL> def __init__ ( self ) : <EOL> self . app = None <EOL> super ( Price , self ) . __init__ ( ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . cents , self . unit ) <EOL> class Plan ( BaseResource ) : <EOL> """<STR_LIT>""" <EOL> _strs = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT:description>' , '<STR_LIT:state>' ] <EOL> _pks = [ '<STR_LIT:name>' , '<STR_LIT:id>' ] <EOL> _map = { '<STR_LIT>' : Price } <EOL> _dates = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . name ) <EOL> class Stack ( BaseResource ) : <EOL> """<STR_LIT>""" <EOL> _strs = [ '<STR_LIT:id>' , '<STR_LIT:name>' ] <EOL> _pks = [ '<STR_LIT:id>' , '<STR_LIT:name>' ] <EOL> def __init__ ( self ) : <EOL> self . app = None <EOL> super ( Stack , self ) . __init__ ( ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . name ) <EOL> class User ( BaseResource ) : <EOL> """<STR_LIT>""" <EOL> _strs = [ '<STR_LIT:id>' , '<STR_LIT:email>' ] <EOL> _pks = [ '<STR_LIT:id>' , '<STR_LIT:email>' ] <EOL> def __init__ ( self ) : <EOL> self . app = None <EOL> super ( User , self ) . __init__ ( ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . email ) <EOL> class RateLimit ( BaseResource ) : <EOL> _strs = [ '<STR_LIT>' ] <EOL> _bools = [ ] <EOL> _pks = [ '<STR_LIT>' ] <EOL> def __init__ ( self ) : <EOL> self . app = None <EOL> super ( RateLimit , self ) . __init__ ( ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . remaining ) </s>
