Commit 85d0c92f by William Tisäter

Merge branch 'master' into continents

Conflicts:
	pygeoip/__init__.py
	pygeoip/const.py
parents 5e9d4771 28e45703
......@@ -2,7 +2,7 @@
*env
*.pyc
*.egg-info
*.dat
tests/data/*
.tox
build
dist
GNU GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
\ No newline at end of file
Bootstrap manual for developers of pygeoip
Dependencies: tox, nose, epydoc
For testing we are using tox virtualenv-based Python version testing
and nose as test framwork.
Tox will create virtualenvs for all Python version pygeoip supports
and installs the current working tree using the setup.py install script.
Running the tests requires a couple of sample databases found on the
link below.
Maxmind sample databases for testing can be downloaded here:
http://www.defunct.cc/maxmind-geoip-samples.tar.gz (58 MB)
Extract the tarball in the tests directory and run tox from the root directory.
Please make sure your code passes all tests before opening pull requests.
All the best,
William Tisäter
recursive-include apidocs *
recursive-include tests *
include README.md
include COPYING
include DEVELOPER
include INSTALL
include epydoc.ini
include tox.ini
......@@ -4,7 +4,7 @@ but the code itself is ported from the [Pure PHP GeoIP API](http://pear.php.net/
It is mostly a drop-in replacement, except the `new` and `open` methods are gone.
Tested using tox with Python version 2.5, 2.6, 2.7, 3.0 and 3.1.
Tested using tox with Python version 2.5, 2.6, 2.7, 3.1, 3.2 and 3.3.
## Issues and contribution ##
......@@ -23,6 +23,7 @@ You can easily install pygeoip with setuptools:
* City
* Organization
* ISP
* ASN
## Quick Documentation ##
......@@ -40,10 +41,16 @@ Create your GeoIP instance with appropriate access flag. `STANDARD` reads data f
>>> gi.country_name_by_addr('64.233.161.99')
'United States'
### Region lookup ###
>>> gi = pygeoip.GeoIP('/path/to/GeoIPRegion.dat')
>>> gi.region_by_name('apple.com')
{'region_name': 'CA', 'country_code': 'US'}
### City lookup ###
>>> gic = pygeoip.GeoIP('/path/to/GeoIPCity.dat')
>>> gic.record_by_addr('64.233.161.99')
>>> gi = pygeoip.GeoIP('/path/to/GeoIPCity.dat')
>>> gi.record_by_addr('64.233.161.99')
{
'city': 'Mountain View',
'region_name': 'CA',
......@@ -56,11 +63,25 @@ Create your GeoIP instance with appropriate access flag. `STANDARD` reads data f
'country_code': 'US',
'country_name': 'United States'
}
>>> gi.time_zone_by_addr('64.233.161.99')
'America/Los_Angeles'
### Timezone lookup ###
### Organization lookup ###
>>> gic = pygeoip.GeoIP('/path/to/GeoIPCity.dat')
>>> gic.time_zone_by_addr('64.233.161.99')
'America/Los_Angeles'
>>> gi = pygeoip.GeoIP('/path/to/GeoIPOrg.dat')
>>> gi.org_by_name('dell.com')
'Dell Computer Corporation'
### ISP lookup ###
>>> gi = pygeoip.GeoIP('/path/to/GeoIPISP.dat')
>>> gi.org_by_name('cnn.com')
'Turner Broadcasting System'
### ASN lookup ###
>>> gi = pygeoip.GeoIP('/path/to/GeoIPASNum.dat')
>>> gi.org_by_name('cnn.com')
'AS5662 Turner Broadcasting'
For more information, [check out the full API documentation](http://packages.python.org/pygeoip).
pygeoip pygeoip-module.html
pygeoip.MMAP_CACHE pygeoip-module.html#MMAP_CACHE
pygeoip.STANDARD pygeoip-module.html#STANDARD
pygeoip.ENCODING pygeoip-module.html#ENCODING
pygeoip.time_zone_by_country_and_region pygeoip.timezone-module.html#time_zone_by_country_and_region
pygeoip.MEMORY_CACHE pygeoip-module.html#MEMORY_CACHE
pygeoip.ip2long pygeoip.util-module.html#ip2long
pygeoip.__package__ pygeoip-module.html#__package__
pygeoip.STANDARD pygeoip-module.html#STANDARD
pygeoip.MMAP_CACHE pygeoip-module.html#MMAP_CACHE
pygeoip.MEMORY_CACHE pygeoip-module.html#MEMORY_CACHE
pygeoip.const pygeoip.const-module.html
pygeoip.const.GEOIP_STANDARD pygeoip.const-module.html#GEOIP_STANDARD
pygeoip.const.ENCODING pygeoip.const-module.html#ENCODING
pygeoip.const.COUNTRY_CODES3 pygeoip.const-module.html#COUNTRY_CODES3
pygeoip.const.PY3 pygeoip.const-module.html#PY3
pygeoip.const.IPV6_EDITIONS pygeoip.const-module.html#IPV6_EDITIONS
pygeoip.const.ORG_EDITION pygeoip.const-module.html#ORG_EDITION
pygeoip.const.ASNUM_EDITION pygeoip.const-module.html#ASNUM_EDITION
pygeoip.const.STRUCTURE_INFO_MAX_SIZE pygeoip.const-module.html#STRUCTURE_INFO_MAX_SIZE
......@@ -16,6 +19,7 @@ pygeoip.const.REGION_EDITION_REV0 pygeoip.const-module.html#REGION_EDITION_REV0
pygeoip.const.REGION_EDITION_REV1 pygeoip.const-module.html#REGION_EDITION_REV1
pygeoip.const.CANADA_OFFSET pygeoip.const-module.html#CANADA_OFFSET
pygeoip.const.MAX_ORG_RECORD_LENGTH pygeoip.const-module.html#MAX_ORG_RECORD_LENGTH
pygeoip.const.CITY_EDITIONS pygeoip.const-module.html#CITY_EDITIONS
pygeoip.const.__package__ pygeoip.const-module.html#__package__
pygeoip.const.CITY_EDITION_REV0 pygeoip.const-module.html#CITY_EDITION_REV0
pygeoip.const.STATE_BEGIN_REV1 pygeoip.const-module.html#STATE_BEGIN_REV1
......@@ -24,6 +28,7 @@ pygeoip.const.FULL_RECORD_LENGTH pygeoip.const-module.html#FULL_RECORD_LENGTH
pygeoip.const.COUNTRY_EDITION_V6 pygeoip.const-module.html#COUNTRY_EDITION_V6
pygeoip.const.ISP_EDITION pygeoip.const-module.html#ISP_EDITION
pygeoip.const.NETSPEED_EDITION pygeoip.const-module.html#NETSPEED_EDITION
pygeoip.const.PY2 pygeoip.const-module.html#PY2
pygeoip.const.WORLD_OFFSET pygeoip.const-module.html#WORLD_OFFSET
pygeoip.const.CITY_EDITION_REV1 pygeoip.const-module.html#CITY_EDITION_REV1
pygeoip.const.DATABASE_INFO_MAX_SIZE pygeoip.const-module.html#DATABASE_INFO_MAX_SIZE
......@@ -31,6 +36,7 @@ pygeoip.const.ORG_RECORD_LENGTH pygeoip.const-module.html#ORG_RECORD_LENGTH
pygeoip.const.COUNTRY_BEGIN pygeoip.const-module.html#COUNTRY_BEGIN
pygeoip.const.PROXY_EDITION pygeoip.const-module.html#PROXY_EDITION
pygeoip.const.STANDARD pygeoip.const-module.html#STANDARD
pygeoip.const.REGION_EDITIONS pygeoip.const-module.html#REGION_EDITIONS
pygeoip.const.FIPS_RANGE pygeoip.const-module.html#FIPS_RANGE
pygeoip.const.SEGMENT_RECORD_LENGTH pygeoip.const-module.html#SEGMENT_RECORD_LENGTH
pygeoip.const.COUNTRY_EDITION pygeoip.const-module.html#COUNTRY_EDITION
......@@ -40,6 +46,7 @@ pygeoip.const.MMAP_CACHE pygeoip.const-module.html#MMAP_CACHE
pygeoip.const.DMA_MAP pygeoip.const-module.html#DMA_MAP
pygeoip.const.COUNTRY_CODES pygeoip.const-module.html#COUNTRY_CODES
pygeoip.const.GEOIP_MEMORY_CACHE pygeoip.const-module.html#GEOIP_MEMORY_CACHE
pygeoip.const.REGION_CITY_EDITIONS pygeoip.const-module.html#REGION_CITY_EDITIONS
pygeoip.const.MEMORY_CACHE pygeoip.const-module.html#MEMORY_CACHE
pygeoip.const.MAX_RECORD_LENGTH pygeoip.const-module.html#MAX_RECORD_LENGTH
pygeoip.timezone pygeoip.timezone-module.html
......@@ -47,8 +54,10 @@ pygeoip.timezone._country pygeoip.timezone-module.html#_country
pygeoip.timezone.time_zone_by_country_and_region pygeoip.timezone-module.html#time_zone_by_country_and_region
pygeoip.timezone.__package__ pygeoip.timezone-module.html#__package__
pygeoip.util pygeoip.util-module.html
pygeoip.util.ip2long pygeoip.util-module.html#ip2long
pygeoip.util.__package__ pygeoip.util-module.html#__package__
pygeoip.util.ip2long_v4 pygeoip.util-module.html#ip2long_v4
pygeoip.util.ip2long_v6 pygeoip.util-module.html#ip2long_v6
pygeoip.util.ip2long pygeoip.util-module.html#ip2long
pygeoip.GeoIP pygeoip.GeoIP-class.html
pygeoip.GeoIP.country_code_by_addr pygeoip.GeoIP-class.html#country_code_by_addr
pygeoip.GeoIP.region_by_name pygeoip.GeoIP-class.html#region_by_name
......@@ -56,15 +65,16 @@ pygeoip.GeoIP.record_by_name pygeoip.GeoIP-class.html#record_by_name
pygeoip.GeoIP._setup_segments pygeoip.GeoIP-class.html#_setup_segments
pygeoip.GeoIP._seek_country pygeoip.GeoIP-class.html#_seek_country
pygeoip.GeoIP.__init__ pygeoip.GeoIP-class.html#__init__
pygeoip.GeoIP.time_zone_by_name pygeoip.GeoIP-class.html#time_zone_by_name
pygeoip.GeoIP._get_region pygeoip.GeoIP-class.html#_get_region
pygeoip.GeoIP.country_code_by_name pygeoip.GeoIP-class.html#country_code_by_name
pygeoip.GeoIP._get_org pygeoip.GeoIP-class.html#_get_org
pygeoip.GeoIP._lookup_country_id pygeoip.GeoIP-class.html#_lookup_country_id
pygeoip.GeoIP.time_zone_by_addr pygeoip.GeoIP-class.html#time_zone_by_addr
pygeoip.GeoIP.id_by_addr pygeoip.GeoIP-class.html#id_by_addr
pygeoip.GeoIP.time_zone_by_name pygeoip.GeoIP-class.html#time_zone_by_name
pygeoip.GeoIP._get_record pygeoip.GeoIP-class.html#_get_record
pygeoip.GeoIP.org_by_addr pygeoip.GeoIP-class.html#org_by_addr
pygeoip.GeoIP.region_by_addr pygeoip.GeoIP-class.html#region_by_addr
pygeoip.GeoIP._gethostbyname pygeoip.GeoIP-class.html#_gethostbyname
pygeoip.GeoIP.record_by_addr pygeoip.GeoIP-class.html#record_by_addr
pygeoip.GeoIP.country_name_by_addr pygeoip.GeoIP-class.html#country_name_by_addr
pygeoip.GeoIP.org_by_name pygeoip.GeoIP-class.html#org_by_name
......
......@@ -123,7 +123,7 @@
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -256,7 +256,7 @@ page was last updated. </p>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -63,7 +63,7 @@
B
<a href="#C">C</a>
<a href="#D">D</a>
E
<a href="#E">E</a>
<a href="#F">F</a>
<a href="#G">G</a>
H
......@@ -107,13 +107,21 @@
<tr>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#CANADA_OFFSET">CANADA_OFFSET</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#COUNTRY_BEGIN">COUNTRY_BEGIN</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#COUNTRY_EDITION">COUNTRY_EDITION</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#CITY_EDITION_REV0">CITY_EDITION_REV0</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#country_code_by_addr">country_code_by_addr()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#COUNTRY_EDITION_V6">COUNTRY_EDITION_V6</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#CITY_EDITION_REV0">CITY_EDITION_REV0</a><br />
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#CITY_EDITION_REV1">CITY_EDITION_REV1</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#country_code_by_name">country_code_by_name()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
......@@ -121,7 +129,7 @@
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#CITY_EDITION_REV1">CITY_EDITION_REV1</a><br />
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#CITY_EDITIONS">CITY_EDITIONS</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#COUNTRY_CODES">COUNTRY_CODES</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
......@@ -136,22 +144,28 @@
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#COUNTRY_NAMES">COUNTRY_NAMES</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
</tr>
</table>
</td></tr>
<tr valign="top"><td valign="top" width="1%"><h2 class="epydoc"><a name="D">D</a></h2></td>
<td valign="top">
<table class="link-index" width="100%" border="1">
<tr>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#COUNTRY_BEGIN">COUNTRY_BEGIN</a><br />
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#DATABASE_INFO_MAX_SIZE">DATABASE_INFO_MAX_SIZE</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#COUNTRY_EDITION">COUNTRY_EDITION</a><br />
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#DMA_MAP">DMA_MAP</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index">&nbsp;</td>
</tr>
<tr><td class="link-index">&nbsp;</td><td class="link-index">&nbsp;</td><td class="link-index">&nbsp;</td></tr>
</table>
</td></tr>
<tr valign="top"><td valign="top" width="1%"><h2 class="epydoc"><a name="D">D</a></h2></td>
<tr valign="top"><td valign="top" width="1%"><h2 class="epydoc"><a name="E">E</a></h2></td>
<td valign="top">
<table class="link-index" width="100%" border="1">
<tr>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#DATABASE_INFO_MAX_SIZE">DATABASE_INFO_MAX_SIZE</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#DMA_MAP">DMA_MAP</a><br />
<td width="33%" class="link-index"><a href="pygeoip-module.html#ENCODING">ENCODING</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip-module.html">pygeoip</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#ENCODING">ENCODING</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index">&nbsp;</td>
</tr>
......@@ -196,13 +210,21 @@
<td valign="top">
<table class="link-index" width="100%" border="1">
<tr>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#id_by_addr">id_by_addr()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.util-module.html#ip2long_v4">ip2long_v4()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.util-module.html">pygeoip.util</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#IPV6_EDITIONS">IPV6_EDITIONS</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip.util-module.html#ip2long">ip2long()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.util-module.html">pygeoip.util</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.util-module.html#ip2long_v6">ip2long_v6()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.util-module.html">pygeoip.util</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#ISP_EDITION">ISP_EDITION</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index">&nbsp;</td>
</tr>
<tr><td class="link-index">&nbsp;</td><td class="link-index">&nbsp;</td><td class="link-index">&nbsp;</td></tr>
</table>
</td></tr>
<tr valign="top"><td valign="top" width="1%"><h2 class="epydoc"><a name="M">M</a></h2></td>
......@@ -263,10 +285,16 @@
<tr>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#PROXY_EDITION">PROXY_EDITION</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#PY3">PY3</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index">&nbsp;</td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#PY2">PY2</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip-module.html">pygeoip</a></td>
<td width="33%" class="link-index">&nbsp;</td>
</tr>
<tr><td class="link-index">&nbsp;</td><td class="link-index">&nbsp;</td><td class="link-index">&nbsp;</td></tr>
</table>
</td></tr>
<tr valign="top"><td valign="top" width="1%"><h2 class="epydoc"><a name="R">R</a></h2></td>
......@@ -275,18 +303,25 @@
<tr>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#record_by_addr">record_by_addr()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#region_by_addr">region_by_addr()</a><br />
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#region_by_name">region_by_name()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#REGION_EDITION_REV0">REGION_EDITION_REV0</a><br />
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#REGION_EDITION_REV1">REGION_EDITION_REV1</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#record_by_name">record_by_name()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#region_by_name">region_by_name()</a><br />
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#REGION_CITY_EDITIONS">REGION_CITY_EDITIONS</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#REGION_EDITIONS">REGION_EDITIONS</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#region_by_addr">region_by_addr()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#REGION_EDITION_REV1">REGION_EDITION_REV1</a><br />
<td width="33%" class="link-index"><a href="pygeoip.const-module.html#REGION_EDITION_REV0">REGION_EDITION_REV0</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.const-module.html">pygeoip.const</a>)</span></td>
<td width="33%" class="link-index">&nbsp;</td>
</tr>
</table>
</td></tr>
......@@ -369,16 +404,16 @@
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.util-module.html#__package__">__package__</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.util-module.html">pygeoip.util</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.GeoIPMetaclass-class.html#_instances">_instances</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIPMetaclass-class.html">GeoIPMetaclass</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#_gethostbyname">_gethostbyname()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip.GeoIPMetaclass-class.html#__new__">__new__()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIPMetaclass-class.html">GeoIPMetaclass</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.timezone-module.html#_country">_country</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.timezone-module.html">pygeoip.timezone</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.GeoIP-class.html#_lookup_country_id">_lookup_country_id()</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIP-class.html">GeoIP</a>)</span></td>
<td width="33%" class="link-index"><a href="pygeoip.GeoIPMetaclass-class.html#_instances">_instances</a><br />
<span class="index-where">(in&nbsp;<a href="pygeoip.GeoIPMetaclass-class.html">GeoIPMetaclass</a>)</span></td>
</tr>
<tr>
<td width="33%" class="link-index"><a href="pygeoip-module.html#__package__">__package__</a><br />
......@@ -437,7 +472,7 @@
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -60,11 +60,11 @@
</b></center><br />
<h1 class="epydoc">Module Hierarchy</h1>
<ul class="nomargin-top">
<li> <strong class="uidlink"><a href="pygeoip-module.html">pygeoip</a></strong>: <em class="summary">Pure Python GeoIP API.</em>
<li> <strong class="uidlink"><a href="pygeoip-module.html">pygeoip</a></strong>: <em class="summary">Pure Python GeoIP API</em>
<ul>
<li> <strong class="uidlink"><a href="pygeoip.const-module.html">pygeoip.const</a></strong>: <em class="summary">Constants needed for parsing binary GeoIP databases.</em> </li>
<li> <strong class="uidlink"><a href="pygeoip.timezone-module.html">pygeoip.timezone</a></strong> </li>
<li> <strong class="uidlink"><a href="pygeoip.util-module.html">pygeoip.util</a></strong>: <em class="summary">Misc.</em> </li>
<li> <strong class="uidlink"><a href="pygeoip.const-module.html">pygeoip.const</a></strong>: <em class="summary">Constants needed for the binary parser.</em> </li>
<li> <strong class="uidlink"><a href="pygeoip.timezone-module.html">pygeoip.timezone</a></strong>: <em class="summary">Time zone functions.</em> </li>
<li> <strong class="uidlink"><a href="pygeoip.util-module.html">pygeoip.util</a></strong>: <em class="summary">Utility functions.</em> </li>
</ul>
</li>
</ul>
......@@ -99,7 +99,7 @@
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -60,21 +60,14 @@
</table>
<!-- ==================== PACKAGE DESCRIPTION ==================== -->
<h1 class="epydoc">Package pygeoip</h1><p class="nomargin-top"><span class="codelink"><a href="pygeoip-pysrc.html">source&nbsp;code</a></span></p>
<p>Pure Python GeoIP API. The API is based off of <a
href="http://www.maxmind.com/app/python" target="_top">MaxMind's C-based
Python API</a>, but the code itself is based on the <a
href="http://pear.php.net/package/Net_GeoIP/" target="_top">pure PHP5
API</a> by Jim Winstead and Hans Lellelid.</p>
<p>It is mostly a drop-in replacement, except the <code>new</code> and
<code>open</code> methods are gone. You should instantiate the <a
href="pygeoip.GeoIP-class.html" class="link">GeoIP</a> class
yourself:</p>
<p><code>gi = GeoIP('/path/to/GeoIP.dat',
pygeoip.MEMORY_CACHE)</code></p>
<p>Pure Python GeoIP API</p>
<p>The API is based on MaxMind's C-based Python API, but the code itself
is ported from the Pure PHP GeoIP API by Jim Winstead and Hans
Lellelid.</p>
<hr />
<div class="fields"> <p><strong>Author:</strong>
Jennifer Ennis &lt;zaylea at gmail dot com&gt;
Jennifer Ennis &lt;zaylea@gmail.com&gt;
</p>
<p><strong>License:</strong>
Copyright(C) 2004 MaxMind LLC
......@@ -109,9 +102,9 @@
</tr>
<tr><td class="summary">
<ul class="nomargin">
<li> <strong class="uidlink"><a href="pygeoip.const-module.html">pygeoip.const</a></strong>: <em class="summary">Constants needed for parsing binary GeoIP databases.</em> </li>
<li> <strong class="uidlink"><a href="pygeoip.timezone-module.html">pygeoip.timezone</a></strong> </li>
<li> <strong class="uidlink"><a href="pygeoip.util-module.html">pygeoip.util</a></strong>: <em class="summary">Misc.</em> </li>
<li> <strong class="uidlink"><a href="pygeoip.const-module.html">pygeoip.const</a></strong>: <em class="summary">Constants needed for the binary parser.</em> </li>
<li> <strong class="uidlink"><a href="pygeoip.timezone-module.html">pygeoip.timezone</a></strong>: <em class="summary">Time zone functions.</em> </li>
<li> <strong class="uidlink"><a href="pygeoip.util-module.html">pygeoip.util</a></strong>: <em class="summary">Utility functions.</em> </li>
</ul></td></tr>
</table>
......@@ -183,6 +176,13 @@
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="STANDARD"></a><span class="summary-name">STANDARD</span> = <code title="0">0</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="MMAP_CACHE"></a><span class="summary-name">MMAP_CACHE</span> = <code title="8">8</code>
</td>
</tr>
......@@ -197,7 +197,7 @@
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="STANDARD"></a><span class="summary-name">STANDARD</span> = <code title="0">0</code>
<a name="ENCODING"></a><span class="summary-name">ENCODING</span> = <code title="'iso-8859-1'"><code class="variable-quote">'</code><code class="variable-string">iso-8859-1</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
......@@ -239,7 +239,7 @@
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -112,7 +112,7 @@ object --+
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="_setup_segments"></a><span class="summary-sig-name">_setup_segments</span>(<span class="summary-sig-arg">self</span>)</span><br />
<td><span class="summary-sig"><a href="pygeoip.GeoIP-class.html#_setup_segments" class="summary-sig-name" onclick="show_private();">_setup_segments</a>(<span class="summary-sig-arg">self</span>)</span><br />
Parses the database file to determine what kind of database is being
used and setup segment sizes and start points that will be used by
the seek*() methods later.</td>
......@@ -131,24 +131,6 @@ object --+
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pygeoip.GeoIP-class.html#_lookup_country_id" class="summary-sig-name" onclick="show_private();">_lookup_country_id</a>(<span class="summary-sig-arg">self</span>,
<span class="summary-sig-arg">addr</span>)</span><br />
Get the country index.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pygeoip-pysrc.html#GeoIP._lookup_country_id">source&nbsp;code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr class="private">
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">int</span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pygeoip.GeoIP-class.html#_seek_country" class="summary-sig-name" onclick="show_private();">_seek_country</a>(<span class="summary-sig-arg">self</span>,
<span class="summary-sig-arg">ipnum</span>)</span><br />
Using the record length and appropriate start points, seek to the
......@@ -170,7 +152,7 @@ object --+
<tr>
<td><span class="summary-sig"><a href="pygeoip.GeoIP-class.html#_get_org" class="summary-sig-name" onclick="show_private();">_get_org</a>(<span class="summary-sig-arg">self</span>,
<span class="summary-sig-arg">ipnum</span>)</span><br />
Seek and return organization (or ISP) name for converted IP addr.</td>
Seek and return organization or ISP name for ipnum.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pygeoip-pysrc.html#GeoIP._get_org">source&nbsp;code</a></span>
......@@ -217,6 +199,41 @@ object --+
</td>
</tr>
<tr class="private">
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="_gethostbyname"></a><span class="summary-sig-name">_gethostbyname</span>(<span class="summary-sig-arg">self</span>,
<span class="summary-sig-arg">hostname</span>)</span></td>
<td align="right" valign="top">
<span class="codelink"><a href="pygeoip-pysrc.html#GeoIP._gethostbyname">source&nbsp;code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">int</span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pygeoip.GeoIP-class.html#id_by_addr" class="summary-sig-name">id_by_addr</a>(<span class="summary-sig-arg">self</span>,
<span class="summary-sig-arg">addr</span>)</span><br />
Get the country index.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pygeoip-pysrc.html#GeoIP.id_by_addr">source&nbsp;code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">str</span>
......@@ -297,7 +314,7 @@ object --+
<tr>
<td><span class="summary-sig"><a href="pygeoip.GeoIP-class.html#org_by_addr" class="summary-sig-name">org_by_addr</a>(<span class="summary-sig-arg">self</span>,
<span class="summary-sig-arg">addr</span>)</span><br />
Lookup the organization (or ISP) for given IP address.</td>
Lookup Organization, ISP or ASNum for given IP address.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pygeoip-pysrc.html#GeoIP.org_by_addr">source&nbsp;code</a></span>
......@@ -516,12 +533,11 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>filename</code></strong> (str) - path to a geoip database. If MEMORY_CACHE is used, the file can
be gzipped.</li>
<li><strong class="pname"><code>flags</code></strong> (int) - flags that affect how the database is processed. Currently the
only supported flags are STANDARD (the default), MEMORY_CACHE
(preload the whole file into memory), and MMAP_CACHE (access the
file via mmap).</li>
<li><strong class="pname"><code>filename</code></strong> (str) - Path to a geoip database.</li>
<li><strong class="pname"><code>flags</code></strong> (int) - Flags that affect how the database is processed. Currently
supported flags are STANDARD (the default), MEMORY_CACHE (preload
the whole file into memory) and MMAP_CACHE (access the file via
mmap).</li>
</ul></dd>
<dt>Overrides:
object.__init__
......@@ -529,32 +545,28 @@ object --+
</dl>
</td></tr></table>
</div>
<a name="_lookup_country_id"></a>
<a name="_setup_segments"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">_lookup_country_id</span>(<span class="sig-arg">self</span>,
<span class="sig-arg">addr</span>)</span>
<h3 class="epydoc"><span class="sig"><span class="sig-name">_setup_segments</span>(<span class="sig-arg">self</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pygeoip-pysrc.html#GeoIP._lookup_country_id">source&nbsp;code</a></span>&nbsp;
><span class="codelink"><a href="pygeoip-pysrc.html#GeoIP._setup_segments">source&nbsp;code</a></span>&nbsp;
</td>
</tr></table>
<p>Get the country index.</p>
<p>This method is called by the _lookupCountryCode and _lookupCountryName
methods. It looks up the index ('id') for the country which is the key
for the code and name.</p>
<p>Parses the database file to determine what kind of database is being
used and setup segment sizes and start points that will be used by the
seek*() methods later.</p>
<p>Supported databases:</p>
<p>* COUNTRY_EDITION * COUNTRY_EDITION_V6 * REGION_EDITION_REV0 *
REGION_EDITION_REV1 * CITY_EDITION_REV0 * CITY_EDITION_REV1 * ORG_EDITION
* ISP_EDITION * ASNUM_EDITION</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>addr</code></strong> (str) - The IP address</li>
</ul></dd>
<dt>Returns: int</dt>
<dd>network byte order 32-bit integer</dd>
</dl>
</td></tr></table>
</div>
......@@ -600,7 +612,7 @@ object --+
</td>
</tr></table>
<p>Seek and return organization (or ISP) name for converted IP addr.</p>
<p>Seek and return organization or ISP name for ipnum.</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
......@@ -631,7 +643,7 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>ipnum</code></strong> (int) - converted IP address</li>
<li><strong class="pname"><code>ipnum</code></strong> (int) - Converted IP address</li>
</ul></dd>
<dt>Returns: dict</dt>
<dd>dict containing country_code and region_name</dd>
......@@ -657,7 +669,7 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>ipnum</code></strong> (int) - converted IP address</li>
<li><strong class="pname"><code>ipnum</code></strong> (int) - Converted IP address</li>
</ul></dd>
<dt>Returns: dict</dt>
<dd>dict with country_code, country_code3, country_name, region,
......@@ -666,6 +678,33 @@ object --+
</dl>
</td></tr></table>
</div>
<a name="id_by_addr"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">id_by_addr</span>(<span class="sig-arg">self</span>,
<span class="sig-arg">addr</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pygeoip-pysrc.html#GeoIP.id_by_addr">source&nbsp;code</a></span>&nbsp;
</td>
</tr></table>
<p>Get the country index. Looks up the index for the country which is the
key for the code and name.</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>addr</code></strong> (str) - The IP address</li>
</ul></dd>
<dt>Returns: int</dt>
<dd>network byte order 32-bit integer</dd>
</dl>
</td></tr></table>
</div>
<a name="country_code_by_addr"></a>
<div>
<table class="details" border="1" cellpadding="3"
......@@ -713,7 +752,7 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>hostname</code></strong> (str) - host name</li>
<li><strong class="pname"><code>hostname</code></strong> (str) - Hostname</li>
</ul></dd>
<dt>Returns: str</dt>
<dd>2-letter country code</dd>
......@@ -767,7 +806,7 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>hostname</code></strong> (str) - host name</li>
<li><strong class="pname"><code>hostname</code></strong> (str) - Hostname</li>
</ul></dd>
<dt>Returns: str</dt>
<dd>country name</dd>
......@@ -789,8 +828,8 @@ object --+
</td>
</tr></table>
<p>Lookup the organization (or ISP) for given IP address. Use this method
if you have an Organization/ISP database.</p>
<p>Lookup Organization, ISP or ASNum for given IP address. Use this
method if you have an Organization, ISP or ASNum database.</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
......@@ -821,10 +860,10 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>hostname</code></strong> (str) - host name</li>
<li><strong class="pname"><code>hostname</code></strong> (str) - Hostname</li>
</ul></dd>
<dt>Returns: str</dt>
<dd>organization or ISP name</dd>
<dd>Organization or ISP name</dd>
</dl>
</td></tr></table>
</div>
......@@ -851,9 +890,9 @@ object --+
<li><strong class="pname"><code>addr</code></strong> (str) - IP address</li>
</ul></dd>
<dt>Returns: dict</dt>
<dd>dict with country_code, country_code3, country_name, region,
city, postal_code, latitude, longitude, dma_code, metro_code,
area_code, region_name, time_zone</dd>
<dd>Dictionary with country_code, country_code3, country_name,
region, city, postal_code, latitude, longitude, dma_code,
metro_code, area_code, region_name, time_zone</dd>
</dl>
</td></tr></table>
</div>
......@@ -877,12 +916,12 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>hostname</code></strong> (str) - host name</li>
<li><strong class="pname"><code>hostname</code></strong> (str) - Hostname</li>
</ul></dd>
<dt>Returns: dict</dt>
<dd>dict with country_code, country_code3, country_name, region,
city, postal_code, latitude, longitude, dma_code, metro_code,
area_code, region_name, time_zone</dd>
<dd>Dictionary with country_code, country_code3, country_name,
region, city, postal_code, latitude, longitude, dma_code,
metro_code, area_code, region_name, time_zone</dd>
</dl>
</td></tr></table>
</div>
......@@ -909,7 +948,7 @@ object --+
<li><strong class="pname"><code>addr</code></strong> (str) - IP address</li>
</ul></dd>
<dt>Returns: dict</dt>
<dd>dict containing country_code, region, and region_name</dd>
<dd>Dictionary containing country_code, region and region_name</dd>
</dl>
</td></tr></table>
</div>
......@@ -933,10 +972,10 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>hostname</code></strong> (str) - host name</li>
<li><strong class="pname"><code>hostname</code></strong> (str) - Hostname</li>
</ul></dd>
<dt>Returns: dict</dt>
<dd>dict containing country_code, region, and region_name</dd>
<dd>Dictionary containing country_code, region, and region_name</dd>
</dl>
</td></tr></table>
</div>
......@@ -987,7 +1026,7 @@ object --+
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>hostname</code></strong> (str) - host name</li>
<li><strong class="pname"><code>hostname</code></strong> (str) - Hostname</li>
</ul></dd>
<dt>Returns: str</dt>
<dd>Time zone</dd>
......@@ -1026,7 +1065,7 @@ object --+
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -167,7 +167,7 @@ object --+
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -177,7 +177,7 @@ exceptions.BaseException --+
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -337,7 +337,7 @@ object --+
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -61,12 +61,12 @@
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module const</h1><p class="nomargin-top"><span class="codelink"><a href="pygeoip.const-pysrc.html">source&nbsp;code</a></span></p>
<p>Constants needed for parsing binary GeoIP databases. It is part of the
pygeoip package.</p>
<p>Constants needed for the binary parser. Part of the pygeoip
package.</p>
<hr />
<div class="fields"> <p><strong>Author:</strong>
Jennifer Ennis &lt;zaylea at gmail dot com&gt;
Jennifer Ennis &lt;zaylea@gmail.com&gt;
</p>
<p><strong>License:</strong>
Copyright(C) 2004 MaxMind LLC
......@@ -103,6 +103,20 @@
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="PY2"></a><span class="summary-name">PY2</span> = <code title="True">True</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="PY3"></a><span class="summary-name">PY3</span> = <code title="False">False</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="GEOIP_STANDARD"></a><span class="summary-name">GEOIP_STANDARD</span> = <code title="0">0</code>
</td>
</tr>
......@@ -240,6 +254,13 @@
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="COUNTRY_EDITION_V6"></a><span class="summary-name">COUNTRY_EDITION_V6</span> = <code title="12">12</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="REGION_EDITION_REV0"></a><span class="summary-name">REGION_EDITION_REV0</span> = <code title="7">7</code>
</td>
</tr>
......@@ -282,14 +303,14 @@
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="PROXY_EDITION"></a><span class="summary-name">PROXY_EDITION</span> = <code title="8">8</code>
<a name="ASNUM_EDITION"></a><span class="summary-name">ASNUM_EDITION</span> = <code title="9">9</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="ASNUM_EDITION"></a><span class="summary-name">ASNUM_EDITION</span> = <code title="9">9</code>
<a name="PROXY_EDITION"></a><span class="summary-name">PROXY_EDITION</span> = <code title="8">8</code>
</td>
</tr>
<tr>
......@@ -303,7 +324,28 @@
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="COUNTRY_EDITION_V6"></a><span class="summary-name">COUNTRY_EDITION_V6</span> = <code title="12">12</code>
<a name="IPV6_EDITIONS"></a><span class="summary-name">IPV6_EDITIONS</span> = <code title="(12)"><code class="variable-group">(</code>12<code class="variable-group">)</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="CITY_EDITIONS"></a><span class="summary-name">CITY_EDITIONS</span> = <code title="(6, 2)"><code class="variable-group">(</code>6<code class="variable-op">, </code>2<code class="variable-group">)</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="REGION_EDITIONS"></a><span class="summary-name">REGION_EDITIONS</span> = <code title="(7, 3)"><code class="variable-group">(</code>7<code class="variable-op">, </code>3<code class="variable-group">)</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="REGION_CITY_EDITIONS"></a><span class="summary-name">REGION_CITY_EDITIONS</span> = <code title="(7, 3, 6, 2)"><code class="variable-group">(</code>7<code class="variable-op">, </code>3<code class="variable-op">, </code>6<code class="variable-op">, </code>2<code class="variable-group">)</code></code>
</td>
</tr>
<tr>
......@@ -380,7 +422,14 @@
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="__package__"></a><span class="summary-name">__package__</span> = <code title="None">None</code>
<a name="ENCODING"></a><span class="summary-name">ENCODING</span> = <code title="'iso-8859-1'"><code class="variable-quote">'</code><code class="variable-string">iso-8859-1</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'pygeoip'"><code class="variable-quote">'</code><code class="variable-string">pygeoip</code><code class="variable-quote">'</code></code>
</td>
</tr>
</table>
......@@ -538,7 +587,7 @@
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -61,7 +61,27 @@
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module timezone</h1><p class="nomargin-top"><span class="codelink"><a href="pygeoip.timezone-pysrc.html">source&nbsp;code</a></span></p>
<!-- ==================== FUNCTIONS ==================== -->
<p>Time zone functions. Part of the pygeoip package.</p>
<hr />
<div class="fields"> <p><strong>Author:</strong>
Jennifer Ennis &lt;zaylea@gmail.com&gt;
</p>
<p><strong>License:</strong>
Copyright(C) 2004 MaxMind LLC
<p>This program is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.</p>
<p>You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
&lt;http://www.gnu.org/licenses/lgpl.txt&gt;.</p>
</p>
</div><!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
......@@ -212,7 +232,7 @@
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -61,11 +61,11 @@
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module util</h1><p class="nomargin-top"><span class="codelink"><a href="pygeoip.util-pysrc.html">source&nbsp;code</a></span></p>
<p>Misc. utility functions. It is part of the pygeoip package.</p>
<p>Utility functions. Part of the pygeoip package.</p>
<hr />
<div class="fields"> <p><strong>Author:</strong>
Jennifer Ennis &lt;zaylea at gmail dot com&gt;
Jennifer Ennis &lt;zaylea@gmail.com&gt;
</p>
<p><strong>License:</strong>
Copyright(C) 2004 MaxMind LLC
......@@ -100,12 +100,12 @@
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">int</span>
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pygeoip.util-module.html#ip2long" class="summary-sig-name">ip2long</a>(<span class="summary-sig-arg">ip</span>)</span><br />
Convert a IPv4 address into a 32-bit integer.</td>
Wrapper function for IPv4 and IPv6 converters</td>
<td align="right" valign="top">
<span class="codelink"><a href="pygeoip.util-pysrc.html#ip2long">source&nbsp;code</a></span>
......@@ -115,6 +115,40 @@
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">int</span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pygeoip.util-module.html#ip2long_v4" class="summary-sig-name">ip2long_v4</a>(<span class="summary-sig-arg">ip</span>)</span><br />
Convert a IPv4 address into a 32-bit integer.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pygeoip.util-pysrc.html#ip2long_v4">source&nbsp;code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">long</span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="pygeoip.util-module.html#ip2long_v6" class="summary-sig-name">ip2long_v6</a>(<span class="summary-sig-arg">ip</span>)</span><br />
Convert a IPv6 address into long.</td>
<td align="right" valign="top">
<span class="codelink"><a href="pygeoip.util-pysrc.html#ip2long_v6">source&nbsp;code</a></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
......@@ -173,6 +207,29 @@
</td>
</tr></table>
<p>Wrapper function for IPv4 and IPv6 converters</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>ip</code></strong> (str) - IPv4 or IPv6 address</li>
</ul></dd>
</dl>
</td></tr></table>
</div>
<a name="ip2long_v4"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">ip2long_v4</span>(<span class="sig-arg">ip</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pygeoip.util-pysrc.html#ip2long_v4">source&nbsp;code</a></span>&nbsp;
</td>
</tr></table>
<p>Convert a IPv4 address into a 32-bit integer.</p>
<dl class="fields">
<dt>Parameters:</dt>
......@@ -184,6 +241,31 @@
</dl>
</td></tr></table>
</div>
<a name="ip2long_v6"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">ip2long_v6</span>(<span class="sig-arg">ip</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="pygeoip.util-pysrc.html#ip2long_v6">source&nbsp;code</a></span>&nbsp;
</td>
</tr></table>
<p>Convert a IPv6 address into long.</p>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>ip</code></strong> (str) - IPv6 address</li>
</ul></dd>
<dt>Returns: long</dt>
<dd>network byte order long</dd>
</dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
......@@ -216,7 +298,7 @@
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -61,48 +61,80 @@
</table>
<h1 class="epydoc">Source Code for <a href="pygeoip.util-module.html">Module pygeoip.util</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno"> 1</tt> <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L2"></a><tt class="py-lineno"> 2</tt> <tt class="py-line"><tt class="py-docstring">Misc. utility functions. It is part of the pygeoip package.</tt> </tt>
<a name="L3"></a><tt class="py-lineno"> 3</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L4"></a><tt class="py-lineno"> 4</tt> <tt class="py-line"><tt class="py-docstring">@author: Jennifer Ennis &lt;zaylea at gmail dot com&gt;</tt> </tt>
<a name="L5"></a><tt class="py-lineno"> 5</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L6"></a><tt class="py-lineno"> 6</tt> <tt class="py-line"><tt class="py-docstring">@license:</tt> </tt>
<a name="L7"></a><tt class="py-lineno"> 7</tt> <tt class="py-line"><tt class="py-docstring">Copyright(C) 2004 MaxMind LLC</tt> </tt>
<a name="L8"></a><tt class="py-lineno"> 8</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L9"></a><tt class="py-lineno"> 9</tt> <tt class="py-line"><tt class="py-docstring">This program is free software: you can redistribute it and/or modify</tt> </tt>
<a name="L10"></a><tt class="py-lineno">10</tt> <tt class="py-line"><tt class="py-docstring">it under the terms of the GNU Lesser General Public License as published by</tt> </tt>
<a name="L11"></a><tt class="py-lineno">11</tt> <tt class="py-line"><tt class="py-docstring">the Free Software Foundation, either version 3 of the License, or</tt> </tt>
<a name="L12"></a><tt class="py-lineno">12</tt> <tt class="py-line"><tt class="py-docstring">(at your option) any later version.</tt> </tt>
<a name="L13"></a><tt class="py-lineno">13</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L14"></a><tt class="py-lineno">14</tt> <tt class="py-line"><tt class="py-docstring">This program is distributed in the hope that it will be useful,</tt> </tt>
<a name="L15"></a><tt class="py-lineno">15</tt> <tt class="py-line"><tt class="py-docstring">but WITHOUT ANY WARRANTY; without even the implied warranty of</tt> </tt>
<a name="L16"></a><tt class="py-lineno">16</tt> <tt class="py-line"><tt class="py-docstring">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</tt> </tt>
<a name="L17"></a><tt class="py-lineno">17</tt> <tt class="py-line"><tt class="py-docstring">GNU General Public License for more details.</tt> </tt>
<a name="L18"></a><tt class="py-lineno">18</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L19"></a><tt class="py-lineno">19</tt> <tt class="py-line"><tt class="py-docstring">You should have received a copy of the GNU Lesser General Public License</tt> </tt>
<a name="L20"></a><tt class="py-lineno">20</tt> <tt class="py-line"><tt class="py-docstring">along with this program. If not, see &lt;http://www.gnu.org/licenses/lgpl.txt&gt;.</tt> </tt>
<a name="L1"></a><tt class="py-lineno"> 1</tt> <tt class="py-line"><tt class="py-comment"># -*- coding: utf-8 -*-</tt> </tt>
<a name="L2"></a><tt class="py-lineno"> 2</tt> <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L3"></a><tt class="py-lineno"> 3</tt> <tt class="py-line"><tt class="py-docstring">Utility functions. Part of the pygeoip package.</tt> </tt>
<a name="L4"></a><tt class="py-lineno"> 4</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L5"></a><tt class="py-lineno"> 5</tt> <tt class="py-line"><tt class="py-docstring">@author: Jennifer Ennis &lt;zaylea@gmail.com&gt;</tt> </tt>
<a name="L6"></a><tt class="py-lineno"> 6</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L7"></a><tt class="py-lineno"> 7</tt> <tt class="py-line"><tt class="py-docstring">@license: Copyright(C) 2004 MaxMind LLC</tt> </tt>
<a name="L8"></a><tt class="py-lineno"> 8</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L9"></a><tt class="py-lineno"> 9</tt> <tt class="py-line"><tt class="py-docstring">This program is free software: you can redistribute it and/or modify</tt> </tt>
<a name="L10"></a><tt class="py-lineno">10</tt> <tt class="py-line"><tt class="py-docstring">it under the terms of the GNU Lesser General Public License as published by</tt> </tt>
<a name="L11"></a><tt class="py-lineno">11</tt> <tt class="py-line"><tt class="py-docstring">the Free Software Foundation, either version 3 of the License, or</tt> </tt>
<a name="L12"></a><tt class="py-lineno">12</tt> <tt class="py-line"><tt class="py-docstring">(at your option) any later version.</tt> </tt>
<a name="L13"></a><tt class="py-lineno">13</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L14"></a><tt class="py-lineno">14</tt> <tt class="py-line"><tt class="py-docstring">This program is distributed in the hope that it will be useful,</tt> </tt>
<a name="L15"></a><tt class="py-lineno">15</tt> <tt class="py-line"><tt class="py-docstring">but WITHOUT ANY WARRANTY; without even the implied warranty of</tt> </tt>
<a name="L16"></a><tt class="py-lineno">16</tt> <tt class="py-line"><tt class="py-docstring">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</tt> </tt>
<a name="L17"></a><tt class="py-lineno">17</tt> <tt class="py-line"><tt class="py-docstring">GNU General Public License for more details.</tt> </tt>
<a name="L18"></a><tt class="py-lineno">18</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L19"></a><tt class="py-lineno">19</tt> <tt class="py-line"><tt class="py-docstring">You should have received a copy of the GNU Lesser General Public License</tt> </tt>
<a name="L20"></a><tt class="py-lineno">20</tt> <tt class="py-line"><tt class="py-docstring">along with this program. If not, see &lt;http://www.gnu.org/licenses/lgpl.txt&gt;.</tt> </tt>
<a name="L21"></a><tt class="py-lineno">21</tt> <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L22"></a><tt class="py-lineno">22</tt> <tt class="py-line"> </tt>
<a name="L23"></a><tt class="py-lineno">23</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">six</tt> </tt>
<a name="L24"></a><tt class="py-lineno">24</tt> <tt class="py-line"> </tt>
<a name="ip2long"></a><div id="ip2long-def"><a name="L25"></a><tt class="py-lineno">25</tt> <a class="py-toggle" href="#" id="ip2long-toggle" onclick="return toggle('ip2long');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pygeoip.util-module.html#ip2long">ip2long</a><tt class="py-op">(</tt><tt class="py-param">ip</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ip2long-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="ip2long-expanded"><a name="L26"></a><tt class="py-lineno">26</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L27"></a><tt class="py-lineno">27</tt> <tt class="py-line"><tt class="py-docstring"> Convert a IPv4 address into a 32-bit integer.</tt> </tt>
<a name="L28"></a><tt class="py-lineno">28</tt> <tt class="py-line"><tt class="py-docstring"> </tt> </tt>
<a name="L29"></a><tt class="py-lineno">29</tt> <tt class="py-line"><tt class="py-docstring"> @param ip: quad-dotted IPv4 address</tt> </tt>
<a name="L30"></a><tt class="py-lineno">30</tt> <tt class="py-line"><tt class="py-docstring"> @type ip: str</tt> </tt>
<a name="L31"></a><tt class="py-lineno">31</tt> <tt class="py-line"><tt class="py-docstring"> @return: network byte order 32-bit integer</tt> </tt>
<a name="L32"></a><tt class="py-lineno">32</tt> <tt class="py-line"><tt class="py-docstring"> @rtype: int</tt> </tt>
<a name="L33"></a><tt class="py-lineno">33</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L34"></a><tt class="py-lineno">34</tt> <tt class="py-line"> <tt class="py-name">ip_array</tt> <tt class="py-op">=</tt> <tt class="py-name">ip</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-string">'.'</tt><tt class="py-op">)</tt> </tt>
<a name="L35"></a><tt class="py-lineno">35</tt> <tt class="py-line"> </tt>
<a name="L36"></a><tt class="py-lineno">36</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">six</tt><tt class="py-op">.</tt><tt class="py-name">PY3</tt><tt class="py-op">:</tt> </tt>
<a name="L37"></a><tt class="py-lineno">37</tt> <tt class="py-line"> <tt class="py-comment"># int and long are unified in py3</tt> </tt>
<a name="L38"></a><tt class="py-lineno">38</tt> <tt class="py-line"> <tt class="py-name">ip_long</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">16777216</tt> <tt class="py-op">+</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">65536</tt> <tt class="py-op">+</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">256</tt> <tt class="py-op">+</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">3</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L39"></a><tt class="py-lineno">39</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L40"></a><tt class="py-lineno">40</tt> <tt class="py-line"> <tt class="py-name">ip_long</tt> <tt class="py-op">=</tt> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">16777216</tt> <tt class="py-op">+</tt> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">65536</tt> <tt class="py-op">+</tt> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">256</tt> <tt class="py-op">+</tt> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">3</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L41"></a><tt class="py-lineno">41</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">ip_long</tt> </tt>
</div><a name="L42"></a><tt class="py-lineno">42</tt> <tt class="py-line"> </tt><script type="text/javascript">
<a name="L23"></a><tt class="py-lineno">23</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">struct</tt> </tt>
<a name="L24"></a><tt class="py-lineno">24</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">socket</tt> </tt>
<a name="L25"></a><tt class="py-lineno">25</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">array</tt> <tt class="py-keyword">import</tt> <tt class="py-name">array</tt> </tt>
<a name="L26"></a><tt class="py-lineno">26</tt> <tt class="py-line"> </tt>
<a name="L27"></a><tt class="py-lineno">27</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-0" class="py-name" targets="Package pygeoip=pygeoip-module.html"><a title="pygeoip" class="py-name" href="#" onclick="return doclink('link-0', 'pygeoip', 'link-0');">pygeoip</a></tt><tt class="py-op">.</tt><tt id="link-1" class="py-name" targets="Module pygeoip.const=pygeoip.const-module.html"><a title="pygeoip.const" class="py-name" href="#" onclick="return doclink('link-1', 'const', 'link-1');">const</a></tt> <tt class="py-keyword">import</tt> <tt id="link-2" class="py-name" targets="Variable pygeoip.const.PY3=pygeoip.const-module.html#PY3"><a title="pygeoip.const.PY3" class="py-name" href="#" onclick="return doclink('link-2', 'PY3', 'link-2');">PY3</a></tt> </tt>
<a name="L28"></a><tt class="py-lineno">28</tt> <tt class="py-line"> </tt>
<a name="L29"></a><tt class="py-lineno">29</tt> <tt class="py-line"> </tt>
<a name="ip2long"></a><div id="ip2long-def"><a name="L30"></a><tt class="py-lineno">30</tt> <a class="py-toggle" href="#" id="ip2long-toggle" onclick="return toggle('ip2long');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pygeoip.util-module.html#ip2long">ip2long</a><tt class="py-op">(</tt><tt class="py-param">ip</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ip2long-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="ip2long-expanded"><a name="L31"></a><tt class="py-lineno">31</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L32"></a><tt class="py-lineno">32</tt> <tt class="py-line"><tt class="py-docstring"> Wrapper function for IPv4 and IPv6 converters</tt> </tt>
<a name="L33"></a><tt class="py-lineno">33</tt> <tt class="py-line"><tt class="py-docstring"> @param ip: IPv4 or IPv6 address</tt> </tt>
<a name="L34"></a><tt class="py-lineno">34</tt> <tt class="py-line"><tt class="py-docstring"> @type ip: str</tt> </tt>
<a name="L35"></a><tt class="py-lineno">35</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L36"></a><tt class="py-lineno">36</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">ip</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">':'</tt><tt class="py-op">)</tt> <tt class="py-op">&gt;=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L37"></a><tt class="py-lineno">37</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-3" class="py-name" targets="Function pygeoip.util.ip2long_v6()=pygeoip.util-module.html#ip2long_v6"><a title="pygeoip.util.ip2long_v6" class="py-name" href="#" onclick="return doclink('link-3', 'ip2long_v6', 'link-3');">ip2long_v6</a></tt><tt class="py-op">(</tt><tt class="py-name">ip</tt><tt class="py-op">)</tt> </tt>
<a name="L38"></a><tt class="py-lineno">38</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L39"></a><tt class="py-lineno">39</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-4" class="py-name" targets="Function pygeoip.util.ip2long_v4()=pygeoip.util-module.html#ip2long_v4"><a title="pygeoip.util.ip2long_v4" class="py-name" href="#" onclick="return doclink('link-4', 'ip2long_v4', 'link-4');">ip2long_v4</a></tt><tt class="py-op">(</tt><tt class="py-name">ip</tt><tt class="py-op">)</tt> </tt>
</div><a name="L40"></a><tt class="py-lineno">40</tt> <tt class="py-line"> </tt>
<a name="L41"></a><tt class="py-lineno">41</tt> <tt class="py-line"> </tt>
<a name="ip2long_v4"></a><div id="ip2long_v4-def"><a name="L42"></a><tt class="py-lineno">42</tt> <a class="py-toggle" href="#" id="ip2long_v4-toggle" onclick="return toggle('ip2long_v4');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pygeoip.util-module.html#ip2long_v4">ip2long_v4</a><tt class="py-op">(</tt><tt class="py-param">ip</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ip2long_v4-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="ip2long_v4-expanded"><a name="L43"></a><tt class="py-lineno">43</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L44"></a><tt class="py-lineno">44</tt> <tt class="py-line"><tt class="py-docstring"> Convert a IPv4 address into a 32-bit integer.</tt> </tt>
<a name="L45"></a><tt class="py-lineno">45</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L46"></a><tt class="py-lineno">46</tt> <tt class="py-line"><tt class="py-docstring"> @param ip: quad-dotted IPv4 address</tt> </tt>
<a name="L47"></a><tt class="py-lineno">47</tt> <tt class="py-line"><tt class="py-docstring"> @type ip: str</tt> </tt>
<a name="L48"></a><tt class="py-lineno">48</tt> <tt class="py-line"><tt class="py-docstring"> @return: network byte order 32-bit integer</tt> </tt>
<a name="L49"></a><tt class="py-lineno">49</tt> <tt class="py-line"><tt class="py-docstring"> @rtype: int</tt> </tt>
<a name="L50"></a><tt class="py-lineno">50</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L51"></a><tt class="py-lineno">51</tt> <tt class="py-line"> <tt class="py-name">ip_array</tt> <tt class="py-op">=</tt> <tt class="py-name">ip</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-string">'.'</tt><tt class="py-op">)</tt> </tt>
<a name="L52"></a><tt class="py-lineno">52</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-5" class="py-name"><a title="pygeoip.const.PY3" class="py-name" href="#" onclick="return doclink('link-5', 'PY3', 'link-2');">PY3</a></tt><tt class="py-op">:</tt> </tt>
<a name="L53"></a><tt class="py-lineno">53</tt> <tt class="py-line"> <tt class="py-comment"># int and long are unified in py3</tt> </tt>
<a name="L54"></a><tt class="py-lineno">54</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">16777216</tt> <tt class="py-op">+</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">65536</tt> <tt class="py-op">+</tt> \ </tt>
<a name="L55"></a><tt class="py-lineno">55</tt> <tt class="py-line"> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">256</tt> <tt class="py-op">+</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">3</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
<a name="L56"></a><tt class="py-lineno">56</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L57"></a><tt class="py-lineno">57</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">16777216</tt> <tt class="py-op">+</tt> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">65536</tt> <tt class="py-op">+</tt> \ </tt>
<a name="L58"></a><tt class="py-lineno">58</tt> <tt class="py-line"> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">*</tt> <tt class="py-number">256</tt> <tt class="py-op">+</tt> <tt class="py-name">long</tt><tt class="py-op">(</tt><tt class="py-name">ip_array</tt><tt class="py-op">[</tt><tt class="py-number">3</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
</div><a name="L59"></a><tt class="py-lineno">59</tt> <tt class="py-line"> </tt>
<a name="L60"></a><tt class="py-lineno">60</tt> <tt class="py-line"> </tt>
<a name="ip2long_v6"></a><div id="ip2long_v6-def"><a name="L61"></a><tt class="py-lineno">61</tt> <a class="py-toggle" href="#" id="ip2long_v6-toggle" onclick="return toggle('ip2long_v6');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pygeoip.util-module.html#ip2long_v6">ip2long_v6</a><tt class="py-op">(</tt><tt class="py-param">ip</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="ip2long_v6-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="ip2long_v6-expanded"><a name="L62"></a><tt class="py-lineno">62</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L63"></a><tt class="py-lineno">63</tt> <tt class="py-line"><tt class="py-docstring"> Convert a IPv6 address into long.</tt> </tt>
<a name="L64"></a><tt class="py-lineno">64</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L65"></a><tt class="py-lineno">65</tt> <tt class="py-line"><tt class="py-docstring"> @param ip: IPv6 address</tt> </tt>
<a name="L66"></a><tt class="py-lineno">66</tt> <tt class="py-line"><tt class="py-docstring"> @type ip: str</tt> </tt>
<a name="L67"></a><tt class="py-lineno">67</tt> <tt class="py-line"><tt class="py-docstring"> @return: network byte order long</tt> </tt>
<a name="L68"></a><tt class="py-lineno">68</tt> <tt class="py-line"><tt class="py-docstring"> @rtype: long</tt> </tt>
<a name="L69"></a><tt class="py-lineno">69</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L70"></a><tt class="py-lineno">70</tt> <tt class="py-line"> <tt class="py-name">ipbyte</tt> <tt class="py-op">=</tt> <tt class="py-name">socket</tt><tt class="py-op">.</tt><tt class="py-name">inet_pton</tt><tt class="py-op">(</tt><tt class="py-name">socket</tt><tt class="py-op">.</tt><tt class="py-name">AF_INET6</tt><tt class="py-op">,</tt> <tt class="py-name">ip</tt><tt class="py-op">)</tt> </tt>
<a name="L71"></a><tt class="py-lineno">71</tt> <tt class="py-line"> <tt class="py-name">ipnum</tt> <tt class="py-op">=</tt> <tt class="py-name">array</tt><tt class="py-op">(</tt><tt class="py-string">'L'</tt><tt class="py-op">,</tt> <tt class="py-name">struct</tt><tt class="py-op">.</tt><tt class="py-name">unpack</tt><tt class="py-op">(</tt><tt class="py-string">'!4L'</tt><tt class="py-op">,</tt> <tt class="py-name">ipbyte</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L72"></a><tt class="py-lineno">72</tt> <tt class="py-line"> <tt class="py-name">max_index</tt> <tt class="py-op">=</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">ipnum</tt><tt class="py-op">)</tt> <tt class="py-op">-</tt> <tt class="py-number">1</tt> </tt>
<a name="L73"></a><tt class="py-lineno">73</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">sum</tt><tt class="py-op">(</tt><tt class="py-name">ipnum</tt><tt class="py-op">[</tt><tt class="py-name">max_index</tt> <tt class="py-op">-</tt> <tt class="py-name">i</tt><tt class="py-op">]</tt> <tt class="py-op">&lt;&lt;</tt> <tt class="py-op">(</tt><tt class="py-name">i</tt> <tt class="py-op">*</tt> <tt class="py-number">32</tt><tt class="py-op">)</tt> <tt class="py-keyword">for</tt> <tt class="py-name">i</tt> <tt class="py-keyword">in</tt> <tt class="py-name">range</tt><tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">ipnum</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L74"></a><tt class="py-lineno">74</tt> <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
......@@ -140,7 +172,7 @@ expandto(location.href);
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Sep 20 17:58:04 2012
Generated by Epydoc 3.0.1 on Sun Sep 30 13:48:03 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -20,14 +20,18 @@
>pygeoip.GeoIPMetaclass</a><br /> <h2 class="toc">All Functions</h2>
<a target="mainFrame" href="pygeoip.timezone-module.html#time_zone_by_country_and_region"
>pygeoip.timezone.time_zone_by_country_and_region</a><br /> <a target="mainFrame" href="pygeoip.util-module.html#ip2long"
>pygeoip.util.ip2long</a><br /> <h2 class="toc">All Variables</h2>
<a target="mainFrame" href="pygeoip-module.html#MEMORY_CACHE"
>pygeoip.util.ip2long</a><br /> <a target="mainFrame" href="pygeoip.util-module.html#ip2long_v4"
>pygeoip.util.ip2long_v4</a><br /> <a target="mainFrame" href="pygeoip.util-module.html#ip2long_v6"
>pygeoip.util.ip2long_v6</a><br /> <h2 class="toc">All Variables</h2>
<a target="mainFrame" href="pygeoip-module.html#ENCODING"
>pygeoip.ENCODING</a><br /> <a target="mainFrame" href="pygeoip-module.html#MEMORY_CACHE"
>pygeoip.MEMORY_CACHE</a><br /> <a target="mainFrame" href="pygeoip-module.html#MMAP_CACHE"
>pygeoip.MMAP_CACHE</a><br /> <a target="mainFrame" href="pygeoip-module.html#STANDARD"
>pygeoip.STANDARD</a><br /> <a target="mainFrame" href="pygeoip-module.html#__package__"
>pygeoip.__package__</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ASNUM_EDITION"
>pygeoip.const.ASNUM_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CANADA_OFFSET"
>pygeoip.const.CANADA_OFFSET</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CITY_EDITION_REV0"
>pygeoip.const.CANADA_OFFSET</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CITY_EDITIONS"
>pygeoip.const.CITY_EDITIONS</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CITY_EDITION_REV0"
>pygeoip.const.CITY_EDITION_REV0</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CITY_EDITION_REV1"
>pygeoip.const.CITY_EDITION_REV1</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#COUNTRY_BEGIN"
>pygeoip.const.COUNTRY_BEGIN</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#COUNTRY_CODES"
......@@ -37,11 +41,13 @@
>pygeoip.const.COUNTRY_EDITION_V6</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#COUNTRY_NAMES"
>pygeoip.const.COUNTRY_NAMES</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#DATABASE_INFO_MAX_SIZE"
>pygeoip.const.DATABASE_INFO_MAX_SIZE</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#DMA_MAP"
>pygeoip.const.DMA_MAP</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#FIPS_RANGE"
>pygeoip.const.DMA_MAP</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ENCODING"
>pygeoip.const.ENCODING</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#FIPS_RANGE"
>pygeoip.const.FIPS_RANGE</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#FULL_RECORD_LENGTH"
>pygeoip.const.FULL_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#GEOIP_MEMORY_CACHE"
>pygeoip.const.GEOIP_MEMORY_CACHE</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#GEOIP_STANDARD"
>pygeoip.const.GEOIP_STANDARD</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ISP_EDITION"
>pygeoip.const.GEOIP_STANDARD</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#IPV6_EDITIONS"
>pygeoip.const.IPV6_EDITIONS</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ISP_EDITION"
>pygeoip.const.ISP_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#MAX_ORG_RECORD_LENGTH"
>pygeoip.const.MAX_ORG_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#MAX_RECORD_LENGTH"
>pygeoip.const.MAX_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#MEMORY_CACHE"
......@@ -50,7 +56,11 @@
>pygeoip.const.NETSPEED_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ORG_EDITION"
>pygeoip.const.ORG_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ORG_RECORD_LENGTH"
>pygeoip.const.ORG_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#PROXY_EDITION"
>pygeoip.const.PROXY_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_EDITION_REV0"
>pygeoip.const.PROXY_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#PY2"
>pygeoip.const.PY2</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#PY3"
>pygeoip.const.PY3</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_CITY_EDITIONS"
>pygeoip.const.REGION_CITY_EDITIONS</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_EDITIONS"
>pygeoip.const.REGION_EDITIONS</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_EDITION_REV0"
>pygeoip.const.REGION_EDITION_REV0</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_EDITION_REV1"
>pygeoip.const.REGION_EDITION_REV1</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#SEGMENT_RECORD_LENGTH"
>pygeoip.const.SEGMENT_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#STANDARD"
......
......@@ -18,7 +18,8 @@
>GeoIPBase</a><br /> <a target="mainFrame" href="pygeoip.GeoIPError-class.html"
>GeoIPError</a><br /> <a target="mainFrame" href="pygeoip.GeoIPMetaclass-class.html"
>GeoIPMetaclass</a><br /> <h2 class="toc">Variables</h2>
<a target="mainFrame" href="pygeoip-module.html#MEMORY_CACHE"
<a target="mainFrame" href="pygeoip-module.html#ENCODING"
>ENCODING</a><br /> <a target="mainFrame" href="pygeoip-module.html#MEMORY_CACHE"
>MEMORY_CACHE</a><br /> <a target="mainFrame" href="pygeoip-module.html#MMAP_CACHE"
>MMAP_CACHE</a><br /> <a target="mainFrame" href="pygeoip-module.html#STANDARD"
>STANDARD</a><br /> <a target="mainFrame" href="pygeoip-module.html#__package__"
......
......@@ -15,7 +15,8 @@
<h2 class="toc">Variables</h2>
<a target="mainFrame" href="pygeoip.const-module.html#ASNUM_EDITION"
>ASNUM_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CANADA_OFFSET"
>CANADA_OFFSET</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CITY_EDITION_REV0"
>CANADA_OFFSET</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CITY_EDITIONS"
>CITY_EDITIONS</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CITY_EDITION_REV0"
>CITY_EDITION_REV0</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#CITY_EDITION_REV1"
>CITY_EDITION_REV1</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#COUNTRY_BEGIN"
>COUNTRY_BEGIN</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#COUNTRY_CODES"
......@@ -25,11 +26,13 @@
>COUNTRY_EDITION_V6</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#COUNTRY_NAMES"
>COUNTRY_NAMES</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#DATABASE_INFO_MAX_SIZE"
>DATABASE_INFO_MAX_SIZE</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#DMA_MAP"
>DMA_MAP</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#FIPS_RANGE"
>DMA_MAP</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ENCODING"
>ENCODING</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#FIPS_RANGE"
>FIPS_RANGE</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#FULL_RECORD_LENGTH"
>FULL_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#GEOIP_MEMORY_CACHE"
>GEOIP_MEMORY_CACHE</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#GEOIP_STANDARD"
>GEOIP_STANDARD</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ISP_EDITION"
>GEOIP_STANDARD</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#IPV6_EDITIONS"
>IPV6_EDITIONS</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ISP_EDITION"
>ISP_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#MAX_ORG_RECORD_LENGTH"
>MAX_ORG_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#MAX_RECORD_LENGTH"
>MAX_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#MEMORY_CACHE"
......@@ -38,7 +41,11 @@
>NETSPEED_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ORG_EDITION"
>ORG_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#ORG_RECORD_LENGTH"
>ORG_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#PROXY_EDITION"
>PROXY_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_EDITION_REV0"
>PROXY_EDITION</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#PY2"
>PY2</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#PY3"
>PY3</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_CITY_EDITIONS"
>REGION_CITY_EDITIONS</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_EDITIONS"
>REGION_EDITIONS</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_EDITION_REV0"
>REGION_EDITION_REV0</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#REGION_EDITION_REV1"
>REGION_EDITION_REV1</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#SEGMENT_RECORD_LENGTH"
>SEGMENT_RECORD_LENGTH</a><br /> <a target="mainFrame" href="pygeoip.const-module.html#STANDARD"
......
......@@ -14,7 +14,9 @@
<hr />
<h2 class="toc">Functions</h2>
<a target="mainFrame" href="pygeoip.util-module.html#ip2long"
>ip2long</a><br /> <h2 class="toc">Variables</h2>
>ip2long</a><br /> <a target="mainFrame" href="pygeoip.util-module.html#ip2long_v4"
>ip2long_v4</a><br /> <a target="mainFrame" href="pygeoip.util-module.html#ip2long_v6"
>ip2long_v6</a><br /> <h2 class="toc">Variables</h2>
<a target="mainFrame" href="pygeoip.util-module.html#__package__"
>__package__</a><br /><hr />
<span class="options">[<a href="javascript:void(0);" class="privatelink"
......
# -*- coding: utf-8 -*-
"""
Pure Python GeoIP API. The API is based off of U{MaxMind's C-based Python API<http://www.maxmind.com/app/python>},
but the code itself is based on the U{pure PHP5 API<http://pear.php.net/package/Net_GeoIP/>}
by Jim Winstead and Hans Lellelid.
Pure Python GeoIP API
It is mostly a drop-in replacement, except the
C{new} and C{open} methods are gone. You should instantiate the L{GeoIP} class yourself:
The API is based on MaxMind's C-based Python API, but the code itself is
ported from the Pure PHP GeoIP API by Jim Winstead and Hans Lellelid.
C{gi = GeoIP('/path/to/GeoIP.dat', pygeoip.MEMORY_CACHE)}
@author: Jennifer Ennis <zaylea@gmail.com>
@author: Jennifer Ennis <zaylea at gmail dot com>
@license:
Copyright(C) 2004 MaxMind LLC
@license: Copyright(C) 2004 MaxMind LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
......@@ -27,28 +23,28 @@ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
"""
from __future__ import with_statement, division
import os
import six
import math
import socket
import mmap
import gzip
import codecs
from threading import Lock
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from io import StringIO, BytesIO
import pygeoip.const
from pygeoip.util import ip2long
from pygeoip import util, const
from pygeoip.const import PY2, PY3
from pygeoip.timezone import time_zone_by_country_and_region
STANDARD = const.STANDARD
MMAP_CACHE = const.MMAP_CACHE
MEMORY_CACHE = const.MEMORY_CACHE
STANDARD = const.STANDARD
ENCODING = const.ENCODING
class GeoIPError(Exception):
......@@ -60,11 +56,10 @@ class GeoIPMetaclass(type):
"""
Singleton method to gets an instance without reparsing the db. Unique
instances are instantiated based on the filename of the db. Flags are
ignored for this, i.e. if you initialize one with STANDARD flag (default)
and then try later to initialize with MEMORY_CACHE, it will still
return the STANDARD one.
ignored for this, i.e. if you initialize one with STANDARD
flag (default) and then try later to initialize with MEMORY_CACHE, it
will still return the STANDARD one.
"""
if not hasattr(cls, '_instances'):
cls._instances = {}
......@@ -73,7 +68,7 @@ class GeoIPMetaclass(type):
elif 'filename' in kwargs:
filename = kwargs['filename']
if not filename in cls._instances:
if filename not in cls._instances:
cls._instances[filename] = type.__new__(cls, *args, **kwargs)
return cls._instances[filename]
......@@ -87,12 +82,11 @@ class GeoIP(GeoIPBase):
"""
Initialize the class.
@param filename: path to a geoip database. If MEMORY_CACHE is used,
the file can be gzipped.
@param filename: Path to a geoip database.
@type filename: str
@param flags: flags that affect how the database is processed.
Currently the only supported flags are STANDARD (the default),
MEMORY_CACHE (preload the whole file into memory), and
@param flags: Flags that affect how the database is processed.
Currently supported flags are STANDARD (the default),
MEMORY_CACHE (preload the whole file into memory) and
MMAP_CACHE (access the file via mmap).
@type flags: int
"""
......@@ -100,42 +94,69 @@ class GeoIP(GeoIPBase):
self._flags = flags
if self._flags & const.MMAP_CACHE:
with open(filename, 'rb') as f:
self._filehandle = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
f = open(filename, 'rb')
access = mmap.ACCESS_READ
self._filehandle = mmap.mmap(f.fileno(), 0, access=access)
f.close()
elif self._flags & const.MEMORY_CACHE:
if filename.endswith('.gz'):
opener = gzip.open
else:
opener = open
with opener(filename, 'rb') as f:
f = open(filename, 'rb')
self._memoryBuffer = f.read()
self._filehandle = StringIO(self._memoryBuffer)
iohandle = BytesIO if PY3 else StringIO
self._filehandle = iohandle(self._memoryBuffer)
f.close()
else:
self._filehandle = codecs.open(filename, 'rb','latin_1')
self._filehandle = codecs.open(filename, 'rb', ENCODING)
self._lock = Lock()
self._setup_segments()
def _setup_segments(self):
"""
Parses the database file to determine what kind of database is being used and setup
segment sizes and start points that will be used by the seek*() methods later.
Parses the database file to determine what kind of database is
being used and setup segment sizes and start points that will
be used by the seek*() methods later.
Supported databases:
* COUNTRY_EDITION
* COUNTRY_EDITION_V6
* REGION_EDITION_REV0
* REGION_EDITION_REV1
* CITY_EDITION_REV0
* CITY_EDITION_REV1
* ORG_EDITION
* ISP_EDITION
* ASNUM_EDITION
"""
self._databaseType = const.COUNTRY_EDITION
self._recordLength = const.STANDARD_RECORD_LENGTH
self._databaseSegments = const.COUNTRY_BEGIN
self._lock.acquire()
filepos = self._filehandle.tell()
self._filehandle.seek(-3, os.SEEK_END)
for i in range(const.STRUCTURE_INFO_MAX_SIZE):
chars = chr(255) * 3
delim = self._filehandle.read(3)
if delim == six.u(chr(255) * 3):
self._databaseType = ord(self._filehandle.read(1))
if PY3 and type(delim) is bytes:
delim = delim.decode(ENCODING)
if PY2:
chars = chars.decode(ENCODING)
if type(delim) is str:
delim = delim.decode(ENCODING)
if delim == chars:
byte = self._filehandle.read(1)
self._databaseType = ord(byte)
# Compatibility with databases from April 2003 and earlier
if (self._databaseType >= 106):
# backwards compatibility with databases from April 2003 and earlier
self._databaseType -= 105
if self._databaseType == const.REGION_EDITION_REV0:
......@@ -152,45 +173,21 @@ class GeoIP(GeoIPBase):
self._databaseSegments = 0
buf = self._filehandle.read(const.SEGMENT_RECORD_LENGTH)
if PY3 and type(buf) is bytes:
buf = buf.decode(ENCODING)
for j in range(const.SEGMENT_RECORD_LENGTH):
self._databaseSegments += (ord(buf[j]) << (j * 8))
if self._databaseType in (const.ORG_EDITION, const.ISP_EDITION):
LONG_RECORDS = (const.ORG_EDITION, const.ISP_EDITION)
if self._databaseType in LONG_RECORDS:
self._recordLength = const.ORG_RECORD_LENGTH
break
else:
self._filehandle.seek(-4, os.SEEK_CUR)
if self._databaseType == const.COUNTRY_EDITION:
self._databaseSegments = const.COUNTRY_BEGIN
self._filehandle.seek(filepos, os.SEEK_SET)
def _lookup_country_id(self, addr):
"""
Get the country index.
This method is called by the _lookupCountryCode and _lookupCountryName
methods. It looks up the index ('id') for the country which is the key
for the code and name.
@param addr: The IP address
@type addr: str
@return: network byte order 32-bit integer
@rtype: int
"""
ipnum = ip2long(addr)
if not ipnum:
raise ValueError("Invalid IP address: %s" % addr)
if self._databaseType != const.COUNTRY_EDITION:
raise GeoIPError('Invalid database type; country_* methods expect '\
'Country database')
return self._seek_country(ipnum) - const.COUNTRY_BEGIN
self._lock.release()
def _seek_country(self, ipnum):
"""
......@@ -203,116 +200,115 @@ class GeoIP(GeoIPBase):
@rtype: int
"""
offset = 0
seek_depth = 127 if len(str(ipnum)) > 10 else 31
for depth in range(31, -1, -1):
for depth in range(seek_depth, -1, -1):
if self._flags & const.MEMORY_CACHE:
startIndex = 2 * self._recordLength * offset
length = 2 * self._recordLength
endIndex = startIndex + length
endIndex = startIndex + (2 * self._recordLength)
buf = self._memoryBuffer[startIndex:endIndex]
else:
self._filehandle.seek(2 * self._recordLength * offset, os.SEEK_SET)
buf = self._filehandle.read(2 * self._recordLength)
startIndex = 2 * self._recordLength * offset
readLength = 2 * self._recordLength
self._lock.acquire()
self._filehandle.seek(startIndex, os.SEEK_SET)
buf = self._filehandle.read(readLength)
self._lock.release()
x = [0,0]
if PY3 and type(buf) is bytes:
buf = buf.decode(ENCODING)
x = [0, 0]
for i in range(2):
for j in range(self._recordLength):
x[i] += ord(buf[self._recordLength * i + j]) << (j * 8)
byte = buf[self._recordLength * i + j]
x[i] += ord(byte) << (j * 8)
if ipnum & (1 << depth):
if x[1] >= self._databaseSegments:
return x[1]
offset = x[1]
else:
if x[0] >= self._databaseSegments:
return x[0]
offset = x[0]
raise Exception('Error traversing database - perhaps it is corrupt?')
raise GeoIPError('Corrupt database')
def _get_org(self, ipnum):
"""
Seek and return organization (or ISP) name for converted IP addr.
Seek and return organization or ISP name for ipnum.
@param ipnum: Converted IP address
@type ipnum: int
@return: org/isp name
@rtype: str
"""
seek_org = self._seek_country(ipnum)
if seek_org == self._databaseSegments:
return None
record_pointer = seek_org + (2 * self._recordLength - 1) * self._databaseSegments
self._filehandle.seek(record_pointer, os.SEEK_SET)
read_length = (2 * self._recordLength - 1) * self._databaseSegments
self._lock.acquire()
self._filehandle.seek(seek_org + read_length, os.SEEK_SET)
buf = self._filehandle.read(const.MAX_ORG_RECORD_LENGTH)
self._lock.release()
org_buf = self._filehandle.read(const.MAX_ORG_RECORD_LENGTH)
if PY3 and type(buf) is bytes:
buf = buf.decode(ENCODING)
return org_buf[:org_buf.index(chr(0))]
return buf[:buf.index(chr(0))]
def _get_region(self, ipnum):
"""
Seek and return the region info (dict containing country_code and region_name).
Seek and return the region info (dict containing country_code
and region_name).
@param ipnum: converted IP address
@param ipnum: Converted IP address
@type ipnum: int
@return: dict containing country_code and region_name
@rtype: dict
"""
country_code = ''
region = ''
country_code = ''
seek_country = self._seek_country(ipnum)
def get_region_name(offset):
region1 = chr(offset // 26 + 65)
region2 = chr(offset % 26 + 65)
return ''.join([region1, region2])
if self._databaseType == const.REGION_EDITION_REV0:
seek_country = self._seek_country(ipnum)
seek_region = seek_country - const.STATE_BEGIN_REV0
if seek_region >= 1000:
country_code = 'US'
region = ''.join([chr((seek_region - 1000) // 26 + 65), chr((seek_region - 1000) % 26 + 65)])
region = get_region_name(seek_region - 1000)
else:
country_code = const.COUNTRY_CODES[seek_region]
region = ''
elif self._databaseType == const.REGION_EDITION_REV1:
seek_country = self._seek_country(ipnum)
seek_region = seek_country - const.STATE_BEGIN_REV1
if seek_region < const.US_OFFSET:
country_code = '';
region = ''
pass
elif seek_region < const.CANADA_OFFSET:
country_code = 'US'
region = ''.join([chr((seek_region - const.US_OFFSET) // 26 + 65), chr((seek_region - const.US_OFFSET) % 26 + 65)])
region = get_region_name(seek_region - const.US_OFFSET)
elif seek_region < const.WORLD_OFFSET:
country_code = 'CA'
region = ''.join([chr((seek_region - const.CANADA_OFFSET) // 26 + 65), chr((seek_region - const.CANADA_OFFSET) % 26 + 65)])
region = get_region_name(seek_region - const.CANADA_OFFSET)
else:
i = (seek_region - const.WORLD_OFFSET) // const.FIPS_RANGE
if i < len(const.COUNTRY_CODES):
#country_code = const.COUNTRY_CODES[(seek_region - const.WORLD_OFFSET) // const.FIPS_RANGE]
country_code = const.COUNTRY_CODES[i]
else:
country_code = ''
region = ''
elif self._databaseType in (const.CITY_EDITION_REV0, const.CITY_EDITION_REV1):
index = (seek_region - const.WORLD_OFFSET) // const.FIPS_RANGE
if index in const.COUNTRY_CODES:
country_code = const.COUNTRY_CODES[index]
elif self._databaseType in const.CITY_EDITIONS:
rec = self._get_record(ipnum)
country_code = rec['country_code'] if 'country_code' in rec else ''
region = rec['region_name'] if 'region_name' in rec else ''
return {'country_code' : country_code, 'region_name' : region }
return {'country_code': country_code, 'region_name': region}
def _get_record(self, ipnum):
"""
Populate location dict for converted IP.
@param ipnum: converted IP address
@param ipnum: Converted IP address
@type ipnum: int
@return: dict with country_code, country_code3, country_name,
region, city, postal_code, latitude, longitude,
......@@ -323,107 +319,115 @@ class GeoIP(GeoIPBase):
if seek_country == self._databaseSegments:
return None
record_pointer = seek_country + (2 * self._recordLength - 1) * self._databaseSegments
read_length = (2 * self._recordLength - 1) * self._databaseSegments
self._lock.acquire()
self._filehandle.seek(seek_country + read_length, os.SEEK_SET)
buf = self._filehandle.read(const.FULL_RECORD_LENGTH)
self._lock.release()
self._filehandle.seek(record_pointer, os.SEEK_SET)
record_buf = self._filehandle.read(const.FULL_RECORD_LENGTH)
if PY3 and type(buf) is bytes:
buf = buf.decode(ENCODING)
record = {}
record = {
'dma_code': 0,
'area_code': 0,
'metro_code': '',
'postal_code': ''
}
record_buf_pos = 0
char = ord(record_buf[record_buf_pos])
#char = record_buf[record_buf_pos] if six.PY3 else ord(record_buf[record_buf_pos])
latitude = 0
longitude = 0
buf_pos = 0
# Get country
char = ord(buf[buf_pos])
record['country_code'] = const.COUNTRY_CODES[char]
record['country_code3'] = const.COUNTRY_CODES3[char]
record['country_name'] = const.COUNTRY_NAMES[char]
if const.CONTINENT_MAP.has_key(record['country_name']):
record['continent'] = const.CONTINENT_MAP[record['country_name']]
record_buf_pos += 1
str_length = 0
# get region
char = ord(record_buf[record_buf_pos+str_length])
while (char != 0):
str_length += 1
char = ord(record_buf[record_buf_pos+str_length])
if str_length > 0:
record['region_name'] = record_buf[record_buf_pos:record_buf_pos+str_length]
record['continent'] = const.CONTINENT_NAMES[char]
record_buf_pos += str_length + 1
str_length = 0
# get city
char = ord(record_buf[record_buf_pos+str_length])
buf_pos += 1
def get_data(buf, buf_pos):
offset = buf_pos
char = ord(buf[offset])
while (char != 0):
str_length += 1
char = ord(record_buf[record_buf_pos+str_length])
offset += 1
char = ord(buf[offset])
if offset > buf_pos:
return (offset, buf[buf_pos:offset])
return (offset, '')
if str_length > 0:
record['city'] = record_buf[record_buf_pos:record_buf_pos+str_length]
else:
record['city'] = ''
offset, record['region_name'] = get_data(buf, buf_pos)
offset, record['city'] = get_data(buf, offset + 1)
offset, record['postal_code'] = get_data(buf, offset + 1)
buf_pos = offset + 1
record_buf_pos += str_length + 1
str_length = 0
# get the postal code
char = ord(record_buf[record_buf_pos+str_length])
while (char != 0):
str_length += 1
char = ord(record_buf[record_buf_pos+str_length])
if str_length > 0:
record['postal_code'] = record_buf[record_buf_pos:record_buf_pos+str_length]
else:
record['postal_code'] = None
record_buf_pos += str_length + 1
str_length = 0
latitude = 0
longitude = 0
for j in range(3):
char = ord(record_buf[record_buf_pos])
record_buf_pos += 1
char = ord(buf[buf_pos])
buf_pos += 1
latitude += (char << (j * 8))
record['latitude'] = (latitude/10000.0) - 180.0
for j in range(3):
char = ord(record_buf[record_buf_pos])
record_buf_pos += 1
char = ord(buf[buf_pos])
buf_pos += 1
longitude += (char << (j * 8))
record['longitude'] = (longitude/10000.0) - 180.0
record['latitude'] = (latitude / 10000.0) - 180.0
record['longitude'] = (longitude / 10000.0) - 180.0
if self._databaseType == const.CITY_EDITION_REV1:
dmaarea_combo = 0
if record['country_code'] == 'US':
for j in range(3):
char = ord(record_buf[record_buf_pos])
record_buf_pos += 1
dmaarea_combo += (char << (j*8))
char = ord(buf[buf_pos])
dmaarea_combo += (char << (j * 8))
buf_pos += 1
record['dma_code'] = int(math.floor(dmaarea_combo/1000))
record['area_code'] = dmaarea_combo%1000
else:
record['dma_code'] = 0
record['area_code'] = 0
record['dma_code'] = int(math.floor(dmaarea_combo / 1000))
record['area_code'] = dmaarea_combo % 1000
if 'dma_code' in record and record['dma_code'] in const.DMA_MAP:
if record['dma_code'] in const.DMA_MAP:
record['metro_code'] = const.DMA_MAP[record['dma_code']]
else:
record['metro_code'] = ''
if 'country_code' in record:
record['time_zone'] = time_zone_by_country_and_region(
record['country_code'], record.get('region_name')) or ''
else:
record['time_zone'] = ''
params = (record['country_code'], record['region_name'])
record['time_zone'] = time_zone_by_country_and_region(*params)
return record
def _gethostbyname(self, hostname):
if self._databaseType in const.IPV6_EDITIONS:
try:
response = socket.getaddrinfo(hostname, 0, socket.AF_INET6)
family, socktype, proto, canonname, sockaddr = response[0]
address, port, flow, scope = sockaddr
return address
except socket.gaierror:
return ''
else:
return socket.gethostbyname(hostname)
def id_by_addr(self, addr):
"""
Get the country index.
Looks up the index for the country which is the key for
the code and name.
@param addr: The IP address
@type addr: str
@return: network byte order 32-bit integer
@rtype: int
"""
ipnum = util.ip2long(addr)
if not ipnum:
raise ValueError("Invalid IP address: %s" % addr)
COUNTY_EDITIONS = (const.COUNTRY_EDITION, const.COUNTRY_EDITION_V6)
if self._databaseType not in COUNTY_EDITIONS:
message = 'Invalid database type, expected Country'
raise GeoIPError(message)
return self._seek_country(ipnum) - const.COUNTRY_BEGIN
def country_code_by_addr(self, addr):
"""
Returns 2-letter country code (e.g. 'US') for specified IP address.
......@@ -435,31 +439,39 @@ class GeoIP(GeoIPBase):
@rtype: str
"""
try:
if self._databaseType == const.COUNTRY_EDITION:
country_id = self._lookup_country_id(addr)
VALID_EDITIONS = (const.COUNTRY_EDITION, const.COUNTRY_EDITION_V6)
if self._databaseType in VALID_EDITIONS:
ipv = 6 if addr.find(':') >= 0 else 4
if ipv == 4 and self._databaseType != const.COUNTRY_EDITION:
message = 'Invalid database type; expected IPv6 address'
raise ValueError(message)
if ipv == 6 and self._databaseType != const.COUNTRY_EDITION_V6:
message = 'Invalid database type; expected IPv4 address'
raise ValueError(message)
country_id = self.id_by_addr(addr)
return const.COUNTRY_CODES[country_id]
elif self._databaseType in (const.REGION_EDITION_REV0, const.REGION_EDITION_REV1,
const.CITY_EDITION_REV0, const.CITY_EDITION_REV1):
elif self._databaseType in const.REGION_CITY_EDITIONS:
return self.region_by_addr(addr)['country_code']
else:
raise GeoIPError('Invalid database type; country_* methods expect '\
'Country, City, or Region database')
message = 'Invalid database type, expected Country, City or Region'
raise GeoIPError(message)
except ValueError:
raise GeoIPError('*_by_addr methods only accept IP addresses. Use *_by_name for hostnames. (Address: %s)' % addr)
raise GeoIPError('Failed to lookup address %s' % addr)
def country_code_by_name(self, hostname):
"""
Returns 2-letter country code (e.g. 'US') for specified hostname.
Use this method if you have a Country, Region, or City database.
@param hostname: host name
@param hostname: Hostname
@type hostname: str
@return: 2-letter country code
@rtype: str
"""
addr = socket.gethostbyname(hostname)
addr = self._gethostbyname(hostname)
return self.country_code_by_addr(addr)
def country_name_by_addr(self, addr):
......@@ -473,34 +485,34 @@ class GeoIP(GeoIPBase):
@rtype: str
"""
try:
if self._databaseType == const.COUNTRY_EDITION:
country_id = self._lookup_country_id(addr)
return const.COUNTRY_NAMES[country_id]
elif self._databaseType in (const.CITY_EDITION_REV0, const.CITY_EDITION_REV1):
VALID_EDITIONS = (const.COUNTRY_EDITION, const.COUNTRY_EDITION_V6)
if self._databaseType in VALID_EDITIONS:
return const.COUNTRY_NAMES[self.id_by_addr(addr)]
elif self._databaseType in const.CITY_EDITIONS:
return self.record_by_addr(addr)['country_name']
else:
raise GeoIPError('Invalid database type; country_* methods expect '\
'Country or City database')
message = 'Invalid database type, expected Country or City'
raise GeoIPError(message)
except ValueError:
raise GeoIPError('*_by_addr methods only accept IP addresses. Use *_by_name for hostnames. (Address: %s)' % addr)
raise GeoIPError('Failed to lookup address %s' % addr)
def country_name_by_name(self, hostname):
"""
Returns full country name for specified hostname.
Use this method if you have a Country database.
@param hostname: host name
@param hostname: Hostname
@type hostname: str
@return: country name
@rtype: str
"""
addr = socket.gethostbyname(hostname)
addr = self._gethostbyname(hostname)
return self.country_name_by_addr(addr)
def org_by_addr(self, addr):
"""
Lookup the organization (or ISP) for given IP address.
Use this method if you have an Organization/ISP database.
Lookup Organization, ISP or ASNum for given IP address.
Use this method if you have an Organization, ISP or ASNum database.
@param addr: IP address
@type addr: str
......@@ -508,31 +520,30 @@ class GeoIP(GeoIPBase):
@rtype: str
"""
try:
ipnum = ip2long(addr)
ipnum = util.ip2long(addr)
if not ipnum:
raise ValueError("Invalid IP address: %s" % addr)
raise ValueError('Invalid IP address')
if self._databaseType not in (const.ORG_EDITION, const.ISP_EDITION, const.ASNUM_EDITION):
raise GeoIPError('Invalid database type; org_* methods expect '\
'Org/ISP database')
valid = (const.ORG_EDITION, const.ISP_EDITION, const.ASNUM_EDITION)
if self._databaseType not in valid:
message = 'Invalid database type, expected Org, ISP or ASNum'
raise GeoIPError(message)
return self._get_org(ipnum)
except ValueError:
raise GeoIPError('*_by_addr methods only accept IP addresses. Use *_by_name for hostnames. (Address: %s)' % addr)
raise GeoIPError('Failed to lookup address %s' % addr)
def org_by_name(self, hostname):
"""
Lookup the organization (or ISP) for hostname.
Use this method if you have an Organization/ISP database.
@param hostname: host name
@param hostname: Hostname
@type hostname: str
@return: organization or ISP name
@return: Organization or ISP name
@rtype: str
"""
addr = socket.gethostbyname(hostname)
addr = self._gethostbyname(hostname)
return self.org_by_addr(addr)
def record_by_addr(self, addr):
......@@ -542,38 +553,37 @@ class GeoIP(GeoIPBase):
@param addr: IP address
@type addr: str
@return: dict with country_code, country_code3, country_name,
region, city, postal_code, latitude, longitude,
dma_code, metro_code, area_code, region_name, time_zone
@return: Dictionary with country_code, country_code3, country_name,
region, city, postal_code, latitude, longitude, dma_code,
metro_code, area_code, region_name, time_zone
@rtype: dict
"""
try:
ipnum = ip2long(addr)
ipnum = util.ip2long(addr)
if not ipnum:
raise ValueError("Invalid IP address: %s" % addr)
raise ValueError('Invalid IP address')
if not self._databaseType in (const.CITY_EDITION_REV0, const.CITY_EDITION_REV1):
raise GeoIPError('Invalid database type; record_* methods expect City database')
if self._databaseType not in const.CITY_EDITIONS:
message = 'Invalid database type, expected City'
raise GeoIPError(message)
return self._get_record(ipnum)
except ValueError:
raise GeoIPError('*_by_addr methods only accept IP addresses. Use *_by_name for hostnames. (Address: %s)' % addr)
raise GeoIPError('Failed to lookup address %s' % addr)
def record_by_name(self, hostname):
"""
Look up the record for a given hostname.
Use this method if you have a City database.
@param hostname: host name
@param hostname: Hostname
@type hostname: str
@return: dict with country_code, country_code3, country_name,
region, city, postal_code, latitude, longitude,
dma_code, metro_code, area_code, region_name, time_zone
@return: Dictionary with country_code, country_code3, country_name,
region, city, postal_code, latitude, longitude, dma_code,
metro_code, area_code, region_name, time_zone
@rtype: dict
"""
addr = socket.gethostbyname(hostname)
addr = self._gethostbyname(hostname)
return self.record_by_addr(addr)
def region_by_addr(self, addr):
......@@ -583,37 +593,33 @@ class GeoIP(GeoIPBase):
@param addr: IP address
@type addr: str
@return: dict containing country_code, region,
and region_name
@return: Dictionary containing country_code, region and region_name
@rtype: dict
"""
try:
ipnum = ip2long(addr)
ipnum = util.ip2long(addr)
if not ipnum:
raise ValueError("Invalid IP address: %s" % addr)
raise ValueError('Invalid IP address')
if not self._databaseType in (const.REGION_EDITION_REV0, const.REGION_EDITION_REV1,
const.CITY_EDITION_REV0, const.CITY_EDITION_REV1):
raise GeoIPError('Invalid database type; region_* methods expect '\
'Region or City database')
if self._databaseType not in const.REGION_CITY_EDITIONS:
message = 'Invalid database type, expected Region or City'
raise GeoIPError(message)
return self._get_region(ipnum)
except ValueError:
raise GeoIPError('*_by_addr methods only accept IP addresses. Use *_by_name for hostnames. (Address: %s)' % addr)
raise GeoIPError('Failed to lookup address %s' % addr)
def region_by_name(self, hostname):
"""
Lookup the region for given hostname.
Use this method if you have a Region database.
@param hostname: host name
@param hostname: Hostname
@type hostname: str
@return: dict containing country_code, region,
and region_name
@return: Dictionary containing country_code, region, and region_name
@rtype: dict
"""
addr = socket.gethostbyname(hostname)
addr = self._gethostbyname(hostname)
return self.region_by_addr(addr)
def time_zone_by_addr(self, addr):
......@@ -627,29 +633,27 @@ class GeoIP(GeoIPBase):
@rtype: str
"""
try:
ipnum = ip2long(addr)
ipnum = util.ip2long(addr)
if not ipnum:
raise ValueError("Invalid IP address: %s" % addr)
raise ValueError('Invalid IP address')
if not self._databaseType in (const.REGION_EDITION_REV0, const.REGION_EDITION_REV1,
const.CITY_EDITION_REV0, const.CITY_EDITION_REV1):
raise GeoIPError('Invalid database type; region_* methods expect '\
'Region or City database')
if self._databaseType not in const.CITY_EDITIONS:
message = 'Invalid database type, expected City'
raise GeoIPError(message)
return self._get_record(ipnum)['time_zone']
except ValueError:
raise GeoIPError('*_by_addr methods only accept IP addresses. Use *_by_name for hostnames. (Address: %s)' % addr)
raise GeoIPError('Failed to lookup address %s' % addr)
def time_zone_by_name(self, hostname):
"""
Look up the time zone for a given hostname.
Use this method if you have a Region or City database.
@param hostname: host name
@param hostname: Hostname
@type hostname: str
@return: Time zone
@rtype: str
"""
addr = socket.gethostbyname(hostname)
addr = self._gethostbyname(hostname)
return self.time_zone_by_addr(addr)
# -*- coding: utf-8 -*-
"""
Constants needed for parsing binary GeoIP databases. It is part of the pygeoip
package.
Constants needed for the binary parser. Part of the pygeoip package.
@author: Jennifer Ennis <zaylea at gmail dot com>
@author: Jennifer Ennis <zaylea@gmail.com>
@license:
Copyright(C) 2004 MaxMind LLC
@license: Copyright(C) 2004 MaxMind LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
......@@ -21,529 +20,366 @@ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
"""
from platform import python_version_tuple
PY2 = python_version_tuple()[0] == '2'
PY3 = python_version_tuple()[0] == '3'
GEOIP_STANDARD = 0
GEOIP_MEMORY_CACHE = 1
DMA_MAP = {
500 : 'Portland-Auburn, ME',
501 : 'New York, NY',
502 : 'Binghamton, NY',
503 : 'Macon, GA',
504 : 'Philadelphia, PA',
505 : 'Detroit, MI',
506 : 'Boston, MA',
507 : 'Savannah, GA',
508 : 'Pittsburgh, PA',
509 : 'Ft Wayne, IN',
510 : 'Cleveland, OH',
511 : 'Washington, DC',
512 : 'Baltimore, MD',
513 : 'Flint, MI',
514 : 'Buffalo, NY',
515 : 'Cincinnati, OH',
516 : 'Erie, PA',
517 : 'Charlotte, NC',
518 : 'Greensboro, NC',
519 : 'Charleston, SC',
520 : 'Augusta, GA',
521 : 'Providence, RI',
522 : 'Columbus, GA',
523 : 'Burlington, VT',
524 : 'Atlanta, GA',
525 : 'Albany, GA',
526 : 'Utica-Rome, NY',
527 : 'Indianapolis, IN',
528 : 'Miami, FL',
529 : 'Louisville, KY',
530 : 'Tallahassee, FL',
531 : 'Tri-Cities, TN',
532 : 'Albany-Schenectady-Troy, NY',
533 : 'Hartford, CT',
534 : 'Orlando, FL',
535 : 'Columbus, OH',
536 : 'Youngstown-Warren, OH',
537 : 'Bangor, ME',
538 : 'Rochester, NY',
539 : 'Tampa, FL',
540 : 'Traverse City-Cadillac, MI',
541 : 'Lexington, KY',
542 : 'Dayton, OH',
543 : 'Springfield-Holyoke, MA',
544 : 'Norfolk-Portsmouth, VA',
545 : 'Greenville-New Bern-Washington, NC',
546 : 'Columbia, SC',
547 : 'Toledo, OH',
548 : 'West Palm Beach, FL',
549 : 'Watertown, NY',
550 : 'Wilmington, NC',
551 : 'Lansing, MI',
552 : 'Presque Isle, ME',
553 : 'Marquette, MI',
554 : 'Wheeling, WV',
555 : 'Syracuse, NY',
556 : 'Richmond-Petersburg, VA',
557 : 'Knoxville, TN',
558 : 'Lima, OH',
559 : 'Bluefield-Beckley-Oak Hill, WV',
560 : 'Raleigh-Durham, NC',
561 : 'Jacksonville, FL',
563 : 'Grand Rapids, MI',
564 : 'Charleston-Huntington, WV',
565 : 'Elmira, NY',
566 : 'Harrisburg-Lancaster-Lebanon-York, PA',
567 : 'Greenville-Spartenburg, SC',
569 : 'Harrisonburg, VA',
570 : 'Florence-Myrtle Beach, SC',
571 : 'Ft Myers, FL',
573 : 'Roanoke-Lynchburg, VA',
574 : 'Johnstown-Altoona, PA',
575 : 'Chattanooga, TN',
576 : 'Salisbury, MD',
577 : 'Wilkes Barre-Scranton, PA',
581 : 'Terre Haute, IN',
582 : 'Lafayette, IN',
583 : 'Alpena, MI',
584 : 'Charlottesville, VA',
588 : 'South Bend, IN',
592 : 'Gainesville, FL',
596 : 'Zanesville, OH',
597 : 'Parkersburg, WV',
598 : 'Clarksburg-Weston, WV',
600 : 'Corpus Christi, TX',
602 : 'Chicago, IL',
603 : 'Joplin-Pittsburg, MO',
604 : 'Columbia-Jefferson City, MO',
605 : 'Topeka, KS',
606 : 'Dothan, AL',
609 : 'St Louis, MO',
610 : 'Rockford, IL',
611 : 'Rochester-Mason City-Austin, MN',
612 : 'Shreveport, LA',
613 : 'Minneapolis-St Paul, MN',
616 : 'Kansas City, MO',
617 : 'Milwaukee, WI',
618 : 'Houston, TX',
619 : 'Springfield, MO',
620 : 'Tuscaloosa, AL',
622 : 'New Orleans, LA',
623 : 'Dallas-Fort Worth, TX',
624 : 'Sioux City, IA',
625 : 'Waco-Temple-Bryan, TX',
626 : 'Victoria, TX',
627 : 'Wichita Falls, TX',
628 : 'Monroe, LA',
630 : 'Birmingham, AL',
631 : 'Ottumwa-Kirksville, IA',
632 : 'Paducah, KY',
633 : 'Odessa-Midland, TX',
634 : 'Amarillo, TX',
635 : 'Austin, TX',
636 : 'Harlingen, TX',
637 : 'Cedar Rapids-Waterloo, IA',
638 : 'St Joseph, MO',
639 : 'Jackson, TN',
640 : 'Memphis, TN',
641 : 'San Antonio, TX',
642 : 'Lafayette, LA',
643 : 'Lake Charles, LA',
644 : 'Alexandria, LA',
646 : 'Anniston, AL',
647 : 'Greenwood-Greenville, MS',
648 : 'Champaign-Springfield-Decatur, IL',
649 : 'Evansville, IN',
650 : 'Oklahoma City, OK',
651 : 'Lubbock, TX',
652 : 'Omaha, NE',
656 : 'Panama City, FL',
657 : 'Sherman, TX',
658 : 'Green Bay-Appleton, WI',
659 : 'Nashville, TN',
661 : 'San Angelo, TX',
662 : 'Abilene-Sweetwater, TX',
669 : 'Madison, WI',
670 : 'Ft Smith-Fay-Springfield, AR',
671 : 'Tulsa, OK',
673 : 'Columbus-Tupelo-West Point, MS',
675 : 'Peoria-Bloomington, IL',
676 : 'Duluth, MN',
678 : 'Wichita, KS',
679 : 'Des Moines, IA',
682 : 'Davenport-Rock Island-Moline, IL',
686 : 'Mobile, AL',
687 : 'Minot-Bismarck-Dickinson, ND',
691 : 'Huntsville, AL',
692 : 'Beaumont-Port Author, TX',
693 : 'Little Rock-Pine Bluff, AR',
698 : 'Montgomery, AL',
702 : 'La Crosse-Eau Claire, WI',
705 : 'Wausau-Rhinelander, WI',
709 : 'Tyler-Longview, TX',
710 : 'Hattiesburg-Laurel, MS',
711 : 'Meridian, MS',
716 : 'Baton Rouge, LA',
717 : 'Quincy, IL',
718 : 'Jackson, MS',
722 : 'Lincoln-Hastings, NE',
724 : 'Fargo-Valley City, ND',
725 : 'Sioux Falls, SD',
734 : 'Jonesboro, AR',
736 : 'Bowling Green, KY',
737 : 'Mankato, MN',
740 : 'North Platte, NE',
743 : 'Anchorage, AK',
744 : 'Honolulu, HI',
745 : 'Fairbanks, AK',
746 : 'Biloxi-Gulfport, MS',
747 : 'Juneau, AK',
749 : 'Laredo, TX',
751 : 'Denver, CO',
752 : 'Colorado Springs, CO',
753 : 'Phoenix, AZ',
754 : 'Butte-Bozeman, MT',
755 : 'Great Falls, MT',
756 : 'Billings, MT',
757 : 'Boise, ID',
758 : 'Idaho Falls-Pocatello, ID',
759 : 'Cheyenne, WY',
760 : 'Twin Falls, ID',
762 : 'Missoula, MT',
764 : 'Rapid City, SD',
765 : 'El Paso, TX',
766 : 'Helena, MT',
767 : 'Casper-Riverton, WY',
770 : 'Salt Lake City, UT',
771 : 'Yuma, AZ',
773 : 'Grand Junction, CO',
789 : 'Tucson, AZ',
790 : 'Albuquerque, NM',
798 : 'Glendive, MT',
800 : 'Bakersfield, CA',
801 : 'Eugene, OR',
802 : 'Eureka, CA',
803 : 'Los Angeles, CA',
804 : 'Palm Springs, CA',
807 : 'San Francisco, CA',
810 : 'Yakima-Pasco, WA',
811 : 'Reno, NV',
813 : 'Medford-Klamath Falls, OR',
819 : 'Seattle-Tacoma, WA',
820 : 'Portland, OR',
821 : 'Bend, OR',
825 : 'San Diego, CA',
828 : 'Monterey-Salinas, CA',
839 : 'Las Vegas, NV',
855 : 'Santa Barbara, CA',
862 : 'Sacramento, CA',
866 : 'Fresno, CA',
868 : 'Chico-Redding, CA',
881 : 'Spokane, WA'
}
500: 'Portland-Auburn, ME',
501: 'New York, NY',
502: 'Binghamton, NY',
503: 'Macon, GA',
504: 'Philadelphia, PA',
505: 'Detroit, MI',
506: 'Boston, MA',
507: 'Savannah, GA',
508: 'Pittsburgh, PA',
509: 'Ft Wayne, IN',
510: 'Cleveland, OH',
511: 'Washington, DC',
512: 'Baltimore, MD',
513: 'Flint, MI',
514: 'Buffalo, NY',
515: 'Cincinnati, OH',
516: 'Erie, PA',
517: 'Charlotte, NC',
518: 'Greensboro, NC',
519: 'Charleston, SC',
520: 'Augusta, GA',
521: 'Providence, RI',
522: 'Columbus, GA',
523: 'Burlington, VT',
524: 'Atlanta, GA',
525: 'Albany, GA',
526: 'Utica-Rome, NY',
527: 'Indianapolis, IN',
528: 'Miami, FL',
529: 'Louisville, KY',
530: 'Tallahassee, FL',
531: 'Tri-Cities, TN',
532: 'Albany-Schenectady-Troy, NY',
533: 'Hartford, CT',
534: 'Orlando, FL',
535: 'Columbus, OH',
536: 'Youngstown-Warren, OH',
537: 'Bangor, ME',
538: 'Rochester, NY',
539: 'Tampa, FL',
540: 'Traverse City-Cadillac, MI',
541: 'Lexington, KY',
542: 'Dayton, OH',
543: 'Springfield-Holyoke, MA',
544: 'Norfolk-Portsmouth, VA',
545: 'Greenville-New Bern-Washington, NC',
546: 'Columbia, SC',
547: 'Toledo, OH',
548: 'West Palm Beach, FL',
549: 'Watertown, NY',
550: 'Wilmington, NC',
551: 'Lansing, MI',
552: 'Presque Isle, ME',
553: 'Marquette, MI',
554: 'Wheeling, WV',
555: 'Syracuse, NY',
556: 'Richmond-Petersburg, VA',
557: 'Knoxville, TN',
558: 'Lima, OH',
559: 'Bluefield-Beckley-Oak Hill, WV',
560: 'Raleigh-Durham, NC',
561: 'Jacksonville, FL',
563: 'Grand Rapids, MI',
564: 'Charleston-Huntington, WV',
565: 'Elmira, NY',
566: 'Harrisburg-Lancaster-Lebanon-York, PA',
567: 'Greenville-Spartenburg, SC',
569: 'Harrisonburg, VA',
570: 'Florence-Myrtle Beach, SC',
571: 'Ft Myers, FL',
573: 'Roanoke-Lynchburg, VA',
574: 'Johnstown-Altoona, PA',
575: 'Chattanooga, TN',
576: 'Salisbury, MD',
577: 'Wilkes Barre-Scranton, PA',
581: 'Terre Haute, IN',
582: 'Lafayette, IN',
583: 'Alpena, MI',
584: 'Charlottesville, VA',
588: 'South Bend, IN',
592: 'Gainesville, FL',
596: 'Zanesville, OH',
597: 'Parkersburg, WV',
598: 'Clarksburg-Weston, WV',
600: 'Corpus Christi, TX',
602: 'Chicago, IL',
603: 'Joplin-Pittsburg, MO',
604: 'Columbia-Jefferson City, MO',
605: 'Topeka, KS',
606: 'Dothan, AL',
609: 'St Louis, MO',
610: 'Rockford, IL',
611: 'Rochester-Mason City-Austin, MN',
612: 'Shreveport, LA',
613: 'Minneapolis-St Paul, MN',
616: 'Kansas City, MO',
617: 'Milwaukee, WI',
618: 'Houston, TX',
619: 'Springfield, MO',
620: 'Tuscaloosa, AL',
622: 'New Orleans, LA',
623: 'Dallas-Fort Worth, TX',
624: 'Sioux City, IA',
625: 'Waco-Temple-Bryan, TX',
626: 'Victoria, TX',
627: 'Wichita Falls, TX',
628: 'Monroe, LA',
630: 'Birmingham, AL',
631: 'Ottumwa-Kirksville, IA',
632: 'Paducah, KY',
633: 'Odessa-Midland, TX',
634: 'Amarillo, TX',
635: 'Austin, TX',
636: 'Harlingen, TX',
637: 'Cedar Rapids-Waterloo, IA',
638: 'St Joseph, MO',
639: 'Jackson, TN',
640: 'Memphis, TN',
641: 'San Antonio, TX',
642: 'Lafayette, LA',
643: 'Lake Charles, LA',
644: 'Alexandria, LA',
646: 'Anniston, AL',
647: 'Greenwood-Greenville, MS',
648: 'Champaign-Springfield-Decatur, IL',
649: 'Evansville, IN',
650: 'Oklahoma City, OK',
651: 'Lubbock, TX',
652: 'Omaha, NE',
656: 'Panama City, FL',
657: 'Sherman, TX',
658: 'Green Bay-Appleton, WI',
659: 'Nashville, TN',
661: 'San Angelo, TX',
662: 'Abilene-Sweetwater, TX',
669: 'Madison, WI',
670: 'Ft Smith-Fay-Springfield, AR',
671: 'Tulsa, OK',
673: 'Columbus-Tupelo-West Point, MS',
675: 'Peoria-Bloomington, IL',
676: 'Duluth, MN',
678: 'Wichita, KS',
679: 'Des Moines, IA',
682: 'Davenport-Rock Island-Moline, IL',
686: 'Mobile, AL',
687: 'Minot-Bismarck-Dickinson, ND',
691: 'Huntsville, AL',
692: 'Beaumont-Port Author, TX',
693: 'Little Rock-Pine Bluff, AR',
698: 'Montgomery, AL',
702: 'La Crosse-Eau Claire, WI',
705: 'Wausau-Rhinelander, WI',
709: 'Tyler-Longview, TX',
710: 'Hattiesburg-Laurel, MS',
711: 'Meridian, MS',
716: 'Baton Rouge, LA',
717: 'Quincy, IL',
718: 'Jackson, MS',
722: 'Lincoln-Hastings, NE',
724: 'Fargo-Valley City, ND',
725: 'Sioux Falls, SD',
734: 'Jonesboro, AR',
736: 'Bowling Green, KY',
737: 'Mankato, MN',
740: 'North Platte, NE',
743: 'Anchorage, AK',
744: 'Honolulu, HI',
745: 'Fairbanks, AK',
746: 'Biloxi-Gulfport, MS',
747: 'Juneau, AK',
749: 'Laredo, TX',
751: 'Denver, CO',
752: 'Colorado Springs, CO',
753: 'Phoenix, AZ',
754: 'Butte-Bozeman, MT',
755: 'Great Falls, MT',
756: 'Billings, MT',
757: 'Boise, ID',
758: 'Idaho Falls-Pocatello, ID',
759: 'Cheyenne, WY',
760: 'Twin Falls, ID',
762: 'Missoula, MT',
764: 'Rapid City, SD',
765: 'El Paso, TX',
766: 'Helena, MT',
767: 'Casper-Riverton, WY',
770: 'Salt Lake City, UT',
771: 'Yuma, AZ',
773: 'Grand Junction, CO',
789: 'Tucson, AZ',
790: 'Albuquerque, NM',
798: 'Glendive, MT',
800: 'Bakersfield, CA',
801: 'Eugene, OR',
802: 'Eureka, CA',
803: 'Los Angeles, CA',
804: 'Palm Springs, CA',
807: 'San Francisco, CA',
810: 'Yakima-Pasco, WA',
811: 'Reno, NV',
813: 'Medford-Klamath Falls, OR',
819: 'Seattle-Tacoma, WA',
820: 'Portland, OR',
821: 'Bend, OR',
825: 'San Diego, CA',
828: 'Monterey-Salinas, CA',
839: 'Las Vegas, NV',
855: 'Santa Barbara, CA',
862: 'Sacramento, CA',
866: 'Fresno, CA',
868: 'Chico-Redding, CA',
881: 'Spokane, WA'
}
COUNTRY_CODES = (
'', 'AP', 'EU', 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', 'AQ',
'AR', 'AS', 'AT', 'AU', 'AW', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH',
'BI', 'BJ', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA',
'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU',
'CV', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG',
'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'FX', 'GA', 'GB',
'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT',
'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN',
'IO', 'IQ', 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM',
'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS',
'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN',
'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA',
'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA',
'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY',
'QA', 'RE', 'RO', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI',
'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'ST', 'SV', 'SY', 'SZ', 'TC', 'TD',
'TF', 'TG', 'TH', 'TJ', 'TK', 'TM', 'TN', 'TO', 'TL', 'TR', 'TT', 'TV', 'TW',
'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN',
'VU', 'WF', 'WS', 'YE', 'YT', 'RS', 'ZA', 'ZM', 'ME', 'ZW', 'A1', 'A2', 'O1',
'AX', 'GG', 'IM', 'JE', 'BL', 'MF'
)
'',
'AP', 'EU', 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', 'AQ',
'AR', 'AS', 'AT', 'AU', 'AW', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG',
'BH', 'BI', 'BJ', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY',
'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN',
'CO', 'CR', 'CU', 'CV', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO',
'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM',
'FO', 'FR', 'FX', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM',
'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN',
'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT',
'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW',
'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV',
'LY', 'MA', 'MC', 'MD', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP',
'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC',
'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA',
'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW',
'PY', 'QA', 'RE', 'RO', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG',
'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'ST', 'SV', 'SY',
'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TM', 'TN', 'TO', 'TL',
'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA',
'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'RS', 'ZA',
'ZM', 'ME', 'ZW', 'A1', 'A2', 'O1', 'AX', 'GG', 'IM', 'JE', 'BL', 'MF',
'BQ', 'SS'
)
COUNTRY_CODES3 = (
'','AP','EU','AND','ARE','AFG','ATG','AIA','ALB','ARM','ANT','AGO','AQ','ARG',
'ASM','AUT','AUS','ABW','AZE','BIH','BRB','BGD','BEL','BFA','BGR','BHR','BDI',
'BEN','BMU','BRN','BOL','BRA','BHS','BTN','BV','BWA','BLR','BLZ','CAN','CC',
'COD','CAF','COG','CHE','CIV','COK','CHL','CMR','CHN','COL','CRI','CUB','CPV',
'CX','CYP','CZE','DEU','DJI','DNK','DMA','DOM','DZA','ECU','EST','EGY','ESH',
'ERI','ESP','ETH','FIN','FJI','FLK','FSM','FRO','FRA','FX','GAB','GBR','GRD',
'GEO','GUF','GHA','GIB','GRL','GMB','GIN','GLP','GNQ','GRC','GS','GTM','GUM',
'GNB','GUY','HKG','HM','HND','HRV','HTI','HUN','IDN','IRL','ISR','IND','IO',
'IRQ','IRN','ISL','ITA','JAM','JOR','JPN','KEN','KGZ','KHM','KIR','COM','KNA',
'PRK','KOR','KWT','CYM','KAZ','LAO','LBN','LCA','LIE','LKA','LBR','LSO','LTU',
'LUX','LVA','LBY','MAR','MCO','MDA','MDG','MHL','MKD','MLI','MMR','MNG','MAC',
'MNP','MTQ','MRT','MSR','MLT','MUS','MDV','MWI','MEX','MYS','MOZ','NAM','NCL',
'NER','NFK','NGA','NIC','NLD','NOR','NPL','NRU','NIU','NZL','OMN','PAN','PER',
'PYF','PNG','PHL','PAK','POL','SPM','PCN','PRI','PSE','PRT','PLW','PRY','QAT',
'REU','ROU','RUS','RWA','SAU','SLB','SYC','SDN','SWE','SGP','SHN','SVN','SJM',
'SVK','SLE','SMR','SEN','SOM','SUR','STP','SLV','SYR','SWZ','TCA','TCD','TF',
'TGO','THA','TJK','TKL','TLS','TKM','TUN','TON','TUR','TTO','TUV','TWN','TZA',
'UKR','UGA','UM','USA','URY','UZB','VAT','VCT','VEN','VGB','VIR','VNM','VUT',
'WLF','WSM','YEM','YT','SRB','ZAF','ZMB','MNE','ZWE','A1','A2','O1',
'ALA','GGY','IMN','JEY','BLM','MAF'
)
'', 'AP', 'EU', 'AND', 'ARE', 'AFG', 'ATG', 'AIA', 'ALB', 'ARM', 'ANT',
'AGO', 'AQ', 'ARG', 'ASM', 'AUT', 'AUS', 'ABW', 'AZE', 'BIH', 'BRB', 'BGD',
'BEL', 'BFA', 'BGR', 'BHR', 'BDI', 'BEN', 'BMU', 'BRN', 'BOL', 'BRA',
'BHS', 'BTN', 'BV', 'BWA', 'BLR', 'BLZ', 'CAN', 'CC', 'COD', 'CAF', 'COG',
'CHE', 'CIV', 'COK', 'CHL', 'CMR', 'CHN', 'COL', 'CRI', 'CUB', 'CPV', 'CX',
'CYP', 'CZE', 'DEU', 'DJI', 'DNK', 'DMA', 'DOM', 'DZA', 'ECU', 'EST',
'EGY', 'ESH', 'ERI', 'ESP', 'ETH', 'FIN', 'FJI', 'FLK', 'FSM', 'FRO',
'FRA', 'FX', 'GAB', 'GBR', 'GRD', 'GEO', 'GUF', 'GHA', 'GIB', 'GRL', 'GMB',
'GIN', 'GLP', 'GNQ', 'GRC', 'GS', 'GTM', 'GUM', 'GNB', 'GUY', 'HKG', 'HM',
'HND', 'HRV', 'HTI', 'HUN', 'IDN', 'IRL', 'ISR', 'IND', 'IO', 'IRQ', 'IRN',
'ISL', 'ITA', 'JAM', 'JOR', 'JPN', 'KEN', 'KGZ', 'KHM', 'KIR', 'COM',
'KNA', 'PRK', 'KOR', 'KWT', 'CYM', 'KAZ', 'LAO', 'LBN', 'LCA', 'LIE',
'LKA', 'LBR', 'LSO', 'LTU', 'LUX', 'LVA', 'LBY', 'MAR', 'MCO', 'MDA',
'MDG', 'MHL', 'MKD', 'MLI', 'MMR', 'MNG', 'MAC', 'MNP', 'MTQ', 'MRT',
'MSR', 'MLT', 'MUS', 'MDV', 'MWI', 'MEX', 'MYS', 'MOZ', 'NAM', 'NCL',
'NER', 'NFK', 'NGA', 'NIC', 'NLD', 'NOR', 'NPL', 'NRU', 'NIU', 'NZL',
'OMN', 'PAN', 'PER', 'PYF', 'PNG', 'PHL', 'PAK', 'POL', 'SPM', 'PCN',
'PRI', 'PSE', 'PRT', 'PLW', 'PRY', 'QAT', 'REU', 'ROU', 'RUS', 'RWA',
'SAU', 'SLB', 'SYC', 'SDN', 'SWE', 'SGP', 'SHN', 'SVN', 'SJM', 'SVK',
'SLE', 'SMR', 'SEN', 'SOM', 'SUR', 'STP', 'SLV', 'SYR', 'SWZ', 'TCA',
'TCD', 'TF', 'TGO', 'THA', 'TJK', 'TKL', 'TLS', 'TKM', 'TUN', 'TON', 'TUR',
'TTO', 'TUV', 'TWN', 'TZA', 'UKR', 'UGA', 'UM', 'USA', 'URY', 'UZB', 'VAT',
'VCT', 'VEN', 'VGB', 'VIR', 'VNM', 'VUT', 'WLF', 'WSM', 'YEM', 'YT', 'SRB',
'ZAF', 'ZMB', 'MNE', 'ZWE', 'A1', 'A2', 'O1', 'ALA', 'GGY', 'IMN', 'JEY',
'BLM', 'MAF', 'BES', 'SSD'
)
COUNTRY_NAMES = (
"", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates",
"Afghanistan", "Antigua and Barbuda", "Anguilla", "Albania", "Armenia",
"Netherlands Antilles", "Angola", "Antarctica", "Argentina", "American Samoa",
"Austria", "Australia", "Aruba", "Azerbaijan", "Bosnia and Herzegovina",
"Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bahrain",
"Burundi", "Benin", "Bermuda", "Brunei Darussalam", "Bolivia", "Brazil",
"Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize",
"Canada", "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the",
"Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire", "Cook Islands",
"Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape Verde",
"Christmas Island", "Cyprus", "Czech Republic", "Germany", "Djibouti",
"Denmark", "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia",
"Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", "Finland", "Fiji",
"Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe Islands",
"France", "France, Metropolitan", "Gabon", "United Kingdom",
"Grenada", "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland",
"Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece",
"South Georgia and the South Sandwich Islands",
"Guatemala", "Guam", "Guinea-Bissau",
"Guyana", "Hong Kong", "Heard Island and McDonald Islands", "Honduras",
"Croatia", "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India",
"British Indian Ocean Territory", "Iraq", "Iran, Islamic Republic of",
"Iceland", "Italy", "Jamaica", "Jordan", "Japan", "Kenya", "Kyrgyzstan",
"Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis",
"Korea, Democratic People's Republic of",
"Korea, Republic of", "Kuwait", "Cayman Islands",
"Kazakhstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia",
"Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg",
"Latvia", "Libya", "Morocco", "Monaco", "Moldova, Republic of",
"Madagascar", "Marshall Islands", "Macedonia",
"Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands",
"Martinique", "Mauritania", "Montserrat", "Malta", "Mauritius", "Maldives",
"Malawi", "Mexico", "Malaysia", "Mozambique", "Namibia", "New Caledonia",
"Niger", "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway",
"Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", "French Polynesia",
"Papua New Guinea", "Philippines", "Pakistan", "Poland", "Saint Pierre and Miquelon",
"Pitcairn Islands", "Puerto Rico", "Palestinian Territory",
"Portugal", "Palau", "Paraguay", "Qatar", "Reunion", "Romania",
"Russian Federation", "Rwanda", "Saudi Arabia", "Solomon Islands",
"Seychelles", "Sudan", "Sweden", "Singapore", "Saint Helena", "Slovenia",
"Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", "Senegal",
"Somalia", "Suriname", "Sao Tome and Principe", "El Salvador", "Syrian Arab Republic",
"Swaziland", "Turks and Caicos Islands", "Chad", "French Southern Territories",
"Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan",
"Tunisia", "Tonga", "Timor-Leste", "Turkey", "Trinidad and Tobago", "Tuvalu",
"Taiwan", "Tanzania, United Republic of", "Ukraine",
"Uganda", "United States Minor Outlying Islands", "United States", "Uruguay",
"Uzbekistan", "Holy See (Vatican City State)", "Saint Vincent and the Grenadines",
"Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
"Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte",
"Serbia", "South Africa", "Zambia", "Montenegro", "Zimbabwe",
"Anonymous Proxy","Satellite Provider","Other",
"Aland Islands","Guernsey","Isle of Man","Jersey","Saint Barthelemy","Saint Martin"
)
'', 'Asia/Pacific Region', 'Europe', 'Andorra', 'United Arab Emirates',
'Afghanistan', 'Antigua and Barbuda', 'Anguilla', 'Albania', 'Armenia',
'Netherlands Antilles', 'Angola', 'Antarctica', 'Argentina',
'American Samoa', 'Austria', 'Australia', 'Aruba', 'Azerbaijan',
'Bosnia and Herzegovina', 'Barbados', 'Bangladesh', 'Belgium',
'Burkina Faso', 'Bulgaria', 'Bahrain', 'Burundi', 'Benin', 'Bermuda',
'Brunei Darussalam', 'Bolivia', 'Brazil', 'Bahamas', 'Bhutan',
'Bouvet Island', 'Botswana', 'Belarus', 'Belize', 'Canada',
'Cocos (Keeling) Islands', 'Congo, The Democratic Republic of the',
'Central African Republic', 'Congo', 'Switzerland', 'Cote D\'Ivoire',
'Cook Islands', 'Chile', 'Cameroon', 'China', 'Colombia', 'Costa Rica',
'Cuba', 'Cape Verde', 'Christmas Island', 'Cyprus', 'Czech Republic',
'Germany', 'Djibouti', 'Denmark', 'Dominica', 'Dominican Republic',
'Algeria', 'Ecuador', 'Estonia', 'Egypt', 'Western Sahara', 'Eritrea',
'Spain', 'Ethiopia', 'Finland', 'Fiji', 'Falkland Islands (Malvinas)',
'Micronesia, Federated States of', 'Faroe Islands', 'France',
'France, Metropolitan', 'Gabon', 'United Kingdom', 'Grenada', 'Georgia',
'French Guiana', 'Ghana', 'Gibraltar', 'Greenland', 'Gambia', 'Guinea',
'Guadeloupe', 'Equatorial Guinea', 'Greece',
'South Georgia and the South Sandwich Islands', 'Guatemala', 'Guam',
'Guinea-Bissau', 'Guyana', 'Hong Kong',
'Heard Island and McDonald Islands', 'Honduras', 'Croatia', 'Haiti',
'Hungary', 'Indonesia', 'Ireland', 'Israel', 'India',
'British Indian Ocean Territory', 'Iraq', 'Iran, Islamic Republic of',
'Iceland', 'Italy', 'Jamaica', 'Jordan', 'Japan', 'Kenya', 'Kyrgyzstan',
'Cambodia', 'Kiribati', 'Comoros', 'Saint Kitts and Nevis',
'Korea, Democratic People\'s Republic of', 'Korea, Republic of', 'Kuwait',
'Cayman Islands', 'Kazakhstan', 'Lao People\'s Democratic Republic',
'Lebanon', 'Saint Lucia', 'Liechtenstein', 'Sri Lanka', 'Liberia',
'Lesotho', 'Lithuania', 'Luxembourg', 'Latvia', 'Libya', 'Morocco',
'Monaco', 'Moldova, Republic of', 'Madagascar', 'Marshall Islands',
'Macedonia', 'Mali', 'Myanmar', 'Mongolia', 'Macau',
'Northern Mariana Islands', 'Martinique', 'Mauritania', 'Montserrat',
'Malta', 'Mauritius', 'Maldives', 'Malawi', 'Mexico', 'Malaysia',
'Mozambique', 'Namibia', 'New Caledonia', 'Niger', 'Norfolk Island',
'Nigeria', 'Nicaragua', 'Netherlands', 'Norway', 'Nepal', 'Nauru', 'Niue',
'New Zealand', 'Oman', 'Panama', 'Peru', 'French Polynesia',
'Papua New Guinea', 'Philippines', 'Pakistan', 'Poland',
'Saint Pierre and Miquelon', 'Pitcairn Islands', 'Puerto Rico',
'Palestinian Territory', 'Portugal', 'Palau', 'Paraguay', 'Qatar',
'Reunion', 'Romania', 'Russian Federation', 'Rwanda', 'Saudi Arabia',
'Solomon Islands', 'Seychelles', 'Sudan', 'Sweden', 'Singapore',
'Saint Helena', 'Slovenia', 'Svalbard and Jan Mayen', 'Slovakia',
'Sierra Leone', 'San Marino', 'Senegal', 'Somalia', 'Suriname',
'Sao Tome and Principe', 'El Salvador', 'Syrian Arab Republic',
'Swaziland', 'Turks and Caicos Islands', 'Chad',
'French Southern Territories', 'Togo', 'Thailand', 'Tajikistan', 'Tokelau',
'Turkmenistan', 'Tunisia', 'Tonga', 'Timor-Leste', 'Turkey',
'Trinidad and Tobago', 'Tuvalu', 'Taiwan', 'Tanzania, United Republic of',
'Ukraine', 'Uganda', 'United States Minor Outlying Islands',
'United States', 'Uruguay', 'Uzbekistan', 'Holy See (Vatican City State)',
'Saint Vincent and the Grenadines', 'Venezuela', 'Virgin Islands, British',
'Virgin Islands, U.S.', 'Vietnam', 'Vanuatu', 'Wallis and Futuna', 'Samoa',
'Yemen', 'Mayotte', 'Serbia', 'South Africa', 'Zambia', 'Montenegro',
'Zimbabwe', 'Anonymous Proxy', 'Satellite Provider', 'Other',
'Aland Islands', 'Guernsey', 'Isle of Man', 'Jersey', 'Saint Barthelemy',
'Saint Martin', 'Bonaire, Sint Eustatius and Saba', 'South Sudan'
)
CONTINENT_MAP = {
'Algeria' : 'Africa',
'Angola' : 'Africa',
'Benin' : 'Africa',
'Botswana' : 'Africa',
'Burkina Faso' : 'Africa',
'Burundi' : 'Africa',
'Cameroon' : 'Africa',
'Cape Verde' : 'Africa',
'Central African Republic' : 'Africa',
'Chad' : 'Africa',
'Comoros' : 'Africa',
'Congo' : 'Africa',
'Congo, The Democratic Republic of the' : 'Africa',
'Djibouti' : 'Africa',
'Egypt' : 'Africa',
'Equatorial Guinea' : 'Africa',
'Eritrea' : 'Africa',
'Ethiopia' : 'Africa',
'Gabon' : 'Africa',
'Gambia' : 'Africa',
'Ghana' : 'Africa',
'Guinea' : 'Africa',
'Guinea-Bissau' : 'Africa',
"Cote D'Ivoire" : 'Africa',
'Kenya' : 'Africa',
'Lesotho' : 'Africa',
'Liberia' : 'Africa',
'Libya' : 'Africa',
'Madagascar' : 'Africa',
'Malawi' : 'Africa',
'Mali' : 'Africa',
'Mauritania' : 'Africa',
'Mauritius' : 'Africa',
'Morocco' : 'Africa',
'Mozambique' : 'Africa',
'Namibia' : 'Africa',
'Niger' : 'Africa',
'Nigeria' : 'Africa',
'Rwanda' : 'Africa',
'Sao Tome and Principe' : 'Africa',
'Senegal' : 'Africa',
'Seychelles' : 'Africa',
'Sierra Leone' : 'Africa',
'Somalia' : 'Africa',
'South Africa' : 'Africa',
'South Sudan' : 'Africa',
'Sudan' : 'Africa',
'Swaziland' : 'Africa',
'Tanzania, United Republic of' : 'Africa',
'Togo' : 'Africa',
'Tunisia' : 'Africa',
'Uganda' : 'Africa',
'Western Sahara' : 'Africa',
'Zambia' : 'Africa',
'Zimbabwe' : 'Africa',
'Afghanistan' : 'Asia',
'Bahrain' : 'Asia',
'Bangladesh' : 'Asia',
'Bhutan' : 'Asia',
'Brunei Darussalam' : 'Asia',
'Myanmar' : 'Asia',
'Cambodia' : 'Asia',
'China' : 'Asia',
'Timor-Leste' : 'Asia',
'India' : 'Asia',
'Indonesia' : 'Asia',
'Iran, Islamic Republic of' : 'Asia',
'Iraq' : 'Asia',
'Israel' : 'Asia',
'Palestinian Territory' : 'Asia',
'Japan' : 'Asia',
'Jordan' : 'Asia',
'Kazakhstan' : 'Asia',
"Korea, Democratic People's Republic of" : 'Asia', # North
'Korea, Republic of' : 'Asia', # South
'Kuwait' : 'Asia',
'Kyrgyzstan' : 'Asia',
"Lao People's Democratic Republic" : 'Asia',
'Lebanon' : 'Asia',
'Malaysia' : 'Asia',
'Maldives' : 'Asia',
'Macau' : 'Asia',
'Mongolia' : 'Asia',
'Nepal' : 'Asia',
'Oman' : 'Asia',
'Pakistan' : 'Asia',
'Philippines' : 'Asia',
'Qatar' : 'Asia',
'Russian Federation' : 'Asia',
'Saudi Arabia' : 'Asia',
'Singapore' : 'Asia',
'Sri Lanka' : 'Asia',
'Syrian Arab Republic' : 'Asia',
'Tajikistan' : 'Asia',
'Taiwan' : 'Asia',
'Thailand' : 'Asia',
'Turkey' : 'Asia',
'Turkmenistan' : 'Asia',
'United Arab Emirates' : 'Asia',
'Uzbekistan' : 'Asia',
'Vietnam' : 'Asia',
'Yemen' : 'Asia',
'Albania' : 'Europe',
'Andorra' : 'Europe',
'Armenia' : 'Europe',
'Austria' : 'Europe',
'Azerbaijan' : 'Europe',
'Belarus' : 'Europe',
'Belgium' : 'Europe',
'Bosnia and Herzegovina' : 'Europe',
'Bulgaria' : 'Europe',
'Croatia' : 'Europe',
'Cyprus' : 'Europe',
'Czech Republic' : 'Europe',
'Denmark' : 'Europe',
'Estonia' : 'Europe',
'Finland' : 'Europe',
'France' : 'Europe',
'Georgia' : 'Europe',
'Germany' : 'Europe',
'Gibraltar' : 'Europe',
'Greece' : 'Europe',
'Hungary' : 'Europe',
'Iceland' : 'Europe',
'Ireland' : 'Europe',
'Isle of Man' : 'Europe',
'Italy' : 'Europe',
'Latvia' : 'Europe',
'Liechtenstein' : 'Europe',
'Lithuania' : 'Europe',
'Luxembourg' : 'Europe',
'Macedonia' : 'Europe',
'Malta' : 'Europe',
'Moldova, Republic of' : 'Europe',
'Monaco' : 'Europe',
'Montenegro' : 'Europe',
'Netherlands' : 'Europe',
'Norway' : 'Europe',
'Poland' : 'Europe',
'Portugal' : 'Europe',
'Romania' : 'Europe',
'San Marino' : 'Europe',
'Serbia' : 'Europe',
'Slovakia' : 'Europe',
'Slovenia' : 'Europe',
'Spain' : 'Europe',
'Sweden' : 'Europe',
'Switzerland' : 'Europe',
'Ukraine' : 'Europe',
'United Kingdom' : 'Europe',
'Holy See (Vatican City State)' : 'Europe',
'Antigua and Barbuda' : "North America",
'Bahamas' : "North America",
'Barbados' : "North America",
'Belize' : "North America",
'Canada' : "North America",
'Costa Rica' : "North America",
'Cuba' : "North America",
'Dominica' : "North America",
'Dominican Republic' : "North America",
'El Salvador' : "North America",
'Grenada' : "North America",
'Greenland' : "North America",
'Guatemala' : "North America",
'Haiti' : "North America",
'Honduras' : "North America",
'Jamaica' : "North America",
'Mexico' : "North America",
'Nicaragua' : "North America",
'Panama' : "North America",
'Puerto Rico' : "North America",
'Saint Kitts and Nevis' : "North America",
'Saint Lucia' : "North America",
'Saint Vincent and the Grenadines' : "North America",
'Trinidad and Tobago' : "North America",
'United States' : "North America",
'Australia' : 'Oceania',
'Fiji' : 'Oceania',
'Kiribati' : 'Oceania',
'Marshall Islands' : 'Oceania',
'Micronesia,, Federated States of' : 'Oceania',
'Nauru' : 'Oceania',
'New Zealand' : 'Oceania',
'Palau' : 'Oceania',
'Papua New Guinea' : 'Oceania',
'American Samoa' : 'Oceania',
'Solomon Islands' : 'Oceania',
'Tonga' : 'Oceania',
'Tuvalu' : 'Oceania',
'Vanuatu' : 'Oceania',
'Argentina' : 'South America',
'Bolivia' : 'South America',
'Brazil' : 'South America',
'Chile' : 'South America',
'Colombia' : 'South America',
'Ecuador' : 'South America',
'French Guiana' : 'South America',
'Paraguay' : 'South America',
'Peru' : 'South America',
'Suriname' : 'South America',
'Uruguay' : 'South America',
'Venezuela' : 'South America'
CONTINENT_NAMES = {
'--', 'AS', 'EU', 'EU', 'AS', 'AS', 'NA', 'NA', 'EU', 'AS', 'NA', 'AF',
'AN', 'SA', 'OC', 'EU', 'OC', 'NA', 'AS', 'EU', 'NA', 'AS', 'EU', 'AF',
'EU', 'AS', 'AF', 'AF', 'NA', 'AS', 'SA', 'SA', 'NA', 'AS', 'AN', 'AF',
'EU', 'NA', 'NA', 'AS', 'AF', 'AF', 'AF', 'EU', 'AF', 'OC', 'SA', 'AF',
'AS', 'SA', 'NA', 'NA', 'AF', 'AS', 'AS', 'EU', 'EU', 'AF', 'EU', 'NA',
'NA', 'AF', 'SA', 'EU', 'AF', 'AF', 'AF', 'EU', 'AF', 'EU', 'OC', 'SA',
'OC', 'EU', 'EU', 'NA', 'AF', 'EU', 'NA', 'AS', 'SA', 'AF', 'EU', 'NA',
'AF', 'AF', 'NA', 'AF', 'EU', 'AN', 'NA', 'OC', 'AF', 'SA', 'AS', 'AN',
'NA', 'EU', 'NA', 'EU', 'AS', 'EU', 'AS', 'AS', 'AS', 'AS', 'AS', 'EU',
'EU', 'NA', 'AS', 'AS', 'AF', 'AS', 'AS', 'OC', 'AF', 'NA', 'AS', 'AS',
'AS', 'NA', 'AS', 'AS', 'AS', 'NA', 'EU', 'AS', 'AF', 'AF', 'EU', 'EU',
'EU', 'AF', 'AF', 'EU', 'EU', 'AF', 'OC', 'EU', 'AF', 'AS', 'AS', 'AS',
'OC', 'NA', 'AF', 'NA', 'EU', 'AF', 'AS', 'AF', 'NA', 'AS', 'AF', 'AF',
'OC', 'AF', 'OC', 'AF', 'NA', 'EU', 'EU', 'AS', 'OC', 'OC', 'OC', 'AS',
'NA', 'SA', 'OC', 'OC', 'AS', 'AS', 'EU', 'NA', 'OC', 'NA', 'AS', 'EU',
'OC', 'SA', 'AS', 'AF', 'EU', 'EU', 'AF', 'AS', 'OC', 'AF', 'AF', 'EU',
'AS', 'AF', 'EU', 'EU', 'EU', 'AF', 'EU', 'AF', 'AF', 'SA', 'AF', 'NA',
'AS', 'AF', 'NA', 'AF', 'AN', 'AF', 'AS', 'AS', 'OC', 'AS', 'AF', 'OC',
'AS', 'EU', 'NA', 'OC', 'AS', 'AF', 'EU', 'AF', 'OC', 'NA', 'SA', 'AS',
'EU', 'NA', 'SA', 'NA', 'NA', 'AS', 'OC', 'OC', 'OC', 'AS', 'AF', 'EU',
'AF', 'AF', 'EU', 'AF', '--', '--', '--', 'EU', 'EU', 'EU', 'EU', 'NA',
'NA', 'NA', 'AF'
}
# storage / caching flags
......@@ -561,16 +397,23 @@ DATABASE_INFO_MAX_SIZE = 100
# Database editions
COUNTRY_EDITION = 1
COUNTRY_EDITION_V6 = 12
REGION_EDITION_REV0 = 7
REGION_EDITION_REV1 = 3
CITY_EDITION_REV0 = 6
CITY_EDITION_REV1 = 2
ORG_EDITION = 5
ISP_EDITION = 4
PROXY_EDITION = 8
ASNUM_EDITION = 9
# Not yet supported databases
PROXY_EDITION = 8
NETSPEED_EDITION = 11
COUNTRY_EDITION_V6 = 12
# Collection of databases
IPV6_EDITIONS = (COUNTRY_EDITION_V6,)
CITY_EDITIONS = (CITY_EDITION_REV0, CITY_EDITION_REV1)
REGION_EDITIONS = (REGION_EDITION_REV0, REGION_EDITION_REV1)
REGION_CITY_EDITIONS = REGION_EDITIONS + CITY_EDITIONS
SEGMENT_RECORD_LENGTH = 3
STANDARD_RECORD_LENGTH = 3
......@@ -583,5 +426,4 @@ US_OFFSET = 1
CANADA_OFFSET = 677
WORLD_OFFSET = 1353
FIPS_RANGE = 360
ENCODING = 'iso-8859-1'
# -*- coding: utf-8 -*-
"""
Time zone functions. Part of the pygeoip package.
@author: Jennifer Ennis <zaylea@gmail.com>
@license: Copyright(C) 2004 MaxMind LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
"""
__all__ = ['time_zone_by_country_and_region']
_country = {}
_country["AD"] = "Europe/Andorra"
_country["AE"] = "Asia/Dubai"
_country["AF"] = "Asia/Kabul"
_country["AG"] = "America/Antigua"
_country["AI"] = "America/Anguilla"
_country["AL"] = "Europe/Tirane"
_country["AM"] = "Asia/Yerevan"
_country["AO"] = "Africa/Luanda"
_country["AR"] = {}
_country["AR"]["01"] = "America/Argentina/Buenos_Aires"
_country["AR"]["02"] = "America/Argentina/Catamarca"
_country["AR"]["03"] = "America/Argentina/Tucuman"
_country["AR"]["04"] = "America/Argentina/Rio_Gallegos"
_country["AR"]["05"] = "America/Argentina/Cordoba"
_country["AR"]["06"] = "America/Argentina/Tucuman"
_country["AR"]["07"] = "America/Argentina/Buenos_Aires"
_country["AR"]["08"] = "America/Argentina/Buenos_Aires"
_country["AR"]["09"] = "America/Argentina/Tucuman"
_country["AR"]["10"] = "America/Argentina/Jujuy"
_country["AR"]["11"] = "America/Argentina/San_Luis"
_country["AR"]["12"] = "America/Argentina/La_Rioja"
_country["AR"]["13"] = "America/Argentina/Mendoza"
_country["AR"]["14"] = "America/Argentina/Buenos_Aires"
_country["AR"]["15"] = "America/Argentina/San_Luis"
_country["AR"]["16"] = "America/Argentina/Buenos_Aires"
_country["AR"]["17"] = "America/Argentina/Salta"
_country["AR"]["18"] = "America/Argentina/San_Juan"
_country["AR"]["19"] = "America/Argentina/San_Luis"
_country["AR"]["20"] = "America/Argentina/Rio_Gallegos"
_country["AR"]["21"] = "America/Argentina/Buenos_Aires"
_country["AR"]["22"] = "America/Argentina/Catamarca"
_country["AR"]["23"] = "America/Argentina/Ushuaia"
_country["AR"]["24"] = "America/Argentina/Tucuman"
_country["AS"] = "US/Samoa"
_country["AT"] = "Europe/Vienna"
_country["AU"] = {}
_country["AU"]["01"] = "Australia/Canberra"
_country["AU"]["02"] = "Australia/NSW"
_country["AU"]["03"] = "Australia/North"
_country["AU"]["04"] = "Australia/Queensland"
_country["AU"]["05"] = "Australia/South"
_country["AU"]["06"] = "Australia/Tasmania"
_country["AU"]["07"] = "Australia/Victoria"
_country["AU"]["08"] = "Australia/West"
_country["AW"] = "America/Aruba"
_country["AX"] = "Europe/Mariehamn"
_country["AZ"] = "Asia/Baku"
_country["BA"] = "Europe/Sarajevo"
_country["BB"] = "America/Barbados"
_country["BD"] = "Asia/Dhaka"
_country["BE"] = "Europe/Brussels"
_country["BF"] = "Africa/Ouagadougou"
_country["BG"] = "Europe/Sofia"
_country["BH"] = "Asia/Bahrain"
_country["BI"] = "Africa/Bujumbura"
_country["BJ"] = "Africa/Porto-Novo"
_country["BL"] = "America/St_Barthelemy"
_country["BM"] = "Atlantic/Bermuda"
_country["BN"] = "Asia/Brunei"
_country["BO"] = "America/La_Paz"
_country["BQ"] = "America/Curacao"
_country["BR"] = {}
_country["BR"]["01"] = "America/Rio_Branco"
_country["BR"]["02"] = "America/Maceio"
_country["BR"]["03"] = "America/Sao_Paulo"
_country["BR"]["04"] = "America/Manaus"
_country["BR"]["05"] = "America/Bahia"
_country["BR"]["06"] = "America/Fortaleza"
_country["BR"]["07"] = "America/Sao_Paulo"
_country["BR"]["08"] = "America/Sao_Paulo"
_country["BR"]["11"] = "America/Campo_Grande"
_country["BR"]["13"] = "America/Belem"
_country["BR"]["14"] = "America/Cuiaba"
_country["BR"]["15"] = "America/Sao_Paulo"
_country["BR"]["16"] = "America/Belem"
_country["BR"]["17"] = "America/Recife"
_country["BR"]["18"] = "America/Sao_Paulo"
_country["BR"]["20"] = "America/Fortaleza"
_country["BR"]["21"] = "America/Sao_Paulo"
_country["BR"]["22"] = "America/Recife"
_country["BR"]["23"] = "America/Sao_Paulo"
_country["BR"]["24"] = "America/Porto_Velho"
_country["BR"]["25"] = "America/Boa_Vista"
_country["BR"]["26"] = "America/Sao_Paulo"
_country["BR"]["27"] = "America/Sao_Paulo"
_country["BR"]["28"] = "America/Maceio"
_country["BR"]["29"] = "America/Sao_Paulo"
_country["BR"]["30"] = "America/Recife"
_country["BR"]["31"] = "America/Araguaina"
_country["BS"] = "America/Nassau"
_country["BT"] = "Asia/Thimphu"
_country["BW"] = "Africa/Gaborone"
_country["BY"] = "Europe/Minsk"
_country["BZ"] = "America/Belize"
_country["CA"] = {}
_country["CA"]["AB"] = "America/Edmonton"
_country["CA"]["BC"] = "America/Vancouver"
_country["CA"]["MB"] = "America/Winnipeg"
_country["CA"]["NB"] = "America/Halifax"
_country["CA"]["NL"] = "America/St_Johns"
_country["CA"]["NS"] = "America/Halifax"
_country["CA"]["NT"] = "America/Yellowknife"
_country["CA"]["NU"] = "America/Rankin_Inlet"
_country["CA"]["ON"] = "America/Rainy_River"
_country["CA"]["PE"] = "America/Halifax"
_country["CA"]["QC"] = "America/Montreal"
_country["CA"]["SK"] = "America/Regina"
_country["CA"]["YT"] = "America/Whitehorse"
_country["CC"] = "Indian/Cocos"
_country["CD"] = {}
_country["CD"]["02"] = "Africa/Kinshasa"
_country["CD"]["05"] = "Africa/Lubumbashi"
_country["CD"]["06"] = "Africa/Kinshasa"
_country["CD"]["08"] = "Africa/Kinshasa"
_country["CD"]["10"] = "Africa/Lubumbashi"
_country["CD"]["11"] = "Africa/Lubumbashi"
_country["CD"]["12"] = "Africa/Lubumbashi"
_country["CF"] = "Africa/Bangui"
_country["CG"] = "Africa/Brazzaville"
_country["CH"] = "Europe/Zurich"
_country["CI"] = "Africa/Abidjan"
_country["CK"] = "Pacific/Rarotonga"
_country["CL"] = "Chile/Continental"
_country["CM"] = "Africa/Lagos"
_country["CN"] = {}
_country["CN"]["01"] = "Asia/Shanghai"
_country["CN"]["02"] = "Asia/Shanghai"
_country["CN"]["03"] = "Asia/Shanghai"
_country["CN"]["04"] = "Asia/Shanghai"
_country["CN"]["05"] = "Asia/Harbin"
_country["CN"]["06"] = "Asia/Chongqing"
_country["CN"]["07"] = "Asia/Shanghai"
_country["CN"]["08"] = "Asia/Harbin"
_country["CN"]["09"] = "Asia/Shanghai"
_country["CN"]["10"] = "Asia/Shanghai"
_country["CN"]["11"] = "Asia/Chongqing"
_country["CN"]["12"] = "Asia/Shanghai"
_country["CN"]["13"] = "Asia/Urumqi"
_country["CN"]["14"] = "Asia/Chongqing"
_country["CN"]["15"] = "Asia/Chongqing"
_country["CN"]["16"] = "Asia/Chongqing"
_country["CN"]["18"] = "Asia/Chongqing"
_country["CN"]["19"] = "Asia/Harbin"
_country["CN"]["20"] = "Asia/Harbin"
_country["CN"]["21"] = "Asia/Chongqing"
_country["CN"]["22"] = "Asia/Harbin"
_country["CN"]["23"] = "Asia/Shanghai"
_country["CN"]["24"] = "Asia/Chongqing"
_country["CN"]["25"] = "Asia/Shanghai"
_country["CN"]["26"] = "Asia/Chongqing"
_country["CN"]["28"] = "Asia/Shanghai"
_country["CN"]["29"] = "Asia/Chongqing"
_country["CN"]["30"] = "Asia/Chongqing"
_country["CN"]["31"] = "Asia/Chongqing"
_country["CN"]["32"] = "Asia/Chongqing"
_country["CN"]["33"] = "Asia/Chongqing"
_country["CO"] = "America/Bogota"
_country["CR"] = "America/Costa_Rica"
_country["CU"] = "America/Havana"
_country["CV"] = "Atlantic/Cape_Verde"
_country["CW"] = "America/Curacao"
_country["CX"] = "Indian/Christmas"
_country["CY"] = "Asia/Nicosia"
_country["CZ"] = "Europe/Prague"
_country["DE"] = "Europe/Berlin"
_country["DJ"] = "Africa/Djibouti"
_country["DK"] = "Europe/Copenhagen"
_country["DM"] = "America/Dominica"
_country["DO"] = "America/Santo_Domingo"
_country["DZ"] = "Africa/Algiers"
_country["EC"] = {}
_country["EC"]["01"] = "Pacific/Galapagos"
_country["EC"]["02"] = "America/Guayaquil"
_country["EC"]["03"] = "America/Guayaquil"
_country["EC"]["04"] = "America/Guayaquil"
_country["EC"]["05"] = "America/Guayaquil"
_country["EC"]["06"] = "America/Guayaquil"
_country["EC"]["07"] = "America/Guayaquil"
_country["EC"]["08"] = "America/Guayaquil"
_country["EC"]["09"] = "America/Guayaquil"
_country["EC"]["10"] = "America/Guayaquil"
_country["EC"]["11"] = "America/Guayaquil"
_country["EC"]["12"] = "America/Guayaquil"
_country["EC"]["13"] = "America/Guayaquil"
_country["EC"]["14"] = "America/Guayaquil"
_country["EC"]["15"] = "America/Guayaquil"
_country["EC"]["17"] = "America/Guayaquil"
_country["EC"]["18"] = "America/Guayaquil"
_country["EC"]["19"] = "America/Guayaquil"
_country["EC"]["20"] = "America/Guayaquil"
_country["EC"]["22"] = "America/Guayaquil"
_country["EE"] = "Europe/Tallinn"
_country["EG"] = "Africa/Cairo"
_country["EH"] = "Africa/El_Aaiun"
_country["ER"] = "Africa/Asmera"
_country["ES"] = {}
_country["ES"]["07"] = "Europe/Madrid"
_country["ES"]["27"] = "Europe/Madrid"
_country["ES"]["29"] = "Europe/Madrid"
_country["ES"]["31"] = "Europe/Madrid"
_country["ES"]["32"] = "Europe/Madrid"
_country["ES"]["34"] = "Europe/Madrid"
_country["ES"]["39"] = "Europe/Madrid"
_country["ES"]["51"] = "Africa/Ceuta"
_country["ES"]["52"] = "Europe/Madrid"
_country["ES"]["53"] = "Atlantic/Canary"
_country["ES"]["54"] = "Europe/Madrid"
_country["ES"]["55"] = "Europe/Madrid"
_country["ES"]["56"] = "Europe/Madrid"
_country["ES"]["57"] = "Europe/Madrid"
_country["ES"]["58"] = "Europe/Madrid"
_country["ES"]["59"] = "Europe/Madrid"
_country["ES"]["60"] = "Europe/Madrid"
_country["ET"] = "Africa/Addis_Ababa"
_country["FI"] = "Europe/Helsinki"
_country["FJ"] = "Pacific/Fiji"
_country["FK"] = "Atlantic/Stanley"
_country["FO"] = "Atlantic/Faeroe"
_country["FR"] = "Europe/Paris"
_country["GA"] = "Africa/Libreville"
_country["GB"] = "Europe/London"
_country["GD"] = "America/Grenada"
_country["GE"] = "Asia/Tbilisi"
_country["GF"] = "America/Cayenne"
_country["GG"] = "Europe/Guernsey"
_country["GH"] = "Africa/Accra"
_country["GI"] = "Europe/Gibraltar"
_country["GL"] = {}
_country["GL"]["01"] = "America/Thule"
_country["GL"]["02"] = "America/Godthab"
_country["GL"]["03"] = "America/Godthab"
_country["GM"] = "Africa/Banjul"
_country["GN"] = "Africa/Conakry"
_country["GP"] = "America/Guadeloupe"
_country["GQ"] = "Africa/Malabo"
_country["GR"] = "Europe/Athens"
_country["GS"] = "Atlantic/South_Georgia"
_country["GT"] = "America/Guatemala"
_country["GU"] = "Pacific/Guam"
_country["GW"] = "Africa/Bissau"
_country["GY"] = "America/Guyana"
_country["HK"] = "Asia/Hong_Kong"
_country["HN"] = "America/Tegucigalpa"
_country["HR"] = "Europe/Zagreb"
_country["HT"] = "America/Port-au-Prince"
_country["HU"] = "Europe/Budapest"
_country["ID"] = {}
_country["ID"]["01"] = "Asia/Pontianak"
_country["ID"]["02"] = "Asia/Makassar"
_country["ID"]["03"] = "Asia/Jakarta"
_country["ID"]["04"] = "Asia/Jakarta"
_country["ID"]["05"] = "Asia/Jakarta"
_country["ID"]["06"] = "Asia/Jakarta"
_country["ID"]["07"] = "Asia/Jakarta"
_country["ID"]["08"] = "Asia/Jakarta"
_country["ID"]["09"] = "Asia/Jayapura"
_country["ID"]["10"] = "Asia/Jakarta"
_country["ID"]["11"] = "Asia/Pontianak"
_country["ID"]["12"] = "Asia/Makassar"
_country["ID"]["13"] = "Asia/Makassar"
_country["ID"]["14"] = "Asia/Makassar"
_country["ID"]["15"] = "Asia/Jakarta"
_country["ID"]["16"] = "Asia/Makassar"
_country["ID"]["17"] = "Asia/Makassar"
_country["ID"]["18"] = "Asia/Makassar"
_country["ID"]["19"] = "Asia/Pontianak"
_country["ID"]["20"] = "Asia/Makassar"
_country["ID"]["21"] = "Asia/Makassar"
_country["ID"]["22"] = "Asia/Makassar"
_country["ID"]["23"] = "Asia/Makassar"
_country["ID"]["24"] = "Asia/Jakarta"
_country["ID"]["25"] = "Asia/Pontianak"
_country["ID"]["26"] = "Asia/Pontianak"
_country["ID"]["30"] = "Asia/Jakarta"
_country["ID"]["31"] = "Asia/Makassar"
_country["ID"]["33"] = "Asia/Jakarta"
_country["IE"] = "Europe/Dublin"
_country["IL"] = "Asia/Jerusalem"
_country["IM"] = "Europe/Isle_of_Man"
_country["IN"] = "Asia/Calcutta"
_country["IO"] = "Indian/Chagos"
_country["IQ"] = "Asia/Baghdad"
_country["IR"] = "Asia/Tehran"
_country["IS"] = "Atlantic/Reykjavik"
_country["IT"] = "Europe/Rome"
_country["JE"] = "Europe/Jersey"
_country["JM"] = "America/Jamaica"
_country["JO"] = "Asia/Amman"
_country["JP"] = "Asia/Tokyo"
_country["KE"] = "Africa/Nairobi"
_country["KG"] = "Asia/Bishkek"
_country["KH"] = "Asia/Phnom_Penh"
_country["KI"] = "Pacific/Tarawa"
_country["KM"] = "Indian/Comoro"
_country["KN"] = "America/St_Kitts"
_country["KP"] = "Asia/Pyongyang"
_country["KR"] = "Asia/Seoul"
_country["KW"] = "Asia/Kuwait"
_country["KY"] = "America/Cayman"
_country["KZ"] = {}
_country["KZ"]["01"] = "Asia/Almaty"
_country["KZ"]["02"] = "Asia/Almaty"
_country["KZ"]["03"] = "Asia/Qyzylorda"
_country["KZ"]["04"] = "Asia/Aqtobe"
_country["KZ"]["05"] = "Asia/Qyzylorda"
_country["KZ"]["06"] = "Asia/Aqtau"
_country["KZ"]["07"] = "Asia/Oral"
_country["KZ"]["08"] = "Asia/Qyzylorda"
_country["KZ"]["09"] = "Asia/Aqtau"
_country["KZ"]["10"] = "Asia/Qyzylorda"
_country["KZ"]["11"] = "Asia/Almaty"
_country["KZ"]["12"] = "Asia/Qyzylorda"
_country["KZ"]["13"] = "Asia/Aqtobe"
_country["KZ"]["14"] = "Asia/Qyzylorda"
_country["KZ"]["15"] = "Asia/Almaty"
_country["KZ"]["16"] = "Asia/Aqtobe"
_country["KZ"]["17"] = "Asia/Almaty"
_country["LA"] = "Asia/Vientiane"
_country["LB"] = "Asia/Beirut"
_country["LC"] = "America/St_Lucia"
_country["LI"] = "Europe/Vaduz"
_country["LK"] = "Asia/Colombo"
_country["LR"] = "Africa/Monrovia"
_country["LS"] = "Africa/Maseru"
_country["LT"] = "Europe/Vilnius"
_country["LU"] = "Europe/Luxembourg"
_country["LV"] = "Europe/Riga"
_country["LY"] = "Africa/Tripoli"
_country["MA"] = "Africa/Casablanca"
_country["MC"] = "Europe/Monaco"
_country["MD"] = "Europe/Chisinau"
_country["ME"] = "Europe/Podgorica"
_country["MF"] = "America/Marigot"
_country["MG"] = "Indian/Antananarivo"
_country["MK"] = "Europe/Skopje"
_country["ML"] = "Africa/Bamako"
_country["MM"] = "Asia/Rangoon"
_country["MN"] = "Asia/Choibalsan"
_country["MO"] = "Asia/Macao"
_country["MP"] = "Pacific/Saipan"
_country["MQ"] = "America/Martinique"
_country["MR"] = "Africa/Nouakchott"
_country["MS"] = "America/Montserrat"
_country["MT"] = "Europe/Malta"
_country["MU"] = "Indian/Mauritius"
_country["MV"] = "Indian/Maldives"
_country["MW"] = "Africa/Blantyre"
_country["MX"] = {}
_country["MX"]["01"] = "America/Mexico_City"
_country["MX"]["02"] = "America/Tijuana"
_country["MX"]["03"] = "America/Hermosillo"
_country["MX"]["04"] = "America/Merida"
_country["MX"]["05"] = "America/Mexico_City"
_country["MX"]["06"] = "America/Chihuahua"
_country["MX"]["07"] = "America/Monterrey"
_country["MX"]["08"] = "America/Mexico_City"
_country["MX"]["09"] = "America/Mexico_City"
_country["MX"]["10"] = "America/Mazatlan"
_country["MX"]["11"] = "America/Mexico_City"
_country["MX"]["12"] = "America/Mexico_City"
_country["MX"]["13"] = "America/Mexico_City"
_country["MX"]["14"] = "America/Mazatlan"
_country["MX"]["15"] = "America/Chihuahua"
_country["MX"]["16"] = "America/Mexico_City"
_country["MX"]["17"] = "America/Mexico_City"
_country["MX"]["18"] = "America/Mazatlan"
_country["MX"]["19"] = "America/Monterrey"
_country["MX"]["20"] = "America/Mexico_City"
_country["MX"]["21"] = "America/Mexico_City"
_country["MX"]["22"] = "America/Mexico_City"
_country["MX"]["23"] = "America/Cancun"
_country["MX"]["24"] = "America/Mexico_City"
_country["MX"]["25"] = "America/Mazatlan"
_country["MX"]["26"] = "America/Hermosillo"
_country["MX"]["27"] = "America/Merida"
_country["MX"]["28"] = "America/Monterrey"
_country["MX"]["29"] = "America/Mexico_City"
_country["MX"]["30"] = "America/Mexico_City"
_country["MX"]["31"] = "America/Merida"
_country["MX"]["32"] = "America/Monterrey"
_country["MY"] = {}
_country["MY"]["01"] = "Asia/Kuala_Lumpur"
_country["MY"]["02"] = "Asia/Kuala_Lumpur"
_country["MY"]["03"] = "Asia/Kuala_Lumpur"
_country["MY"]["04"] = "Asia/Kuala_Lumpur"
_country["MY"]["05"] = "Asia/Kuala_Lumpur"
_country["MY"]["06"] = "Asia/Kuala_Lumpur"
_country["MY"]["07"] = "Asia/Kuala_Lumpur"
_country["MY"]["08"] = "Asia/Kuala_Lumpur"
_country["MY"]["09"] = "Asia/Kuala_Lumpur"
_country["MY"]["11"] = "Asia/Kuching"
_country["MY"]["12"] = "Asia/Kuala_Lumpur"
_country["MY"]["13"] = "Asia/Kuala_Lumpur"
_country["MY"]["14"] = "Asia/Kuala_Lumpur"
_country["MY"]["15"] = "Asia/Kuching"
_country["MY"]["16"] = "Asia/Kuching"
_country["MZ"] = "Africa/Maputo"
_country["NA"] = "Africa/Windhoek"
_country["NC"] = "Pacific/Noumea"
_country["NE"] = "Africa/Niamey"
_country["NF"] = "Pacific/Norfolk"
_country["NG"] = "Africa/Lagos"
_country["NI"] = "America/Managua"
_country["NL"] = "Europe/Amsterdam"
_country["NO"] = "Europe/Oslo"
_country["NP"] = "Asia/Katmandu"
_country["NR"] = "Pacific/Nauru"
_country["NU"] = "Pacific/Niue"
_country["NZ"] = {}
_country["NZ"]["85"] = "Pacific/Auckland"
_country["NZ"]["E7"] = "Pacific/Auckland"
_country["NZ"]["E8"] = "Pacific/Auckland"
_country["NZ"]["E9"] = "Pacific/Auckland"
_country["NZ"]["F1"] = "Pacific/Auckland"
_country["NZ"]["F2"] = "Pacific/Auckland"
_country["NZ"]["F3"] = "Pacific/Auckland"
_country["NZ"]["F4"] = "Pacific/Auckland"
_country["NZ"]["F5"] = "Pacific/Auckland"
_country["NZ"]["F7"] = "Pacific/Chatham"
_country["NZ"]["F8"] = "Pacific/Auckland"
_country["NZ"]["F9"] = "Pacific/Auckland"
_country["NZ"]["G1"] = "Pacific/Auckland"
_country["NZ"]["G2"] = "Pacific/Auckland"
_country["NZ"]["G3"] = "Pacific/Auckland"
_country["OM"] = "Asia/Muscat"
_country["PA"] = "America/Panama"
_country["PE"] = "America/Lima"
_country["PF"] = "Pacific/Marquesas"
_country["PG"] = "Pacific/Port_Moresby"
_country["PH"] = "Asia/Manila"
_country["PK"] = "Asia/Karachi"
_country["PL"] = "Europe/Warsaw"
_country["PM"] = "America/Miquelon"
_country["PN"] = "Pacific/Pitcairn"
_country["PR"] = "America/Puerto_Rico"
_country["PS"] = "Asia/Gaza"
_country["PT"] = {}
_country["PT"]["02"] = "Europe/Lisbon"
_country["PT"]["03"] = "Europe/Lisbon"
_country["PT"]["04"] = "Europe/Lisbon"
_country["PT"]["05"] = "Europe/Lisbon"
_country["PT"]["06"] = "Europe/Lisbon"
_country["PT"]["07"] = "Europe/Lisbon"
_country["PT"]["08"] = "Europe/Lisbon"
_country["PT"]["09"] = "Europe/Lisbon"
_country["PT"]["10"] = "Atlantic/Madeira"
_country["PT"]["11"] = "Europe/Lisbon"
_country["PT"]["13"] = "Europe/Lisbon"
_country["PT"]["14"] = "Europe/Lisbon"
_country["PT"]["16"] = "Europe/Lisbon"
_country["PT"]["17"] = "Europe/Lisbon"
_country["PT"]["18"] = "Europe/Lisbon"
_country["PT"]["19"] = "Europe/Lisbon"
_country["PT"]["20"] = "Europe/Lisbon"
_country["PT"]["21"] = "Europe/Lisbon"
_country["PT"]["22"] = "Europe/Lisbon"
_country["PW"] = "Pacific/Palau"
_country["PY"] = "America/Asuncion"
_country["QA"] = "Asia/Qatar"
_country["RE"] = "Indian/Reunion"
_country["RO"] = "Europe/Bucharest"
_country["RS"] = "Europe/Belgrade"
_country["RU"] = {}
_country["RU"]["01"] = "Europe/Volgograd"
_country["RU"]["02"] = "Asia/Irkutsk"
_country["RU"]["03"] = "Asia/Novokuznetsk"
_country["RU"]["04"] = "Asia/Novosibirsk"
_country["RU"]["05"] = "Asia/Vladivostok"
_country["RU"]["06"] = "Europe/Moscow"
_country["RU"]["07"] = "Europe/Volgograd"
_country["RU"]["08"] = "Europe/Samara"
_country["RU"]["09"] = "Europe/Moscow"
_country["RU"]["10"] = "Europe/Moscow"
_country["RU"]["11"] = "Asia/Irkutsk"
_country["RU"]["13"] = "Asia/Yekaterinburg"
_country["RU"]["14"] = "Asia/Irkutsk"
_country["RU"]["15"] = "Asia/Anadyr"
_country["RU"]["16"] = "Europe/Samara"
_country["RU"]["17"] = "Europe/Volgograd"
_country["RU"]["18"] = "Asia/Krasnoyarsk"
_country["RU"]["20"] = "Asia/Irkutsk"
_country["RU"]["21"] = "Europe/Moscow"
_country["RU"]["22"] = "Europe/Volgograd"
_country["RU"]["23"] = "Europe/Kaliningrad"
_country["RU"]["24"] = "Europe/Volgograd"
_country["RU"]["25"] = "Europe/Moscow"
_country["RU"]["26"] = "Asia/Kamchatka"
_country["RU"]["27"] = "Europe/Volgograd"
_country["RU"]["28"] = "Europe/Moscow"
_country["RU"]["29"] = "Asia/Novokuznetsk"
_country["RU"]["30"] = "Asia/Vladivostok"
_country["RU"]["31"] = "Asia/Krasnoyarsk"
_country["RU"]["32"] = "Asia/Omsk"
_country["RU"]["33"] = "Asia/Yekaterinburg"
_country["RU"]["34"] = "Asia/Yekaterinburg"
_country["RU"]["35"] = "Asia/Yekaterinburg"
_country["RU"]["36"] = "Asia/Anadyr"
_country["RU"]["37"] = "Europe/Moscow"
_country["RU"]["38"] = "Europe/Volgograd"
_country["RU"]["39"] = "Asia/Krasnoyarsk"
_country["RU"]["40"] = "Asia/Yekaterinburg"
_country["RU"]["41"] = "Europe/Moscow"
_country["RU"]["42"] = "Europe/Moscow"
_country["RU"]["43"] = "Europe/Moscow"
_country["RU"]["44"] = "Asia/Magadan"
_country["RU"]["45"] = "Europe/Samara"
_country["RU"]["46"] = "Europe/Samara"
_country["RU"]["47"] = "Europe/Moscow"
_country["RU"]["48"] = "Europe/Moscow"
_country["RU"]["49"] = "Europe/Moscow"
_country["RU"]["50"] = "Asia/Yekaterinburg"
_country["RU"]["51"] = "Europe/Moscow"
_country["RU"]["52"] = "Europe/Moscow"
_country["RU"]["53"] = "Asia/Novosibirsk"
_country["RU"]["54"] = "Asia/Omsk"
_country["RU"]["55"] = "Europe/Samara"
_country["RU"]["56"] = "Europe/Moscow"
_country["RU"]["57"] = "Europe/Samara"
_country["RU"]["58"] = "Asia/Yekaterinburg"
_country["RU"]["59"] = "Asia/Vladivostok"
_country["RU"]["60"] = "Europe/Kaliningrad"
_country["RU"]["61"] = "Europe/Volgograd"
_country["RU"]["62"] = "Europe/Moscow"
_country["RU"]["63"] = "Asia/Yakutsk"
_country["RU"]["64"] = "Asia/Sakhalin"
_country["RU"]["65"] = "Europe/Samara"
_country["RU"]["66"] = "Europe/Moscow"
_country["RU"]["67"] = "Europe/Samara"
_country["RU"]["68"] = "Europe/Volgograd"
_country["RU"]["69"] = "Europe/Moscow"
_country["RU"]["70"] = "Europe/Volgograd"
_country["RU"]["71"] = "Asia/Yekaterinburg"
_country["RU"]["72"] = "Europe/Moscow"
_country["RU"]["73"] = "Europe/Samara"
_country["RU"]["74"] = "Asia/Krasnoyarsk"
_country["RU"]["75"] = "Asia/Novosibirsk"
_country["RU"]["76"] = "Europe/Moscow"
_country["RU"]["77"] = "Europe/Moscow"
_country["RU"]["78"] = "Asia/Yekaterinburg"
_country["RU"]["79"] = "Asia/Irkutsk"
_country["RU"]["80"] = "Asia/Yekaterinburg"
_country["RU"]["81"] = "Europe/Samara"
_country["RU"]["82"] = "Asia/Irkutsk"
_country["RU"]["83"] = "Europe/Moscow"
_country["RU"]["84"] = "Europe/Volgograd"
_country["RU"]["85"] = "Europe/Moscow"
_country["RU"]["86"] = "Europe/Moscow"
_country["RU"]["87"] = "Asia/Novosibirsk"
_country["RU"]["88"] = "Europe/Moscow"
_country["RU"]["89"] = "Asia/Vladivostok"
_country["RW"] = "Africa/Kigali"
_country["SA"] = "Asia/Riyadh"
_country["SB"] = "Pacific/Guadalcanal"
_country["SC"] = "Indian/Mahe"
_country["SD"] = "Africa/Khartoum"
_country["SE"] = "Europe/Stockholm"
_country["SG"] = "Asia/Singapore"
_country["SH"] = "Atlantic/St_Helena"
_country["SI"] = "Europe/Ljubljana"
_country["SJ"] = "Arctic/Longyearbyen"
_country["SK"] = "Europe/Bratislava"
_country["SL"] = "Africa/Freetown"
_country["SM"] = "Europe/San_Marino"
_country["SN"] = "Africa/Dakar"
_country["SO"] = "Africa/Mogadishu"
_country["SR"] = "America/Paramaribo"
_country["ST"] = "Africa/Sao_Tome"
_country["SV"] = "America/El_Salvador"
_country["SX"] = "America/Curacao"
_country["SY"] = "Asia/Damascus"
_country["SZ"] = "Africa/Mbabane"
_country["TC"] = "America/Grand_Turk"
_country["TD"] = "Africa/Ndjamena"
_country["TF"] = "Indian/Kerguelen"
_country["TG"] = "Africa/Lome"
_country["TH"] = "Asia/Bangkok"
_country["TJ"] = "Asia/Dushanbe"
_country["TK"] = "Pacific/Fakaofo"
_country["TL"] = "Asia/Dili"
_country["TM"] = "Asia/Ashgabat"
_country["TN"] = "Africa/Tunis"
_country["TO"] = "Pacific/Tongatapu"
_country["TR"] = "Asia/Istanbul"
_country["TT"] = "America/Port_of_Spain"
_country["TV"] = "Pacific/Funafuti"
_country["TW"] = "Asia/Taipei"
_country["TZ"] = "Africa/Dar_es_Salaam"
_country["UA"] = {}
_country["UA"]["01"] = "Europe/Kiev"
_country["UA"]["02"] = "Europe/Kiev"
_country["UA"]["03"] = "Europe/Uzhgorod"
_country["UA"]["04"] = "Europe/Zaporozhye"
_country["UA"]["05"] = "Europe/Zaporozhye"
_country["UA"]["06"] = "Europe/Uzhgorod"
_country["UA"]["07"] = "Europe/Zaporozhye"
_country["UA"]["08"] = "Europe/Simferopol"
_country["UA"]["09"] = "Europe/Kiev"
_country["UA"]["10"] = "Europe/Zaporozhye"
_country["UA"]["11"] = "Europe/Simferopol"
_country["UA"]["13"] = "Europe/Kiev"
_country["UA"]["14"] = "Europe/Zaporozhye"
_country["UA"]["15"] = "Europe/Uzhgorod"
_country["UA"]["16"] = "Europe/Zaporozhye"
_country["UA"]["17"] = "Europe/Simferopol"
_country["UA"]["18"] = "Europe/Zaporozhye"
_country["UA"]["19"] = "Europe/Kiev"
_country["UA"]["20"] = "Europe/Simferopol"
_country["UA"]["21"] = "Europe/Kiev"
_country["UA"]["22"] = "Europe/Uzhgorod"
_country["UA"]["23"] = "Europe/Kiev"
_country["UA"]["24"] = "Europe/Uzhgorod"
_country["UA"]["25"] = "Europe/Uzhgorod"
_country["UA"]["26"] = "Europe/Zaporozhye"
_country["UA"]["27"] = "Europe/Kiev"
_country["UG"] = "Africa/Kampala"
_country["US"] = {}
_country["US"]["AK"] = "America/Anchorage"
_country["US"]["AL"] = "America/Chicago"
_country["US"]["AR"] = "America/Chicago"
_country["US"]["AZ"] = "America/Phoenix"
_country["US"]["CA"] = "America/Los_Angeles"
_country["US"]["CO"] = "America/Denver"
_country["US"]["CT"] = "America/New_York"
_country["US"]["DC"] = "America/New_York"
_country["US"]["DE"] = "America/New_York"
_country["US"]["FL"] = "America/New_York"
_country["US"]["GA"] = "America/New_York"
_country["US"]["HI"] = "Pacific/Honolulu"
_country["US"]["IA"] = "America/Chicago"
_country["US"]["ID"] = "America/Denver"
_country["US"]["IL"] = "America/Chicago"
_country["US"]["IN"] = "America/Indianapolis"
_country["US"]["KS"] = "America/Chicago"
_country["US"]["KY"] = "America/New_York"
_country["US"]["LA"] = "America/Chicago"
_country["US"]["MA"] = "America/New_York"
_country["US"]["MD"] = "America/New_York"
_country["US"]["ME"] = "America/New_York"
_country["US"]["MI"] = "America/New_York"
_country["US"]["MN"] = "America/Chicago"
_country["US"]["MO"] = "America/Chicago"
_country["US"]["MS"] = "America/Chicago"
_country["US"]["MT"] = "America/Denver"
_country["US"]["NC"] = "America/New_York"
_country["US"]["ND"] = "America/Chicago"
_country["US"]["NE"] = "America/Chicago"
_country["US"]["NH"] = "America/New_York"
_country["US"]["NJ"] = "America/New_York"
_country["US"]["NM"] = "America/Denver"
_country["US"]["NV"] = "America/Los_Angeles"
_country["US"]["NY"] = "America/New_York"
_country["US"]["OH"] = "America/New_York"
_country["US"]["OK"] = "America/Chicago"
_country["US"]["OR"] = "America/Los_Angeles"
_country["US"]["PA"] = "America/New_York"
_country["US"]["RI"] = "America/New_York"
_country["US"]["SC"] = "America/New_York"
_country["US"]["SD"] = "America/Chicago"
_country["US"]["TN"] = "America/Chicago"
_country["US"]["TX"] = "America/Chicago"
_country["US"]["UT"] = "America/Denver"
_country["US"]["VA"] = "America/New_York"
_country["US"]["VT"] = "America/New_York"
_country["US"]["WA"] = "America/Los_Angeles"
_country["US"]["WI"] = "America/Chicago"
_country["US"]["WV"] = "America/New_York"
_country["US"]["WY"] = "America/Denver"
_country["UY"] = "America/Montevideo"
_country["UZ"] = {}
_country["UZ"]["01"] = "Asia/Tashkent"
_country["UZ"]["02"] = "Asia/Samarkand"
_country["UZ"]["03"] = "Asia/Tashkent"
_country["UZ"]["06"] = "Asia/Tashkent"
_country["UZ"]["07"] = "Asia/Samarkand"
_country["UZ"]["08"] = "Asia/Samarkand"
_country["UZ"]["09"] = "Asia/Samarkand"
_country["UZ"]["10"] = "Asia/Samarkand"
_country["UZ"]["12"] = "Asia/Samarkand"
_country["UZ"]["13"] = "Asia/Tashkent"
_country["UZ"]["14"] = "Asia/Tashkent"
_country["VA"] = "Europe/Vatican"
_country["VC"] = "America/St_Vincent"
_country["VE"] = "America/Caracas"
_country["VG"] = "America/Tortola"
_country["VI"] = "America/St_Thomas"
_country["VN"] = "Asia/Phnom_Penh"
_country["VU"] = "Pacific/Efate"
_country["WF"] = "Pacific/Wallis"
_country["WS"] = "Pacific/Samoa"
_country["YE"] = "Asia/Aden"
_country["YT"] = "Indian/Mayotte"
_country["YU"] = "Europe/Belgrade"
_country["ZA"] = "Africa/Johannesburg"
_country["ZM"] = "Africa/Lusaka"
_country["ZW"] = "Africa/Harare"
_country = {
'AD': 'Europe/Andorra',
'AE': 'Asia/Dubai',
'AF': 'Asia/Kabul',
'AG': 'America/Antigua',
'AI': 'America/Anguilla',
'AL': 'Europe/Tirane',
'AM': 'Asia/Yerevan',
'AO': 'Africa/Luanda',
'AR': {'01': 'America/Argentina/Buenos_Aires',
'02': 'America/Argentina/Catamarca',
'03': 'America/Argentina/Tucuman',
'04': 'America/Argentina/Rio_Gallegos',
'05': 'America/Argentina/Cordoba',
'06': 'America/Argentina/Tucuman',
'07': 'America/Argentina/Buenos_Aires',
'08': 'America/Argentina/Buenos_Aires',
'09': 'America/Argentina/Tucuman',
'10': 'America/Argentina/Jujuy',
'11': 'America/Argentina/San_Luis',
'12': 'America/Argentina/La_Rioja',
'13': 'America/Argentina/Mendoza',
'14': 'America/Argentina/Buenos_Aires',
'15': 'America/Argentina/San_Luis',
'16': 'America/Argentina/Buenos_Aires',
'17': 'America/Argentina/Salta',
'18': 'America/Argentina/San_Juan',
'19': 'America/Argentina/San_Luis',
'20': 'America/Argentina/Rio_Gallegos',
'21': 'America/Argentina/Buenos_Aires',
'22': 'America/Argentina/Catamarca',
'23': 'America/Argentina/Ushuaia',
'24': 'America/Argentina/Tucuman'},
'AS': 'US/Samoa',
'AT': 'Europe/Vienna',
'AU': {'01': 'Australia/Canberra',
'02': 'Australia/NSW',
'03': 'Australia/North',
'04': 'Australia/Queensland',
'05': 'Australia/South',
'06': 'Australia/Tasmania',
'07': 'Australia/Victoria',
'08': 'Australia/West'},
'AW': 'America/Aruba',
'AX': 'Europe/Mariehamn',
'AZ': 'Asia/Baku',
'BA': 'Europe/Sarajevo',
'BB': 'America/Barbados',
'BD': 'Asia/Dhaka',
'BE': 'Europe/Brussels',
'BF': 'Africa/Ouagadougou',
'BG': 'Europe/Sofia',
'BH': 'Asia/Bahrain',
'BI': 'Africa/Bujumbura',
'BJ': 'Africa/Porto-Novo',
'BL': 'America/St_Barthelemy',
'BM': 'Atlantic/Bermuda',
'BN': 'Asia/Brunei',
'BO': 'America/La_Paz',
'BQ': 'America/Curacao',
'BR': {'01': 'America/Rio_Branco',
'02': 'America/Maceio',
'03': 'America/Sao_Paulo',
'04': 'America/Manaus',
'05': 'America/Bahia',
'06': 'America/Fortaleza',
'07': 'America/Sao_Paulo',
'08': 'America/Sao_Paulo',
'11': 'America/Campo_Grande',
'13': 'America/Belem',
'14': 'America/Cuiaba',
'15': 'America/Sao_Paulo',
'16': 'America/Belem',
'17': 'America/Recife',
'18': 'America/Sao_Paulo',
'20': 'America/Fortaleza',
'21': 'America/Sao_Paulo',
'22': 'America/Recife',
'23': 'America/Sao_Paulo',
'24': 'America/Porto_Velho',
'25': 'America/Boa_Vista',
'26': 'America/Sao_Paulo',
'27': 'America/Sao_Paulo',
'28': 'America/Maceio',
'29': 'America/Sao_Paulo',
'30': 'America/Recife',
'31': 'America/Araguaina'},
'BS': 'America/Nassau',
'BT': 'Asia/Thimphu',
'BW': 'Africa/Gaborone',
'BY': 'Europe/Minsk',
'BZ': 'America/Belize',
'CA': {'AB': 'America/Edmonton',
'BC': 'America/Vancouver',
'MB': 'America/Winnipeg',
'NB': 'America/Halifax',
'NL': 'America/St_Johns',
'NS': 'America/Halifax',
'NT': 'America/Yellowknife',
'NU': 'America/Rankin_Inlet',
'ON': 'America/Rainy_River',
'PE': 'America/Halifax',
'QC': 'America/Montreal',
'SK': 'America/Regina',
'YT': 'America/Whitehorse'},
'CC': 'Indian/Cocos',
'CD': {'02': 'Africa/Kinshasa',
'05': 'Africa/Lubumbashi',
'06': 'Africa/Kinshasa',
'08': 'Africa/Kinshasa',
'10': 'Africa/Lubumbashi',
'11': 'Africa/Lubumbashi',
'12': 'Africa/Lubumbashi'},
'CF': 'Africa/Bangui',
'CG': 'Africa/Brazzaville',
'CH': 'Europe/Zurich',
'CI': 'Africa/Abidjan',
'CK': 'Pacific/Rarotonga',
'CL': 'Chile/Continental',
'CM': 'Africa/Lagos',
'CN': {'01': 'Asia/Shanghai',
'02': 'Asia/Shanghai',
'03': 'Asia/Shanghai',
'04': 'Asia/Shanghai',
'05': 'Asia/Harbin',
'06': 'Asia/Chongqing',
'07': 'Asia/Shanghai',
'08': 'Asia/Harbin',
'09': 'Asia/Shanghai',
'10': 'Asia/Shanghai',
'11': 'Asia/Chongqing',
'12': 'Asia/Shanghai',
'13': 'Asia/Urumqi',
'14': 'Asia/Chongqing',
'15': 'Asia/Chongqing',
'16': 'Asia/Chongqing',
'18': 'Asia/Chongqing',
'19': 'Asia/Harbin',
'20': 'Asia/Harbin',
'21': 'Asia/Chongqing',
'22': 'Asia/Harbin',
'23': 'Asia/Shanghai',
'24': 'Asia/Chongqing',
'25': 'Asia/Shanghai',
'26': 'Asia/Chongqing',
'28': 'Asia/Shanghai',
'29': 'Asia/Chongqing',
'30': 'Asia/Chongqing',
'31': 'Asia/Chongqing',
'32': 'Asia/Chongqing',
'33': 'Asia/Chongqing'},
'CO': 'America/Bogota',
'CR': 'America/Costa_Rica',
'CU': 'America/Havana',
'CV': 'Atlantic/Cape_Verde',
'CW': 'America/Curacao',
'CX': 'Indian/Christmas',
'CY': 'Asia/Nicosia',
'CZ': 'Europe/Prague',
'DE': 'Europe/Berlin',
'DJ': 'Africa/Djibouti',
'DK': 'Europe/Copenhagen',
'DM': 'America/Dominica',
'DO': 'America/Santo_Domingo',
'DZ': 'Africa/Algiers',
'EC': {'01': 'Pacific/Galapagos',
'02': 'America/Guayaquil',
'03': 'America/Guayaquil',
'04': 'America/Guayaquil',
'05': 'America/Guayaquil',
'06': 'America/Guayaquil',
'07': 'America/Guayaquil',
'08': 'America/Guayaquil',
'09': 'America/Guayaquil',
'10': 'America/Guayaquil',
'11': 'America/Guayaquil',
'12': 'America/Guayaquil',
'13': 'America/Guayaquil',
'14': 'America/Guayaquil',
'15': 'America/Guayaquil',
'17': 'America/Guayaquil',
'19': 'America/Guayaquil',
'20': 'America/Guayaquil',
'22': 'America/Guayaquil'},
'EE': 'Europe/Tallinn',
'EH': 'Africa/El_Aaiun',
'ER': 'Africa/Asmera',
'ES': {'07': 'Europe/Madrid',
'27': 'Europe/Madrid',
'29': 'Europe/Madrid',
'31': 'Europe/Madrid',
'32': 'Europe/Madrid',
'34': 'Europe/Madrid',
'39': 'Europe/Madrid',
'51': 'Africa/Ceuta',
'52': 'Europe/Madrid',
'53': 'Atlantic/Canary',
'54': 'Europe/Madrid',
'55': 'Europe/Madrid',
'56': 'Europe/Madrid',
'57': 'Europe/Madrid',
'58': 'Europe/Madrid',
'59': 'Europe/Madrid'},
'ET': 'Africa/Addis_Ababa',
'FI': 'Europe/Helsinki',
'FJ': 'Pacific/Fiji',
'FK': 'Atlantic/Stanley',
'FO': 'Atlantic/Faeroe',
'FR': 'Europe/Paris',
'GA': 'Africa/Libreville',
'GB': 'Europe/London',
'GD': 'America/Grenada',
'GE': 'Asia/Tbilisi',
'GF': 'America/Cayenne',
'GG': 'Europe/Guernsey',
'GH': 'Africa/Accra',
'GI': 'Europe/Gibraltar',
'GL': {'01': 'America/Thule',
'02': 'America/Godthab',
'03': 'America/Godthab'},
'GM': 'Africa/Banjul',
'GN': 'Africa/Conakry',
'GP': 'America/Guadeloupe',
'GQ': 'Africa/Malabo',
'GR': 'Europe/Athens',
'GS': 'Atlantic/South_Georgia',
'GT': 'America/Guatemala',
'GW': 'Africa/Bissau',
'GY': 'America/Guyana',
'HK': 'Asia/Hong_Kong',
'HN': 'America/Tegucigalpa',
'HR': 'Europe/Zagreb',
'HT': 'America/Port-au-Prince',
'HU': 'Europe/Budapest',
'ID': {'01': 'Asia/Pontianak',
'02': 'Asia/Makassar',
'03': 'Asia/Jakarta',
'04': 'Asia/Jakarta',
'05': 'Asia/Jakarta',
'06': 'Asia/Jakarta',
'07': 'Asia/Jakarta',
'08': 'Asia/Jakarta',
'09': 'Asia/Jayapura',
'10': 'Asia/Jakarta',
'11': 'Asia/Pontianak',
'12': 'Asia/Makassar',
'13': 'Asia/Makassar',
'14': 'Asia/Makassar',
'15': 'Asia/Jakarta',
'16': 'Asia/Makassar',
'17': 'Asia/Makassar',
'18': 'Asia/Makassar',
'19': 'Asia/Pontianak',
'20': 'Asia/Makassar',
'21': 'Asia/Makassar',
'22': 'Asia/Makassar',
'23': 'Asia/Makassar',
'24': 'Asia/Jakarta',
'25': 'Asia/Pontianak',
'26': 'Asia/Pontianak',
'30': 'Asia/Jakarta',
'31': 'Asia/Makassar',
'33': 'Asia/Jakarta'},
'IE': 'Europe/Dublin',
'IL': 'Asia/Jerusalem',
'IM': 'Europe/Isle_of_Man',
'IN': 'Asia/Calcutta',
'IO': 'Indian/Chagos',
'IQ': 'Asia/Baghdad',
'IR': 'Asia/Tehran',
'IS': 'Atlantic/Reykjavik',
'IT': 'Europe/Rome',
'JE': 'Europe/Jersey',
'JM': 'America/Jamaica',
'JO': 'Asia/Amman',
'JP': 'Asia/Tokyo',
'KE': 'Africa/Nairobi',
'KG': 'Asia/Bishkek',
'KH': 'Asia/Phnom_Penh',
'KM': 'Indian/Comoro',
'KN': 'America/St_Kitts',
'KP': 'Asia/Pyongyang',
'KR': 'Asia/Seoul',
'KW': 'Asia/Kuwait',
'KY': 'America/Cayman',
'KZ': {'01': 'Asia/Almaty',
'02': 'Asia/Almaty',
'03': 'Asia/Qyzylorda',
'05': 'Asia/Qyzylorda',
'06': 'Asia/Aqtau',
'07': 'Asia/Oral',
'08': 'Asia/Qyzylorda',
'10': 'Asia/Qyzylorda',
'11': 'Asia/Almaty',
'12': 'Asia/Qyzylorda',
'13': 'Asia/Aqtobe',
'14': 'Asia/Qyzylorda',
'15': 'Asia/Almaty',
'16': 'Asia/Aqtobe',
'17': 'Asia/Almaty'},
'LA': 'Asia/Vientiane',
'LB': 'Asia/Beirut',
'LC': 'America/St_Lucia',
'LI': 'Europe/Vaduz',
'LK': 'Asia/Colombo',
'LR': 'Africa/Monrovia',
'LT': 'Europe/Vilnius',
'LU': 'Europe/Luxembourg',
'LV': 'Europe/Riga',
'LY': 'Africa/Tripoli',
'MA': 'Africa/Casablanca',
'MC': 'Europe/Monaco',
'ME': 'Europe/Podgorica',
'MF': 'America/Marigot',
'MG': 'Indian/Antananarivo',
'MK': 'Europe/Skopje',
'ML': 'Africa/Bamako',
'MM': 'Asia/Rangoon',
'MN': 'Asia/Choibalsan',
'MO': 'Asia/Macao',
'MP': 'Pacific/Saipan',
'MQ': 'America/Martinique',
'MR': 'Africa/Nouakchott',
'MS': 'America/Montserrat',
'MT': 'Europe/Malta',
'MU': 'Indian/Mauritius',
'MV': 'Indian/Maldives',
'MW': 'Africa/Blantyre',
'MX': {'01': 'America/Mexico_City',
'02': 'America/Tijuana',
'03': 'America/Hermosillo',
'04': 'America/Merida',
'05': 'America/Mexico_City',
'06': 'America/Chihuahua',
'07': 'America/Monterrey',
'08': 'America/Mexico_City',
'09': 'America/Mexico_City',
'10': 'America/Mazatlan',
'11': 'America/Mexico_City',
'12': 'America/Mexico_City',
'13': 'America/Mexico_City',
'14': 'America/Mazatlan',
'15': 'America/Chihuahua',
'16': 'America/Mexico_City',
'17': 'America/Mexico_City',
'18': 'America/Mazatlan',
'19': 'America/Monterrey',
'20': 'America/Mexico_City',
'21': 'America/Mexico_City',
'22': 'America/Mexico_City',
'23': 'America/Cancun',
'24': 'America/Mexico_City',
'25': 'America/Mazatlan',
'26': 'America/Hermosillo',
'27': 'America/Merida',
'28': 'America/Monterrey',
'29': 'America/Mexico_City',
'30': 'America/Mexico_City',
'31': 'America/Merida',
'32': 'America/Monterrey'},
'MY': {'01': 'Asia/Kuala_Lumpur',
'02': 'Asia/Kuala_Lumpur',
'03': 'Asia/Kuala_Lumpur',
'07': 'Asia/Kuala_Lumpur',
'08': 'Asia/Kuala_Lumpur',
'09': 'Asia/Kuala_Lumpur',
'11': 'Asia/Kuching',
'12': 'Asia/Kuala_Lumpur',
'13': 'Asia/Kuala_Lumpur',
'14': 'Asia/Kuala_Lumpur',
'15': 'Asia/Kuching',
'16': 'Asia/Kuching'},
'MZ': 'Africa/Maputo',
'NA': 'Africa/Windhoek',
'NC': 'Pacific/Noumea',
'NE': 'Africa/Niamey',
'NF': 'Pacific/Norfolk',
'NG': 'Africa/Lagos',
'NI': 'America/Managua',
'NL': 'Europe/Amsterdam',
'NO': 'Europe/Oslo',
'NP': 'Asia/Katmandu',
'NR': 'Pacific/Nauru',
'NU': 'Pacific/Niue',
'NZ': {'85': 'Pacific/Auckland',
'E7': 'Pacific/Auckland',
'E8': 'Pacific/Auckland',
'E9': 'Pacific/Auckland',
'F1': 'Pacific/Auckland',
'F2': 'Pacific/Auckland',
'F4': 'Pacific/Auckland',
'F5': 'Pacific/Auckland',
'F7': 'Pacific/Chatham',
'F8': 'Pacific/Auckland',
'G1': 'Pacific/Auckland',
'G2': 'Pacific/Auckland',
'G3': 'Pacific/Auckland'},
'OM': 'Asia/Muscat',
'PA': 'America/Panama',
'PE': 'America/Lima',
'PF': 'Pacific/Marquesas',
'PG': 'Pacific/Port_Moresby',
'PH': 'Asia/Manila',
'PK': 'Asia/Karachi',
'PL': 'Europe/Warsaw',
'PM': 'America/Miquelon',
'PN': 'Pacific/Pitcairn',
'PR': 'America/Puerto_Rico',
'PS': 'Asia/Gaza',
'PT': {'02': 'Europe/Lisbon',
'03': 'Europe/Lisbon',
'04': 'Europe/Lisbon',
'05': 'Europe/Lisbon',
'06': 'Europe/Lisbon',
'07': 'Europe/Lisbon',
'08': 'Europe/Lisbon',
'09': 'Europe/Lisbon',
'10': 'Atlantic/Madeira',
'11': 'Europe/Lisbon',
'13': 'Europe/Lisbon',
'14': 'Europe/Lisbon',
'16': 'Europe/Lisbon',
'17': 'Europe/Lisbon',
'18': 'Europe/Lisbon',
'19': 'Europe/Lisbon',
'20': 'Europe/Lisbon',
'21': 'Europe/Lisbon',
'22': 'Europe/Lisbon'},
'PW': 'Pacific/Palau',
'PY': 'America/Asuncion',
'QA': 'Asia/Qatar',
'RE': 'Indian/Reunion',
'RO': 'Europe/Bucharest',
'RS': 'Europe/Belgrade',
'RU': {'01': 'Europe/Volgograd',
'02': 'Asia/Irkutsk',
'03': 'Asia/Novokuznetsk',
'04': 'Asia/Novosibirsk',
'05': 'Asia/Vladivostok',
'06': 'Europe/Moscow',
'07': 'Europe/Volgograd',
'08': 'Europe/Samara',
'09': 'Europe/Moscow',
'10': 'Europe/Moscow',
'11': 'Asia/Irkutsk',
'13': 'Asia/Yekaterinburg',
'14': 'Asia/Irkutsk',
'15': 'Asia/Anadyr',
'16': 'Europe/Samara',
'17': 'Europe/Volgograd',
'18': 'Asia/Krasnoyarsk',
'20': 'Asia/Irkutsk',
'21': 'Europe/Moscow',
'22': 'Europe/Volgograd',
'23': 'Europe/Kaliningrad',
'24': 'Europe/Volgograd',
'25': 'Europe/Moscow',
'26': 'Asia/Kamchatka',
'27': 'Europe/Volgograd',
'28': 'Europe/Moscow',
'30': 'Asia/Vladivostok',
'31': 'Asia/Krasnoyarsk',
'32': 'Asia/Omsk',
'33': 'Asia/Yekaterinburg',
'34': 'Asia/Yekaterinburg',
'35': 'Asia/Yekaterinburg',
'36': 'Asia/Anadyr',
'37': 'Europe/Moscow',
'38': 'Europe/Volgograd',
'39': 'Asia/Krasnoyarsk',
'40': 'Asia/Yekaterinburg',
'41': 'Europe/Moscow',
'42': 'Europe/Moscow',
'43': 'Europe/Moscow',
'45': 'Europe/Samara',
'46': 'Europe/Samara',
'47': 'Europe/Moscow',
'48': 'Europe/Moscow',
'49': 'Europe/Moscow',
'50': 'Asia/Yekaterinburg',
'51': 'Europe/Moscow',
'52': 'Europe/Moscow',
'53': 'Asia/Novosibirsk',
'54': 'Asia/Omsk',
'55': 'Europe/Samara',
'56': 'Europe/Moscow',
'57': 'Europe/Samara',
'58': 'Asia/Yekaterinburg',
'59': 'Asia/Vladivostok',
'60': 'Europe/Kaliningrad',
'61': 'Europe/Volgograd',
'62': 'Europe/Moscow',
'63': 'Asia/Yakutsk',
'65': 'Europe/Samara',
'66': 'Europe/Moscow',
'68': 'Europe/Volgograd',
'69': 'Europe/Moscow',
'70': 'Europe/Volgograd',
'71': 'Asia/Yekaterinburg',
'72': 'Europe/Moscow',
'73': 'Europe/Samara',
'74': 'Asia/Krasnoyarsk',
'75': 'Asia/Novosibirsk',
'76': 'Europe/Moscow',
'77': 'Europe/Moscow',
'79': 'Asia/Irkutsk',
'80': 'Asia/Yekaterinburg',
'81': 'Europe/Samara',
'82': 'Asia/Irkutsk',
'84': 'Europe/Volgograd',
'85': 'Europe/Moscow',
'86': 'Europe/Moscow',
'87': 'Asia/Novosibirsk',
'88': 'Europe/Moscow',
'89': 'Asia/Vladivostok'},
'RW': 'Africa/Kigali',
'SA': 'Asia/Riyadh',
'SB': 'Pacific/Guadalcanal',
'SC': 'Indian/Mahe',
'SD': 'Africa/Khartoum',
'SE': 'Europe/Stockholm',
'SG': 'Asia/Singapore',
'SH': 'Atlantic/St_Helena',
'SI': 'Europe/Ljubljana',
'SJ': 'Arctic/Longyearbyen',
'SK': 'Europe/Bratislava',
'SL': 'Africa/Freetown',
'SM': 'Europe/San_Marino',
'SN': 'Africa/Dakar',
'SO': 'Africa/Mogadishu',
'SR': 'America/Paramaribo',
'ST': 'Africa/Sao_Tome',
'SX': 'America/Curacao',
'SY': 'Asia/Damascus',
'SZ': 'Africa/Mbabane',
'TC': 'America/Grand_Turk',
'TD': 'Africa/Ndjamena',
'TF': 'Indian/Kerguelen',
'TG': 'Africa/Lome',
'TJ': 'Asia/Dushanbe',
'TK': 'Pacific/Fakaofo',
'TL': 'Asia/Dili',
'TM': 'Asia/Ashgabat',
'TN': 'Africa/Tunis',
'TO': 'Pacific/Tongatapu',
'TR': 'Asia/Istanbul',
'TT': 'America/Port_of_Spain',
'TV': 'Pacific/Funafuti',
'TW': 'Asia/Taipei',
'TZ': 'Africa/Dar_es_Salaam',
'UA': {'01': 'Europe/Kiev',
'02': 'Europe/Kiev',
'03': 'Europe/Uzhgorod',
'04': 'Europe/Zaporozhye',
'05': 'Europe/Zaporozhye',
'06': 'Europe/Uzhgorod',
'07': 'Europe/Zaporozhye',
'08': 'Europe/Simferopol',
'10': 'Europe/Zaporozhye',
'11': 'Europe/Simferopol',
'13': 'Europe/Kiev',
'14': 'Europe/Zaporozhye',
'15': 'Europe/Uzhgorod',
'16': 'Europe/Zaporozhye',
'17': 'Europe/Simferopol',
'18': 'Europe/Zaporozhye',
'19': 'Europe/Kiev',
'20': 'Europe/Simferopol',
'21': 'Europe/Kiev',
'22': 'Europe/Uzhgorod',
'23': 'Europe/Kiev',
'24': 'Europe/Uzhgorod',
'25': 'Europe/Uzhgorod',
'26': 'Europe/Zaporozhye',
'27': 'Europe/Kiev'},
'UG': 'Africa/Kampala',
'US': {'AK': 'America/Anchorage',
'AL': 'America/Chicago',
'AR': 'America/Chicago',
'AZ': 'America/Phoenix',
'CA': 'America/Los_Angeles',
'CO': 'America/Denver',
'CT': 'America/New_York',
'DC': 'America/New_York',
'DE': 'America/New_York',
'FL': 'America/New_York',
'GA': 'America/New_York',
'IA': 'America/Chicago',
'ID': 'America/Denver',
'IL': 'America/Chicago',
'IN': 'America/Indianapolis',
'KS': 'America/Chicago',
'LA': 'America/Chicago',
'MA': 'America/New_York',
'MD': 'America/New_York',
'ME': 'America/New_York',
'MI': 'America/New_York',
'MN': 'America/Chicago',
'MO': 'America/Chicago',
'MS': 'America/Chicago',
'MT': 'America/Denver',
'NC': 'America/New_York',
'ND': 'America/Chicago',
'NE': 'America/Chicago',
'NJ': 'America/New_York',
'NM': 'America/Denver',
'NV': 'America/Los_Angeles',
'NY': 'America/New_York',
'OK': 'America/Chicago',
'OR': 'America/Los_Angeles',
'PA': 'America/New_York',
'RI': 'America/New_York',
'SC': 'America/New_York',
'SD': 'America/Chicago',
'TN': 'America/Chicago',
'TX': 'America/Chicago',
'UT': 'America/Denver',
'VA': 'America/New_York',
'VT': 'America/New_York',
'WA': 'America/Los_Angeles',
'WI': 'America/Chicago',
'WY': 'America/Denver'},
'UY': 'America/Montevideo',
'UZ': {'01': 'Asia/Tashkent',
'02': 'Asia/Samarkand',
'03': 'Asia/Tashkent',
'06': 'Asia/Tashkent',
'07': 'Asia/Samarkand',
'08': 'Asia/Samarkand',
'09': 'Asia/Samarkand',
'12': 'Asia/Samarkand',
'13': 'Asia/Tashkent',
'14': 'Asia/Tashkent'},
'VA': 'Europe/Vatican',
'VC': 'America/St_Vincent',
'VE': 'America/Caracas',
'VG': 'America/Tortola',
'VI': 'America/St_Thomas',
'VN': 'Asia/Phnom_Penh',
'VU': 'Pacific/Efate',
'WF': 'Pacific/Wallis',
'WS': 'Pacific/Samoa',
'YE': 'Asia/Aden',
'YT': 'Indian/Mayotte',
'YU': 'Europe/Belgrade',
'ZA': 'Africa/Johannesburg',
'ZM': 'Africa/Lusaka',
'ZW': 'Africa/Harare'
}
def time_zone_by_country_and_region(country_code, region_name=None):
if country_code not in _country:
return None
return ''
if not region_name or region_name == '00':
region_name = None
timezones = _country[country_code]
if isinstance(timezones, str):
return timezones
if region_name:
if not region_name:
return ''
return timezones.get(region_name)
# -*- coding: utf-8 -*-
"""
Misc. utility functions. It is part of the pygeoip package.
Utility functions. Part of the pygeoip package.
@author: Jennifer Ennis <zaylea at gmail dot com>
@author: Jennifer Ennis <zaylea@gmail.com>
@license:
Copyright(C) 2004 MaxMind LLC
@license: Copyright(C) 2004 MaxMind LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
......@@ -20,23 +20,17 @@ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
"""
import six
import socket
import binascii
def ip2long(ip):
"""
Convert a IPv4 address into a 32-bit integer.
@param ip: quad-dotted IPv4 address
Wrapper function for IPv4 and IPv6 converters
@param ip: IPv4 or IPv6 address
@type ip: str
@return: network byte order 32-bit integer
@rtype: int
"""
ip_array = ip.split('.')
if six.PY3:
# int and long are unified in py3
ip_long = int(ip_array[0]) * 16777216 + int(ip_array[1]) * 65536 + int(ip_array[2]) * 256 + int(ip_array[3])
else:
ip_long = long(ip_array[0]) * 16777216 + long(ip_array[1]) * 65536 + long(ip_array[2]) * 256 + long(ip_array[3])
return ip_long
try:
return int(binascii.hexlify(socket.inet_aton(ip)), 16)
except socket.error:
return int(binascii.hexlify(socket.inet_pton(socket.AF_INET6, ip)), 16)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Setup file for pygeoip package.
......@@ -33,15 +33,17 @@ setup(name='pygeoip',
description='Pure Python GeoIP API',
author='Jennifer Ennis',
author_email='zaylea@gmail.com',
url='http://code.google.com/p/pygeoip/',
maintainer='William Tisäter',
maintainer_email='william@defunct.cc',
url='https://github.com/appliedsec/pygeoip',
classifiers=['Programming Language :: Python',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2'],
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3'],
packages=['pygeoip'],
install_requires=['six'],
license='LGPL',
license='LGPLv3+',
keywords='geoip')
......@@ -3,6 +3,9 @@ import os.path as path
DATA_DIR = path.join(path.dirname(path.realpath(__file__)), 'data')
COUNTRY_DB_PATH = path.join(DATA_DIR, 'GeoIP.dat')
COUNTRY_V6_DB_PATH = path.join(DATA_DIR, 'GeoIPv6.dat')
REGION_DB_PATH = path.join(DATA_DIR, 'GeoIPRegion.dat')
CITY_DB_PATH = path.join(DATA_DIR, 'GeoLiteCity.dat')
ORG_DB_PATH = path.join(DATA_DIR, 'GeoIPOrg.dat')
ASNUM_DB_PATH = path.join(DATA_DIR, 'GeoIPASNum.dat')
ISP_DB_PATH = path.join(DATA_DIR, 'GeoIPISP.dat')
# -*- coding: utf-8 -*-
import unittest
import pygeoip
from tests.config import ASNUM_DB_PATH
class TestGeoIPASNumFunctions(unittest.TestCase):
def setUp(self):
self.us_as = 'AS15169 Google Inc.'
self.us_ip = '64.233.161.99'
self.us_hostname = 'google.com'
self.gb_as = 'AS2818 BBC Internet Services, UK'
self.gb_ip = '212.58.253.68'
self.gb_hostname = 'bbc.com'
self.gia = pygeoip.GeoIP(ASNUM_DB_PATH)
def testOrgByAddr(self):
gb_as = self.gia.org_by_addr(self.gb_ip)
us_as = self.gia.org_by_addr(self.us_ip)
self.assertEqual(gb_as, self.gb_as)
self.assertEqual(us_as, self.us_as)
def testOrgByName(self):
gb_as = self.gia.org_by_name(self.gb_hostname)
us_as = self.gia.org_by_name(self.us_hostname)
self.assertEqual(gb_as, self.gb_as)
self.assertEqual(us_as, self.us_as)
# -*- coding: utf-8 -*-
import unittest
import pygeoip
from pygeoip import MEMORY_CACHE, MMAP_CACHE, STANDARD
from tests.config import COUNTRY_DB_PATH
class TestGeoIPCacheMethods(unittest.TestCase):
def setUp(self):
self.us_ip = '64.233.161.99'
self.us_code = 'US'
self.gi_mmap = pygeoip.GeoIP(COUNTRY_DB_PATH, MMAP_CACHE)
self.gi_memory = pygeoip.GeoIP(COUNTRY_DB_PATH, MEMORY_CACHE)
self.gi_standard = pygeoip.GeoIP(COUNTRY_DB_PATH, STANDARD)
def testCountryCodeByAddr(self):
code_mmap = self.gi_mmap.country_code_by_addr(self.us_ip)
code_memory = self.gi_memory.country_code_by_addr(self.us_ip)
code_standard = self.gi_standard.country_code_by_addr(self.us_ip)
self.assertEqual(code_mmap, self.us_code)
self.assertEqual(code_memory, self.us_code)
self.assertEqual(code_standard, self.us_code)
......@@ -40,7 +40,8 @@ class TestGeoIPCityFunctions(unittest.TestCase):
'longitude': -0.23339999999998895,
'country_code3': 'GBR',
'latitude': 51.283299999999997,
'postal_code': None, 'dma_code': 0,
'postal_code': '',
'dma_code': 0,
'country_code': 'GB',
'country_name': 'United Kingdom',
'time_zone': 'Europe/London'
......@@ -50,6 +51,8 @@ class TestGeoIPCityFunctions(unittest.TestCase):
self.gb_region_data = {'region_name': 'N7', 'country_code': 'GB'}
self.gic = pygeoip.GeoIP(CITY_DB_PATH)
self.gic_mem = pygeoip.GeoIP(CITY_DB_PATH, pygeoip.MEMORY_CACHE)
self.gic_mmap = pygeoip.GeoIP(CITY_DB_PATH, pygeoip.MMAP_CACHE)
def testCountryCodeByName(self):
us_code = self.gic.country_code_by_name(self.us_hostname)
......@@ -93,19 +96,12 @@ class TestGeoIPCityFunctions(unittest.TestCase):
self.assertEqual(us_region, self.us_region_data)
self.assertEqual(gb_region, self.gb_region_data)
def testTimeZoneByAddr(self):
us_time_zone = self.gic.time_zone_by_addr(self.us_ip)
gb_time_zone = self.gic.time_zone_by_addr(self.gb_ip)
def testCacheMethods(self):
mem_record = self.gic_mem.record_by_addr(self.us_ip)
mmap_record = self.gic_mmap.record_by_addr(self.us_ip)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
self.assertEquals(gb_time_zone, 'Europe/London')
def testTimeZoneByName(self):
us_time_zone = self.gic.time_zone_by_name(self.us_hostname)
gb_time_zone = self.gic.time_zone_by_name(self.gb_hostname)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
self.assertEquals(gb_time_zone, 'Europe/London')
self.assertEqual(mem_record['city'], self.us_record_data['city'])
self.assertEqual(mmap_record['city'], self.us_record_data['city'])
def testRecordByAddr(self):
equal_keys = ('city', 'region_name', 'area_code', 'country_code3',
......
......@@ -2,7 +2,7 @@
import unittest
import pygeoip
from tests.config import COUNTRY_DB_PATH
from tests.config import COUNTRY_DB_PATH, COUNTRY_V6_DB_PATH
class TestGeoIPCountryFunctions(unittest.TestCase):
......@@ -13,38 +13,52 @@ class TestGeoIPCountryFunctions(unittest.TestCase):
self.us_ip = '64.233.161.99'
self.gb_ip = '212.58.253.68'
self.ie6_hostname = 'google.com'
self.ie6_ip = '2a00:1450:400f:800::1002'
self.ie_code = 'IE'
self.us_code = 'US'
self.gb_code = 'GB'
self.ie_name = 'Ireland'
self.us_name = 'United States'
self.gb_name = 'United Kingdom'
self.gi = pygeoip.GeoIP(COUNTRY_DB_PATH)
self.gi6 = pygeoip.GeoIP(COUNTRY_V6_DB_PATH)
def testCountryCodeByName(self):
us_code = self.gi.country_code_by_name(self.us_hostname)
gb_code = self.gi.country_code_by_name(self.gb_hostname)
ie6_code = self.gi6.country_code_by_name(self.ie6_hostname)
self.assertEqual(us_code, self.us_code)
self.assertEqual(gb_code, self.gb_code)
self.assertEqual(ie6_code, self.ie_code)
def testCountryCodeByAddr(self):
us_code = self.gi.country_code_by_name(self.us_ip)
gb_code = self.gi.country_code_by_name(self.gb_ip)
us_code = self.gi.country_code_by_addr(self.us_ip)
gb_code = self.gi.country_code_by_addr(self.gb_ip)
ie6_code = self.gi6.country_code_by_addr(self.ie6_ip)
self.assertEqual(us_code, self.us_code)
self.assertEqual(gb_code, self.gb_code)
self.assertEqual(ie6_code, self.ie_code)
def testCountryNameByName(self):
us_name = self.gi.country_name_by_name(self.us_hostname)
gb_name = self.gi.country_name_by_name(self.gb_hostname)
ie6_name = self.gi6.country_name_by_name(self.ie6_hostname)
self.assertEqual(us_name, self.us_name)
self.assertEqual(gb_name, self.gb_name)
self.assertEqual(ie6_name, self.ie_name)
def testCountryNameByAddr(self):
us_name = self.gi.country_name_by_addr(self.us_ip)
gb_name = self.gi.country_name_by_addr(self.gb_ip)
ie6_name = self.gi6.country_name_by_addr(self.ie6_ip)
self.assertEqual(us_name, self.us_name)
self.assertEqual(gb_name, self.gb_name)
self.assertEqual(ie6_name, self.ie_name)
# -*- coding: utf-8 -*-
import unittest
import pygeoip
from tests.config import ISP_DB_PATH
class TestGeOIPISPFunctions(unittest.TestCase):
def setUp(self):
self.us_isp = 'Turner Broadcasting System'
self.us_ip = '157.166.255.18'
self.us_hostname = 'cnn.com'
self.se_isp = 'IP-Only Tele Communication AB'
self.se_ip = '213.132.112.97'
self.se_hostname = 'blocket.se'
self.gi = pygeoip.GeoIP(ISP_DB_PATH)
def testISPByAddr(self):
se_isp = self.gi.org_by_addr(self.se_ip)
us_isp = self.gi.org_by_addr(self.us_ip)
self.assertEqual(se_isp, self.se_isp)
self.assertEqual(us_isp, self.us_isp)
def testISPByName(self):
se_isp = self.gi.org_by_name(self.se_hostname)
us_isp = self.gi.org_by_name(self.us_hostname)
self.assertEqual(se_isp, self.se_isp)
self.assertEqual(us_isp, self.us_isp)
......@@ -7,9 +7,9 @@ from tests.config import ORG_DB_PATH
class TestGeoIPOrgFunctions(unittest.TestCase):
def setUp(self):
self.us_org = 'Google'
self.us_ip = '64.233.161.99'
self.us_hostname = 'google.com'
self.us_org = 'APPLE COMPUTER'
self.us_ip = '17.172.224.47'
self.us_hostname = 'apple.com'
self.gb_org = 'BBC'
self.gb_ip = '212.58.253.68'
......@@ -30,6 +30,3 @@ class TestGeoIPOrgFunctions(unittest.TestCase):
self.assertEqual(gb_org, self.gb_org)
self.assertEqual(us_org, self.us_org)
......@@ -8,10 +8,9 @@ from tests.config import REGION_DB_PATH
class TestGeoIPRegionFunctions(unittest.TestCase):
def setUp(self):
self.us_code = 'US'
self.yahoo_hostname = 'yahoo.com'
self.yahoo_ip = '209.131.36.159'
self.yahoo_region_data = {
self.us_hostname = 'apple.com'
self.us_ip = '17.172.224.47'
self.us_region_data = {
'region_name': 'CA',
'country_code': 'US'
}
......@@ -19,17 +18,17 @@ class TestGeoIPRegionFunctions(unittest.TestCase):
self.gir = pygeoip.GeoIP(REGION_DB_PATH)
def testRegionByName(self):
region_name = self.gir.region_by_name(self.yahoo_hostname)
self.assertEqual(region_name, self.yahoo_region_data)
region_name = self.gir.region_by_name(self.us_hostname)
self.assertEqual(region_name, self.us_region_data)
def testRegionByAddr(self):
region_name = self.gir.region_by_addr(self.yahoo_ip)
self.assertEqual(region_name, self.yahoo_region_data)
region_name = self.gir.region_by_addr(self.us_ip)
self.assertEqual(region_name, self.us_region_data)
def testCountryCodeByName(self):
us_code = self.gir.country_code_by_name(self.yahoo_hostname)
us_code = self.gir.country_code_by_name(self.us_hostname)
self.assertEqual(us_code, self.us_code)
def testCountryCodeByAddr(self):
us_code = self.gir.country_code_by_addr(self.yahoo_ip)
us_code = self.gir.country_code_by_addr(self.us_ip)
self.assertEqual(us_code, self.us_code)
# -*- coding: utf-8 -*-
import unittest
import threading
import pygeoip
from tests.config import COUNTRY_DB_PATH
class TestGeoIPThreading(unittest.TestCase):
def setUp(self):
self.us_ip = '64.233.161.99'
self.gb_ip = '212.58.253.68'
self.us_code = 'US'
self.gb_code = 'GB'
self.gi = pygeoip.GeoIP(COUNTRY_DB_PATH)
def testCountryDatabase(self):
us_thread = TestThread('us', self.gi, self.us_ip, self.us_code, self.assertEqual)
gb_thread = TestThread('gb', self.gi, self.us_ip, self.us_code, self.assertEqual)
us_thread.start()
gb_thread.start()
us_thread.join()
gb_thread.join()
class TestThread(threading.Thread):
def __init__(self, name, gi, ip, code, assertEqual):
threading.Thread.__init__(self, name=name)
self.ip = ip
self.gi = gi
self.code = code
self.assertEqual = assertEqual
def run(self):
for i in range(1000):
code = self.gi.country_code_by_addr(self.ip)
self.assertEqual(code, self.code)
......@@ -17,14 +17,14 @@ class TestGeoIPTimeZoneFunctions(unittest.TestCase):
def testTimeZoneByAddr(self):
us_time_zone = self.gic.time_zone_by_addr(self.us_ip)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
gb_time_zone = self.gic.time_zone_by_addr(self.gb_ip)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
self.assertEquals(gb_time_zone, 'Europe/London')
def testTimeZoneByName(self):
us_time_zone = self.gic.time_zone_by_name(self.us_hostname)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
gb_time_zone = self.gic.time_zone_by_name(self.gb_hostname)
self.assertEquals(us_time_zone, 'America/Los_Angeles')
self.assertEquals(gb_time_zone, 'Europe/London')
# -*- coding: utf-8 -*-
import unittest
import pygeoip
from pygeoip.const import PY2, PY3
from tests.config import CITY_DB_PATH
class TestGeoIPCacheMethods(unittest.TestCase):
def setUp(self):
self.de_hostname = 'www.osnabrueck.de'
self.de_city = 'Osnabr\xfcck'.decode('latin1') if PY2 else 'Osnabrück'
self.gic = pygeoip.GeoIP(CITY_DB_PATH)
def testUnicodeCity(self):
record = self.gic.record_by_name(self.de_hostname)
self.assertEqual(type(record['city']), unicode if PY2 else str)
self.assertEqual(record['city'], self.de_city)
[tox]
envlist = py25,py26,py27,py31,py32
envlist = py25,py26,py27,py31,py32,py33
[testenv]
deps = nose
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment