Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: pygeoip/util.py

Issue 11577044: Switch to pygeoip for log processing to allow running it via PyPy (Closed)
Patch Set: Created Aug. 29, 2013, 7:38 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pygeoip/timezone.py ('k') | sitescripts/stats/bin/logprocessor.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # -*- coding: utf-8 -*-
2 """
3 Utility functions. Part of the pygeoip package.
4
5 @author: Jennifer Ennis <zaylea@gmail.com>
6
7 @license: Copyright(C) 2004 MaxMind LLC
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
21 """
22
23 import socket
24 import binascii
25
26
27 def ip2long(ip):
28 """
29 Wrapper function for IPv4 and IPv6 converters
30 @param ip: IPv4 or IPv6 address
31 @type ip: str
32 """
33 try:
34 return int(binascii.hexlify(socket.inet_aton(ip)), 16)
35 except socket.error:
36 return int(binascii.hexlify(socket.inet_pton(socket.AF_INET6, ip)), 16)
OLDNEW
« no previous file with comments | « pygeoip/timezone.py ('k') | sitescripts/stats/bin/logprocessor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld