File: compat.py

package info (click to toggle)
python-geoip2 2.9.0%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 572 kB
  • sloc: python: 1,224; makefile: 5
file content (19 lines) | stat: -rw-r--r-- 458 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""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)