<commit_before>
"""Helper objects for maintaining PLM state and interfaces."""
import logging
import binascii

__all__ = ('Address')

class Address(object):
    """Datatype definition for INSTEON device address handling."""

    def __init__(self, addr):
        """Create an Address object."""
        self.log = logging.getLogger(__name__)
        self.addr = self.normalize(addr)

    def __repr__(self):
        return self.hex

    def __str__(self):
        return self.hex

    def __eq__(self, other):
        if hasattr(other, 'addr'):
            return self.addr == other.addr
        else:
            return False

    def __ne__(self, other):
        if hasattr(other, 'addr'):
            return self.addr != other.addr
        else:
            return true

    def __lt__(self, other):
        if isinstance(other, Address):
            return str(self) < str(other)
        else:
            return TypeError

    def __gt__(self, other):
        if isinstance(other, Address):
            return str(self) > str(other)
        else:
            return TypeError

    def __hash__(self):
        return hash(self.hex)

    def matches_pattern(self, other):
        if hasattr(other, 'addr'):
            if self.addr == None or other.addr == None:
                return True
            else:
                return self.addr == other.addr
        else:
            return False

    def normalize(self, addr):
        """Take any format of address and turn it into a hex string."""
        if isinstance(addr, Address):
            return addr.addr

        if isinstance(addr, bytearray):
            return binascii.unhexlify(binascii.hexlify(addr).decode())

        if isinstance(addr, bytes):
            return addr

        if isinstance(addr, str):
            addr.replace('.', '')
            addr = addr[0:6]
            return binascii.unhexlify(addr.lower())

        if addr is None:
            return None

        else:
            self.log.warning('Address class init with unknown type %s: %r',
                             type(addr), addr)
            return None

    @property
    def human(self):
        """Emit the address in human-readible format (AA.BB.CC)."""
        if self.addr is not None:
            addrstr = self.hex[0:2]+'.'+self.hex[2:4]+'.'+self.hex[4:6]
            return addrstr.upper()
        return '00.00.00'

    @property
    def hex(self):
        """Emit the address in bare hex format (aabbcc)."""
        if self.addr is not None:
            return binascii.hexlify(self.addr).decode()
        else:
            return '000000'

    @property
    def bytes(self):<commit_msg>Fix addr normalization - Actually remove the dots.<commit_after>
"""Helper objects for maintaining PLM state and interfaces."""
import logging
import binascii

__all__ = ('Address')

class Address(object):
    """Datatype definition for INSTEON device address handling."""

    def __init__(self, addr):
        """Create an Address object."""
        self.log = logging.getLogger(__name__)
        self.addr = self.normalize(addr)

    def __repr__(self):
        return self.hex

    def __str__(self):
        return self.hex

    def __eq__(self, other):
        if hasattr(other, 'addr'):
            return self.addr == other.addr
        else:
            return False

    def __ne__(self, other):
        if hasattr(other, 'addr'):
            return self.addr != other.addr
        else:
            return true

    def __lt__(self, other):
        if isinstance(other, Address):
            return str(self) < str(other)
        else:
            return TypeError

    def __gt__(self, other):
        if isinstance(other, Address):
            return str(self) > str(other)
        else:
            return TypeError

    def __hash__(self):
        return hash(self.hex)

    def matches_pattern(self, other):
        if hasattr(other, 'addr'):
            if self.addr == None or other.addr == None:
                return True
            else:
                return self.addr == other.addr
        else:
            return False

    def normalize(self, addr):
        """Take any format of address and turn it into a hex string."""
        if isinstance(addr, Address):
            return addr.addr

        if isinstance(addr, bytearray):
            return binascii.unhexlify(binascii.hexlify(addr).decode())

        if isinstance(addr, bytes):
            return addr

        if isinstance(addr, str):
            addr = addr.replace('.', '')
            addr = addr[0:6]
            return binascii.unhexlify(addr.lower())

        if addr is None:
            return None

        else:
            self.log.warning('Address class init with unknown type %s: %r',
                             type(addr), addr)
            return None

    @property
    def human(self):
        """Emit the address in human-readible format (AA.BB.CC)."""
        if self.addr is not None:
            addrstr = self.hex[0:2]+'.'+self.hex[2:4]+'.'+self.hex[4:6]
            return addrstr.upper()
        return '00.00.00'

    @property
    def hex(self):
        """Emit the address in bare hex format (aabbcc)."""
        if self.addr is not None:
            return binascii.hexlify(self.addr).decode()
        else:
            return '000000'

    @property
    def bytes(self):
{'fraction_non_alphanumeric': 0.10880149812734083, 'fraction_numerical': 0.00749063670411985, 'mean_word_length': 1.8051470588235294, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3703229', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1435, 'n_words': 442}