# Path: beacontools/const.py
# class ScannerMode(IntEnum):
#     """Used to determine which packets should be parsed by the scanner."""
#     MODE_NONE = 0
#     MODE_IBEACON = 1
#     MODE_EDDYSTONE = 2
#     MODE_ESTIMOTE = 4
#     MODE_CJMONITOR = 8
#     MODE_EXPOSURE_NOTIFICATION = 16
#     MODE_ALL = MODE_IBEACON | MODE_EDDYSTONE | MODE_ESTIMOTE | MODE_CJMONITOR  | MODE_EXPOSURE_NOTIFICATION


from binascii import hexlify
from re import compile as compile_regex
from .const import ScannerMode
    from .packet_types import EddystoneUIDFrame, EddystoneURLFrame, \
                              EddystoneEncryptedTLMFrame, EddystoneTLMFrame, \
                              EddystoneEIDFrame, IBeaconAdvertisement, \
                              EstimoteTelemetryFrameA, EstimoteTelemetryFrameB, \
                              ExposureNotificationFrame
    from .device_filters import IBeaconFilter, EddystoneFilter, BtAddrFilter, EstimoteFilter, \
                                CJMonitorFilter, ExposureNotificationFilter  # pylint: disable=import-outside-toplevel
import array
import struct
                    ExposureNotificationFrame])


def to_int(string):
    """Convert a one element byte string to int for python 2 support."""
    if isinstance(string, str):
        return ord(string[0])
    else:
        return string


def bin_to_int(string):
    """Convert a one element byte string to signed int for python 2 support."""
    if isinstance(string, str):
        return struct.unpack("b", string)[0]
    else:
        return struct.unpack("b", bytes([string]))[0]


def get_mode(device_filter):
    """Determine which beacons the scanner should look for."""

    if device_filter is None or len(device_filter) == 0:
        return ScannerMode.MODE_ALL

    mode = ScannerMode.MODE_NONE
    for filtr in device_filter:
        if isinstance(filtr, IBeaconFilter):
            mode |= ScannerMode.MODE_IBEACON
        elif isinstance(filtr, EddystoneFilter):

# Path: beacontools/const.py
# class ScannerMode(IntEnum):
#     """Used to determine which packets should be parsed by the scanner."""
#     MODE_NONE = 0
#     MODE_IBEACON = 1
#     MODE_EDDYSTONE = 2
#     MODE_ESTIMOTE = 4
#     MODE_CJMONITOR = 8
#     MODE_EXPOSURE_NOTIFICATION = 16
#     MODE_ALL = MODE_IBEACON | MODE_EDDYSTONE | MODE_ESTIMOTE | MODE_CJMONITOR  | MODE_EXPOSURE_NOTIFICATION


# Path: beacontools/utils.py
from binascii import hexlify
from re import compile as compile_regex
from .const import ScannerMode
    from .packet_types import EddystoneUIDFrame, EddystoneURLFrame, \
                              EddystoneEncryptedTLMFrame, EddystoneTLMFrame, \
                              EddystoneEIDFrame, IBeaconAdvertisement, \
                              EstimoteTelemetryFrameA, EstimoteTelemetryFrameB, \
                              ExposureNotificationFrame
    from .device_filters import IBeaconFilter, EddystoneFilter, BtAddrFilter, EstimoteFilter, \
                                CJMonitorFilter, ExposureNotificationFilter  # pylint: disable=import-outside-toplevel
import array
import struct

                    ExposureNotificationFrame])


def to_int(string):
    """Convert a one element byte string to int for python 2 support."""
    if isinstance(string, str):
        return ord(string[0])
    else:
        return string


def bin_to_int(string):
    """Convert a one element byte string to signed int for python 2 support."""
    if isinstance(string, str):
        return struct.unpack("b", string)[0]
    else:
        return struct.unpack("b", bytes([string]))[0]


def get_mode(device_filter):
    """Determine which beacons the scanner should look for."""

    if device_filter is None or len(device_filter) == 0:
        return ScannerMode.MODE_ALL

    mode = ScannerMode.MODE_NONE
    for filtr in device_filter:
        if isinstance(filtr, IBeaconFilter):
            mode |= ScannerMode.MODE_IBEACON
        elif isinstance(filtr, EddystoneFilter):

            mode |= ScannerMode.MODE_EDDYSTONE