'Initializes the GeoIP object, no parameters are required to use default
settings.  Keyword arguments may be passed in to customize the locations
of the GeoIP data sets.
* path: Base directory to where GeoIP data is located or the full path
to where the city or country data files (*.dat) are located.
Assumes that both the city and country data sets are located in
this directory; overrides the GEOIP_PATH settings attribute.
* cache: The cache settings when opening up the GeoIP datasets,
and may be an integer in (0, 1, 2, 4, 8) corresponding to
the GEOIP_STANDARD, GEOIP_MEMORY_CACHE, GEOIP_CHECK_CACHE,
GEOIP_INDEX_CACHE, and GEOIP_MMAP_CACHE, `GeoIPOptions` C API
settings,  respectively.  Defaults to 0, meaning that the data is read
from the disk.
* country: The name of the GeoIP country data file.  Defaults to
\'GeoIP.dat\'; overrides the GEOIP_COUNTRY settings attribute.
* city: The name of the GeoIP city data file.  Defaults to
\'GeoLiteCity.dat\'; overrides the GEOIP_CITY settings attribute.'

def __init__(self, path=None, cache=0, country=None, city=None):

    if (cache in self.cache_options):
        self._cache = cache
    else:
        raise GeoIPException(('Invalid    GeoIP    caching    option:    %s' % cache))
    if (not path):
        path = GEOIP_SETTINGS.get('GEOIP_PATH', None)
        if (not path):
            raise GeoIPException('GeoIP    path    must    be    provided    via    parameter    or    the    GEOIP_PATH    setting.')
    if (not isinstance(path, six.string_types)):
        raise TypeError(('Invalid    path    type:    %s' % type(path).__name__))
    if os.path.isdir(path):
        country_db = os.path.join(path, (country or GEOIP_SETTINGS.get('GEOIP_COUNTRY', 'GeoIP.dat')))
        if os.path.isfile(country_db):
            self._country = GeoIP_open(country_db, cache)
            self._country_file = country_db
        city_db = os.path.join(path, (city or GEOIP_SETTINGS.get('GEOIP_CITY', 'GeoLiteCity.dat')))
        if os.path.isfile(city_db):
            self._city = GeoIP_open(city_db, cache)
            self._city_file = city_db
    elif os.path.isfile(path):
        ptr = GeoIP_open(path, cache)
        info = GeoIP_database_info(ptr)
        if lite_regex.match(info):
            self._city = ptr
            self._city_file = path
        elif free_regex.match(info):
            self._country = ptr
            self._country_file = path
        else:
            raise GeoIPException(('Unable    to    recognize    database    edition:    %s' % info))
    else:
        raise GeoIPException('GeoIP    path    must    be    a    valid    file    or    directory.')
