File: compat.py

package info (click to toggle)
python-geoip2 2.4.2%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 620 kB
  • ctags: 181
  • sloc: python: 1,074; makefile: 5
file content (17 lines) | stat: -rw-r--r-- 456 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Intended for internal use only."""
import sys

import ipaddress

# pylint: skip-file

if sys.version_info[0] == 2:
    def compat_ip_address(address):
        """Intended for internal use only."""
        if isinstance(address, bytes):
            address = address.decode()
        return ipaddress.ip_address(address)
else:
    def compat_ip_address(address):
        """Intended for internal use only."""
        return ipaddress.ip_address(address)