lf"dZddlZddlmZmZmZmZmZmZddl Z ddl m Z m Z m Z m Z mZmZddlZddlZddlZddlmZddlmZmZmZmZmZmZmZmZGddZdS) zG ====================== GeoIP2 Database Reader ====================== N)AnycastListOptionalTypeUnion) MODE_AUTO MODE_MMAP MODE_MMAP_EXT MODE_FILE MODE_MEMORYMODE_FD) IPAddress)ASN AnonymousIPCityConnectionTypeCountryDomain EnterpriseISPc eZdZdZdefdedeeededdfdZ ddZ dd Z d e de fdZd e defdZd e defdZd e defdZd e defdZd e defdZd e defdZd e defdZded e defdZdee e e ee efded e dee eeffdZ!dee ee ee ee ee efded e deeeeeeffdZ"de#j$j%fdZ&d dZ'dS)!Readera GeoIP2 database Reader object. Instances of this class provide a reader for the GeoIP2 database format. IP addresses can be looked up using the ``country`` and ``city`` methods. The basic API for this class is the same for every database. First, you create a reader object, specifying a file name or file descriptor. You then call the method corresponding to the specific database, passing it the IP address you want to look up. If the request succeeds, the method call will return a model class for the method you called. This model in turn contains multiple record classes, each of which represents part of the data returned by the database. If the database does not contain the requested information, the attributes on the record class will have a ``None`` value. If the address is not in the database, an ``geoip2.errors.AddressNotFoundError`` exception will be thrown. If the database is corrupt or invalid, a ``maxminddb.InvalidDatabaseError`` will be thrown. Nfileishlocalesmodereturnc|dg}tj|||_|jj|_||_dS)agCreate GeoIP2 Reader. :param fileish: The string path to the GeoIP2 database, or an existing file descriptor pointing to the database. Note that this latter usage is only valid when mode is MODE_FD. :param locales: This is list of locale codes. This argument will be passed on to record classes to use when their name properties are called. The default value is ['en']. The order of the locales is significant. When a record class has multiple names (country, city, etc.), its name property will return the name in the first locale that has one. Note that the only locale which is always present in the GeoIP2 data is "en". If you do not include this locale, the name property may end up returning None even when the record has an English name. Currently, the valid locale codes are: * de -- German * en -- English names may still include accented characters if that is the accepted spelling in English. In other words, English does not mean ASCII. * es -- Spanish * fr -- French * ja -- Japanese * pt-BR -- Brazilian Portuguese * ru -- Russian * zh-CN -- Simplified Chinese. :param mode: The mode to open the database with. Valid mode are: * MODE_MMAP_EXT - use the C extension with memory map. * MODE_MMAP - read from memory map. Pure Python. * MODE_FILE - read database as standard file. Pure Python. * MODE_MEMORY - load database into memory. Pure Python. * MODE_FD - the param passed via fileish is a file descriptor, not a path. This mode implies MODE_MEMORY. Pure Python. * MODE_AUTO - try MODE_MMAP_EXT, MODE_MMAP, MODE_FILE in that order. Default. Nen) maxminddb open_database _db_readermetadata database_type_db_type_locales)selfrrrs o/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/geoip2/database.py__init__zReader.__init__=sHV ?fG#1'4@@0022@  c|SNr's r( __enter__zReader.__enter__ns r*exc_type exc_value tracebackc.|dSr,)close)r'r0r1r2s r(__exit__zReader.__exit__qs r* ip_addresscttt|tjjd|S)zGet the Country object for the IP address. :param ip_address: IPv4 or IPv6 address as a string. :returns: :py:class:`geoip2.models.Country` object r)rr _model_forgeoip2modelsr'r6s r(countryzReader.countryts0 T__V]%:IzRR   r*cttt|tjjd|S)zGet the City object for the IP address. :param ip_address: IPv4 or IPv6 address as a string. :returns: :py:class:`geoip2.models.City` object r)rrr8r9r:r;s r(cityz Reader.citys)D$//&-*-44CzCCC z!!r* model_classtypesc|||\}}|di}||d<||d<|||jS)Ntraitsr6rW)r)rX setdefaultr&)r'rYrZr6rVrWr\s r(r8zReader._model_fors\ $yy ;;""8R00)|)|{64=9999r*c^|||\}}||d<||d<||S)Nr6rW)rX)r'rYrZr6rVrWs r(r@zReader._flat_model_fors@ $yy ;;)|)|{6"""r*c4|jS)zlThe metadata for the open database. :returns: :py:class:`maxminddb.reader.Metadata` object )r"r#r.s r(r#zReader.metadatas '')))r*c8|jdS)zCloses the GeoIP2 database.N)r"r4r.s r(r4z Reader.closes r*)rr)r0Nr1Nr2NrN)rN)(__name__ __module__ __qualname____doc__r strrrintr)r/r5rrr<rr>rrArrCrrErrGrrIrrKrrXrrr8r@r readerMetadatar#r4r-r*r(rr&s.<@Y/ / / %-d3i%8/ GJ/ / / / / b  )       SySTSSSS  y  [       i  C       )           v       Y  :       i  C      "# "9 " " " " " :4=$z*:DJFG : : : w D( ) : : : : # L$s)T.%949d;FW W  #  #  # ~sK< = # # # #*)*3****      r*r)rdrOtypingrrrrrrr r r r r r rr9 geoip2.models geoip2.errors geoip2.typesrrrrrrrrrrr-r*r(rms{ 9999999999999999 """"""                    e e e e e e e e e e r*