Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/geoip2/__pycache__/database.cpython-311.pyc



]j"dZddlZddlmZmZmZmZmZmZddl	Z	ddl	m
Z
mZmZm
Z
mZmZddlZddlZddlZddlmZddlmZmZmZmZmZmZmZmZGddZdS)	zG
======================
GeoIP2 Database Reader
======================

N)AnycastListOptionalTypeUnion)	MODE_AUTO	MODE_MMAP
MODE_MMAP_EXT	MODE_FILEMODE_MEMORYMODE_FD)	IPAddress)ASNAnonymousIPCityConnectionTypeCountryDomain
EnterpriseISPc
eZdZdZdefdedeeededdfdZ	ddZ
ddZd
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.6.3/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__nsr*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(cityzReader.citys)D$//&-*<fjQQRRRr*cttt|tjjd|S)zGet the AnonymousIP object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.AnonymousIP` object

        zGeoIP2-Anonymous-IP)rr_flat_model_forr9r:r;s  r(anonymous_ipzReader.anonymous_ips9  
)+@*



	
r*cttt|tjjd|S)zGet the ASN object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.ASN` object

        zGeoLite2-ASN)rrr@r9r:r;s  r(asnz
Reader.asns2%%fm&7TT

	
r*cttt|tjjd|S)zGet the ConnectionType object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.ConnectionType` object

        zGeoIP2-Connection-Type)rrr@r9r:r;s  r(connection_typezReader.connection_types9  
,.F




	
r*cttt|tjjd|S)zGet the Domain object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.Domain` object

        z
GeoIP2-Domain)rrr@r9r:r;s  r(domainz
Reader.domains3  !5
SS

	
r*cttt|tjjd|S)zGet the Enterprise object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.Enterprise` object

        r)rrr8r9r:r;s  r(
enterprisezReader.enterprises1OOFM4lJOO

	
r*cttt|tjjd|S)zGet the ISP object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.ISP` object

        z
GeoIP2-ISP)rrr@r9r:r;s  r(ispz
Reader.isps2%%fm&7zRR

	
r*r$c||jvr:tjdd}td|d|jd|j|\}}|#tjd|d||fS)NzThe z  method cannot be used with the z	 databasezThe address z is not in the database.)	r%inspectstack	TypeErrorr"get_with_prefix_lenr9errorsAddressNotFoundError)r'r$r6callerrecord
prefix_lens      r(_getzReader._gets
--]__Q'*FWvWWt}WWW
 $BB:NN>-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
rrr
rr9
geoip2.models
geoip2.errorsgeoip2.typesrrrrrrrrrrr-r*r(<module>rms{9999999999999999


""""""																				e e e e e e e e e e r*
Back to Directory File Manager