def geocode(self, query, exactly_one=True, timeout=None):
        query_str = self.format_string % query

        url = "?".join((self.api, urlencode({'address':query_str})))
        logger.debug("%s.geocode: %s", self.__class__.__name__, url)
        if self.authenticated is True:
            auth = " ".join((
                "Basic",
                encodestring(":".join((self.username, self.password))\
                    .encode('utf-8')).strip().decode('utf-8')
            ))
            url = Request(url, headers={"Authorization": auth})
        page = self._call_geocoder(url, timeout=timeout, raw=True)
        content = page.read().decode("utf-8") if py3k else page.read() # pylint: disable=E1101,E1103
        places = [
            r for r in csv.reader(
                [content, ] if not isinstance(content, list)
                else content
            )
        ]
        if not len(places):
            return None
        if exactly_one is True:
            return self._parse_result(places[0])
        else:
            result = [self._parse_result(res) for res in places]
            if None in result: # todo
                return None
            return result
Geocode a location query.
dataset/ETHPy150Open geopy/geopy/geopy/geocoders/dot_us.py/GeocoderDotUS.geocode