Python socket.AddressType() Examples

The following are code examples for showing how to use socket.AddressType(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: OSPTF   Author: xSploited   File: _common.py    (license) View Source Project 5 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    else:  # pragma: no cover
        try:
            return socket.AddressType(num)
        except (ValueError, AttributeError):
            return num 
Example 2
Project: OSPTF   Author: xSploited   File: _common.py    (license) View Source Project 5 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    else:  # pragma: no cover
        try:
            return socket.AddressType(num)
        except (ValueError, AttributeError):
            return num 
Example 3
Project: pupy   Author: ru-faraon   File: _common.py    (license) View Source Project 5 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    else:  # pragma: no cover
        try:
            return socket.AddressType(num)
        except (ValueError, AttributeError):
            return num 
Example 4
Project: pupy   Author: ru-faraon   File: _common.py    (license) View Source Project 5 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    else:  # pragma: no cover
        try:
            return socket.AddressType(num)
        except (ValueError, AttributeError):
            return num 
Example 5
Project: respeaker_virtualenv   Author: respeaker   File: _common.py    (license) View Source Project 5 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    else:  # pragma: no cover
        try:
            return socket.AddressType(num)
        except (ValueError, AttributeError):
            return num 
Example 6
Project: pipenv   Author: pypa   File: _common.py    (license) View Source Project 5 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    else:  # pragma: no cover
        try:
            return socket.AddressType(num)
        except (ValueError, AttributeError):
            return num 
Example 7
Project: zenchmarks   Author: squeaky-pl   File: _common.py    (license) View Source Project 5 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    else:  # pragma: no cover
        try:
            return socket.AddressType(num)
        except (ValueError, AttributeError):
            return num 
Example 8
Project: FancyWord   Author: EastonLee   File: _common.py    (license) View Source Project 5 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    else:  # pragma: no cover
        try:
            return socket.AddressType(num)
        except (ValueError, AttributeError):
            return num 
Example 9
Project: ropi   Author: ThumbGen   File: _common.py    (license) View Source Project 4 votes vote down vote up
def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    try:
        return socket.AddressType(num)
    except (ValueError, AttributeError):
        return num


# --- Process.connections() 'kind' parameter mapping