def _make_methods():
    "Automagically generates methods based on the API endpoints"
    for k, v in PokeAPI().get_endpoints().items():
        string = "\t@BaseAPI._memoize\n"
        string += ("\tdef get_{0}(self, id_or_name='', limit=None,"
                   .format(k.replace('-', '_')) + ' offset=None):\n')
        string += ("\t\tparams = self._parse_params(locals().copy(), " +
                   "['id_or_name'])\n")
        string += "\t\tquery_string = '{0}/'\n".format(v.split('/')[-2])
        string += "\t\tquery_string += str(id_or_name) + '?'\n"
        string += '\t\tquery_string += params\n'
        string += '\t\treturn self._get(query_string)\n'
        print(string)
def _make_methods ( ) : for k , v in PokeAPI ( ) . get_endpoints ( ) . items ( ) : string = "\t@BaseAPI._memoize\n" string += ( "\tdef get_{0}(self, id_or_name='', limit=None," . format ( k . replace ( '-' , '_' ) ) + ' offset=None):\n' ) string += ( "\t\tparams = self._parse_params(locals().copy(), " + "['id_or_name'])\n" ) string += "\t\tquery_string = '{0}/'\n" . format ( v . split ( '/' ) [ - 2 ] ) string += "\t\tquery_string += str(id_or_name) + '?'\n" string += '\t\tquery_string += params\n' string += '\t\treturn self._get(query_string)\n' print ( string )
Automagically generates methods based on the API endpoints