'Helper routine for checking the query and database availability.'

def _check_query(self, query, country=False, city=False, city_or_country=False):

    if (not isinstance(query, basestring)):
        raise TypeError(('GeoIP    query    must    be    a    string,    not    type    %s' % type(query).__name__))
    if (city_or_country and (not (self._country or self._city))):
        raise GeoIPException('Invalid    GeoIP    country    and    city    data    files.')
    elif (country and (not self._country)):
        raise GeoIPException(('Invalid    GeoIP    country    data    file:    %s' % self._country_file))
    elif (city and (not self._city)):
        raise GeoIPException(('Invalid    GeoIP    city    data    file:    %s' % self._city_file))
