Commit 91d3634a by William Tisäter

Remove dependency on six. Closes pull #11.

Thanks to jimbo1023 for the pull request. Due recent refactor jobs I had
to rewrite these lines and did therefor not merge the pull.
parent b7ac752f
Bootstrap manual for developers of pygeoip
Dependencies: tox, nose, epydoc, six
Dependencies: tox, nose, epydoc
For testing we are using tox virtualenv-based Python version testing
and nose as test framwork.
......
pygeoip pygeoip-module.html
pygeoip.MMAP_CACHE pygeoip-module.html#MMAP_CACHE
pygeoip.STANDARD pygeoip-module.html#STANDARD
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.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 +17,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 +26,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 +34,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 +44,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 +52,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 +63,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 Fri Sep 28 22:42:00 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 Fri Sep 28 22:42:00 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -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,13 +144,6 @@
<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>
<tr>
<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>
<td width="33%" 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>
......@@ -196,13 +197,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 +272,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 +290,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 +391,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 +459,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 Fri Sep 28 22:42:00 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -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 Fri Sep 28 22:42:00 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -73,9 +73,12 @@
pygeoip.MEMORY_CACHE)</code></p>
<hr />
<div class="fields"> <p><strong>Author:</strong>
Jennifer Ennis &lt;zaylea at gmail dot com&gt;
</p>
<div class="fields"> <dl><dt>Authors:</dt>
<dd>
Jennifer Ennis &lt;zaylea at gmail dot com&gt;,
William Tis&#228;ter &lt;william@defunct.cc&gt;
</dd>
</dl>
<p><strong>License:</strong>
Copyright(C) 2004 MaxMind LLC
<p>This program is free software: you can redistribute it and/or
......@@ -239,7 +242,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 Fri Sep 28 22:42:00 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,12 @@ 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
<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>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 +546,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 * 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 +613,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 +644,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 +670,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 +679,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 +753,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 +807,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 +829,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 +861,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 +891,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 +917,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 +949,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 +973,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 +1027,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 +1066,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 Fri Sep 28 22:42:00 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 Fri Sep 28 22:42:00 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 Fri Sep 28 22:42:00 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 Fri Sep 28 22:42:00 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -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>
......@@ -282,14 +296,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>
......@@ -310,6 +324,34 @@
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<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>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">&nbsp;</span>
</td><td class="summary">
<a name="SEGMENT_RECORD_LENGTH"></a><span class="summary-name">SEGMENT_RECORD_LENGTH</span> = <code title="3">3</code>
</td>
</tr>
......@@ -380,7 +422,7 @@
<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="__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 +580,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 Fri Sep 28 22:42:00 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.
......@@ -212,7 +212,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 Fri Sep 28 22:42:00 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -760,22 +760,23 @@
<a name="L697"></a><tt class="py-lineno">697</tt> <tt class="py-line"><tt id="link-694" class="py-name"><a title="pygeoip.timezone._country" class="py-name" href="#" onclick="return doclink('link-694', '_country', 'link-0');">_country</a></tt><tt class="py-op">[</tt><tt class="py-string">"ZM"</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-string">"Africa/Lusaka"</tt> </tt>
<a name="L698"></a><tt class="py-lineno">698</tt> <tt class="py-line"><tt id="link-695" class="py-name"><a title="pygeoip.timezone._country" class="py-name" href="#" onclick="return doclink('link-695', '_country', 'link-0');">_country</a></tt><tt class="py-op">[</tt><tt class="py-string">"ZW"</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-string">"Africa/Harare"</tt> </tt>
<a name="L699"></a><tt class="py-lineno">699</tt> <tt class="py-line"> </tt>
<a name="time_zone_by_country_and_region"></a><div id="time_zone_by_country_and_region-def"><a name="L700"></a><tt class="py-lineno">700</tt> <a class="py-toggle" href="#" id="time_zone_by_country_and_region-toggle" onclick="return toggle('time_zone_by_country_and_region');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pygeoip.timezone-module.html#time_zone_by_country_and_region">time_zone_by_country_and_region</a><tt class="py-op">(</tt><tt class="py-param">country_code</tt><tt class="py-op">,</tt> <tt class="py-param">region_name</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="time_zone_by_country_and_region-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="time_zone_by_country_and_region-expanded"><a name="L701"></a><tt class="py-lineno">701</tt> <tt class="py-line"> </tt>
<a name="L702"></a><tt class="py-lineno">702</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">country_code</tt> <tt class="py-keyword">not</tt> <tt class="py-keyword">in</tt> <tt id="link-696" class="py-name"><a title="pygeoip.timezone._country" class="py-name" href="#" onclick="return doclink('link-696', '_country', 'link-0');">_country</a></tt><tt class="py-op">:</tt> </tt>
<a name="L703"></a><tt class="py-lineno">703</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">None</tt> </tt>
<a name="L700"></a><tt class="py-lineno">700</tt> <tt class="py-line"> </tt>
<a name="time_zone_by_country_and_region"></a><div id="time_zone_by_country_and_region-def"><a name="L701"></a><tt class="py-lineno">701</tt> <a class="py-toggle" href="#" id="time_zone_by_country_and_region-toggle" onclick="return toggle('time_zone_by_country_and_region');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="pygeoip.timezone-module.html#time_zone_by_country_and_region">time_zone_by_country_and_region</a><tt class="py-op">(</tt><tt class="py-param">country_code</tt><tt class="py-op">,</tt> <tt class="py-param">region_name</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="time_zone_by_country_and_region-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="time_zone_by_country_and_region-expanded"><a name="L702"></a><tt class="py-lineno">702</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">country_code</tt> <tt class="py-keyword">not</tt> <tt class="py-keyword">in</tt> <tt id="link-696" class="py-name"><a title="pygeoip.timezone._country" class="py-name" href="#" onclick="return doclink('link-696', '_country', 'link-0');">_country</a></tt><tt class="py-op">:</tt> </tt>
<a name="L703"></a><tt class="py-lineno">703</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-string">''</tt> </tt>
<a name="L704"></a><tt class="py-lineno">704</tt> <tt class="py-line"> </tt>
<a name="L705"></a><tt class="py-lineno">705</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">region_name</tt> <tt class="py-keyword">or</tt> <tt class="py-name">region_name</tt> <tt class="py-op">==</tt> <tt class="py-string">'00'</tt><tt class="py-op">:</tt> </tt>
<a name="L706"></a><tt class="py-lineno">706</tt> <tt class="py-line"> <tt class="py-name">region_name</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L707"></a><tt class="py-lineno">707</tt> <tt class="py-line"> </tt>
<a name="L708"></a><tt class="py-lineno">708</tt> <tt class="py-line"> <tt class="py-name">timezones</tt> <tt class="py-op">=</tt> <tt id="link-697" class="py-name"><a title="pygeoip.timezone._country" class="py-name" href="#" onclick="return doclink('link-697', '_country', 'link-0');">_country</a></tt><tt class="py-op">[</tt><tt class="py-name">country_code</tt><tt class="py-op">]</tt> </tt>
<a name="L709"></a><tt class="py-lineno">709</tt> <tt class="py-line"> </tt>
<a name="L710"></a><tt class="py-lineno">710</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">timezones</tt><tt class="py-op">,</tt> <tt class="py-name">str</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L711"></a><tt class="py-lineno">711</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">timezones</tt> </tt>
<a name="L712"></a><tt class="py-lineno">712</tt> <tt class="py-line"> </tt>
<a name="L713"></a><tt class="py-lineno">713</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">region_name</tt><tt class="py-op">:</tt> </tt>
<a name="L714"></a><tt class="py-lineno">714</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">timezones</tt><tt class="py-op">.</tt><tt class="py-name">get</tt><tt class="py-op">(</tt><tt class="py-name">region_name</tt><tt class="py-op">)</tt> </tt>
</div><a name="L715"></a><tt class="py-lineno">715</tt> <tt class="py-line"> </tt><script type="text/javascript">
<a name="L709"></a><tt class="py-lineno">709</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">timezones</tt><tt class="py-op">,</tt> <tt class="py-name">str</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L710"></a><tt class="py-lineno">710</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">timezones</tt> </tt>
<a name="L711"></a><tt class="py-lineno">711</tt> <tt class="py-line"> </tt>
<a name="L712"></a><tt class="py-lineno">712</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">region_name</tt><tt class="py-op">:</tt> </tt>
<a name="L713"></a><tt class="py-lineno">713</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-string">''</tt> </tt>
<a name="L714"></a><tt class="py-lineno">714</tt> <tt class="py-line"> </tt>
<a name="L715"></a><tt class="py-lineno">715</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">timezones</tt><tt class="py-op">.</tt><tt class="py-name">get</tt><tt class="py-op">(</tt><tt class="py-name">region_name</tt><tt class="py-op">)</tt> </tt>
</div><a name="L716"></a><tt class="py-lineno">716</tt> <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
......@@ -813,7 +814,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:05 2012
Generated by Epydoc 3.0.1 on Fri Sep 28 22:42:00 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -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 Fri Sep 28 22:42:00 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -61,48 +61,79 @@
</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="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="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="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">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-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="L55"></a><tt class="py-lineno">55</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L56"></a><tt class="py-lineno">56</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="L57"></a><tt class="py-lineno">57</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">ip_long</tt> </tt>
</div><a name="L58"></a><tt class="py-lineno">58</tt> <tt class="py-line"> </tt>
<a name="L59"></a><tt class="py-lineno">59</tt> <tt class="py-line"> </tt>
<a name="ip2long_v6"></a><div id="ip2long_v6-def"><a name="L60"></a><tt class="py-lineno">60</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="L61"></a><tt class="py-lineno">61</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L62"></a><tt class="py-lineno">62</tt> <tt class="py-line"><tt class="py-docstring"> Convert a IPv6 address into long.</tt> </tt>
<a name="L63"></a><tt class="py-lineno">63</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L64"></a><tt class="py-lineno">64</tt> <tt class="py-line"><tt class="py-docstring"> @param ip: IPv6 address</tt> </tt>
<a name="L65"></a><tt class="py-lineno">65</tt> <tt class="py-line"><tt class="py-docstring"> @type ip: str</tt> </tt>
<a name="L66"></a><tt class="py-lineno">66</tt> <tt class="py-line"><tt class="py-docstring"> @return: network byte order long</tt> </tt>
<a name="L67"></a><tt class="py-lineno">67</tt> <tt class="py-line"><tt class="py-docstring"> @rtype: long</tt> </tt>
<a name="L68"></a><tt class="py-lineno">68</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L69"></a><tt class="py-lineno">69</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="L70"></a><tt class="py-lineno">70</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="L71"></a><tt class="py-lineno">71</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="L72"></a><tt class="py-lineno">72</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="L73"></a><tt class="py-lineno">73</tt> <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
......@@ -140,7 +171,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 Fri Sep 28 22:42:00 2012
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
......
......@@ -20,14 +20,17 @@
>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>
>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#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"
......@@ -41,7 +44,8 @@
>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 +54,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"
......
......@@ -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"
......@@ -29,7 +30,8 @@
>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 +40,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"
......
......@@ -31,7 +31,6 @@ 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
......@@ -45,6 +44,7 @@ except ImportError:
import pygeoip.const
from pygeoip import util
from pygeoip.const import PY2, PY3
from pygeoip.timezone import time_zone_by_country_and_region
......@@ -128,14 +128,14 @@ class GeoIP(GeoIPBase):
Supported databases:
COUNTRY_EDITION
REGION_EDITION_REV0
REGION_EDITION_REV1
CITY_EDITION_REV0
CITY_EDITION_REV1
ORG_EDITION
ISP_EDITION
ASNUM_EDITION
* COUNTRY_EDITION
* REGION_EDITION_REV0
* REGION_EDITION_REV1
* CITY_EDITION_REV0
* CITY_EDITION_REV1
* ORG_EDITION
* ISP_EDITION
* ASNUM_EDITION
"""
self._databaseType = const.COUNTRY_EDITION
......@@ -146,7 +146,10 @@ class GeoIP(GeoIPBase):
self._filehandle.seek(-3, os.SEEK_END)
for i in range(const.STRUCTURE_INFO_MAX_SIZE):
if self._filehandle.read(3) == six.u(chr(255) * 3):
chars = chr(255) * 3
encoding = 'unicode_escape'
delim = self._filehandle.read(3)
if (delim == chars) if PY3 else (delim == unicode(chars, encoding)):
self._databaseType = ord(self._filehandle.read(1))
# Backwards compatibility with databases from
......
......@@ -21,6 +21,11 @@ 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
......
......@@ -20,11 +20,12 @@ 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 struct
import socket
from array import array
from pygeoip.const import PY3
def ip2long(ip):
"""
......@@ -48,7 +49,7 @@ def ip2long_v4(ip):
@rtype: int
"""
ip_array = ip.split('.')
if six.PY3:
if 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:
......
......@@ -43,6 +43,5 @@ setup(name='pygeoip',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2'],
packages=['pygeoip'],
install_requires=['six'],
license='LGPLv3+',
keywords='geoip')
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