# Path: beacontools/const.py
# CJ_MANUFACTURER_ID = b"\x72\x04"
# 
# CJ_TEMPHUM_TYPE = 0x10fe
# 
# Path: beacontools/utils.py
# def is_valid_mac(mac):
#     """"Returns True if the given argument matches RE_MAC_ADDR, otherwise False"""
#     return RE_MAC_ADDR.match(mac) is not None


from .const import CJ_MANUFACTURER_ID, CJ_TEMPHUM_TYPE
from .utils import is_valid_mac
class DeviceFilter(object):
    """Base class for all device filters. Should not be used by itself."""

    def __init__(self):
        """Initialize filter."""
        self.properties = {}

    def matches(self, filter_props):
        """Check if the filter matches the supplied properties."""
        if filter_props is None:
            return False

        found_one = False
        for key, value in filter_props.items():
            if key in self.properties and value != self.properties[key]:
                return False
            elif key in self.properties and value == self.properties[key]:
                found_one = True

        return found_one

    def __repr__(self):
        return "{}({})".format(
            self.__class__.__name__,
            ", ".join(["=".join((k, str(v),)) for k, v in self.properties.items()]))


class CJMonitorFilter(DeviceFilter):
    """Filter for CJ Monitor."""


# Path: beacontools/const.py
# CJ_MANUFACTURER_ID = b"\x72\x04"
# 
# CJ_TEMPHUM_TYPE = 0x10fe
# 
# Path: beacontools/utils.py
# def is_valid_mac(mac):
#     """"Returns True if the given argument matches RE_MAC_ADDR, otherwise False"""
#     return RE_MAC_ADDR.match(mac) is not None


# Path: beacontools/device_filters.py
from .const import CJ_MANUFACTURER_ID, CJ_TEMPHUM_TYPE
from .utils import is_valid_mac

class DeviceFilter(object):
    """Base class for all device filters. Should not be used by itself."""

    def __init__(self):
        """Initialize filter."""
        self.properties = {}

    def matches(self, filter_props):
        """Check if the filter matches the supplied properties."""
        if filter_props is None:
            return False

        found_one = False
        for key, value in filter_props.items():
            if key in self.properties and value != self.properties[key]:
                return False
            elif key in self.properties and value == self.properties[key]:
                found_one = True

        return found_one

    def __repr__(self):
        return "{}({})".format(
            self.__class__.__name__,
            ", ".join(["=".join((k, str(v),)) for k, v in self.properties.items()]))


class CJMonitorFilter(DeviceFilter):
    """Filter for CJ Monitor."""


    def __init__(self, company_id=CJ_MANUFACTURER_ID, beacon_type=CJ_TEMPHUM_TYPE):