<s> try : <EOL> from swapi import settings <EOL> from swapi . utils import query , all_resource_urls <EOL> from swapi . models import ( <EOL> People , <EOL> PeopleQuerySet , <EOL> Planet , <EOL> PlanetQuerySet , <EOL> Starship , <EOL> StarshipQuerySet , <EOL> Vehicle , <EOL> VehicleQuerySet , <EOL> Species , <EOL> SpeciesQuerySet , <EOL> Film , <EOL> FilmQuerySet , <EOL> ) <EOL> except : <EOL> import settings <EOL> from utils import query , all_resource_urls <EOL> from models import ( <EOL> People , <EOL> PeopleQuerySet , <EOL> Planet , <EOL> PlanetQuerySet , <EOL> Starship , <EOL> StarshipQuerySet , <EOL> Vehicle , <EOL> VehicleQuerySet , <EOL> Species , <EOL> SpeciesQuerySet , <EOL> Film , <EOL> FilmQuerySet , <EOL> ) <EOL> def _get ( id , type ) : <EOL> '''<STR_LIT>''' <EOL> result = query ( "<STR_LIT>" . format ( <EOL> settings . BASE_URL , <EOL> type , <EOL> str ( id ) ) <EOL> ) <EOL> return result <EOL> def get_all ( resource ) : <EOL> '''<STR_LIT>''' <EOL> QUERYSETS = { <EOL> settings . PEOPLE : PeopleQuerySet , <EOL> settings . PLANETS : PlanetQuerySet , <EOL> settings . STARSHIPS : StarshipQuerySet , <EOL> settings . VEHICLES : VehicleQuerySet , <EOL> settings . SPECIES : SpeciesQuerySet , <EOL> settings . FILMS : FilmQuerySet <EOL> } <EOL> urls = all_resource_urls ( <EOL> "<STR_LIT>" . format ( settings . BASE_URL , resource ) <EOL> ) <EOL> return QUERYSETS [ resource ] ( urls ) <EOL> def get_planet ( planet_id ) : <EOL> '''<STR_LIT>''' <EOL> result = _get ( planet_id , settings . PLANETS ) <EOL> return Planet ( result . content ) <EOL> def get_person ( people_id ) : <EOL> '''<STR_LIT>''' <EOL> result = _get ( people_id , settings . PEOPLE ) <EOL> return People ( result . content ) <EOL> def get_starship ( starship_id ) : <EOL> '''<STR_LIT>''' <EOL> result = _get ( starship_id , settings . STARSHIPS ) <EOL> return Starship ( result . content ) <EOL> def get_vehicle ( vehicle_id ) : <EOL> '''<STR_LIT>''' <EOL> result = _get ( vehicle_id , settings . VEHICLES ) <EOL> return Vehicle ( result . content ) <EOL> def get_species ( species_id ) : <EOL> '''<STR_LIT>''' <EOL> result = _get ( species_id , settings . SPECIES ) <EOL> return Species ( result . content ) <EOL> def get_film ( film_id ) : <EOL> '''<STR_LIT>''' <EOL> result = _get ( film_id , settings . FILMS ) <EOL> return Film ( result . content ) </s>
