Parse an API response.

def parseresponse(self, resp):
        """Parse an API response."""
        # Support Python 3's bytes type from socket repsonses
        if sys.version_info.major > 2:
            resp = resp.decode('utf-8')
	
        if self.RESPONSE_TOKEN not in resp:
            raise BustimeError("The Bustime API returned an invalid response: {}".format(resp))
        elif self.ERROR_TOKEN in resp:
            return self.errorhandle(resp)
        else:
            if self.format == 'json':
                return xmltodict.parse(resp)[self.RESPONSE_TOKEN]
            elif self.format == 'xml':
                return resp