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

Side by Side Diff: pygeoip/util.py

Issue 29934561: #1537 - Remove stats processing from sitescripts (Closed) Base URL: https://hg.adblockplus.org/sitescripts
Patch Set: Created Nov. 2, 2018, 12:42 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
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/__init__.py » ('j') | tox.ini » ('J')

Powered by Google App Engine
This is Rietveld