<commit_before>import random
import struct


class AddressGenerator(object):
    def __init__(self, subnet):
        if isinstance(subnet, basestring):
            subnet = parseIPv6(subnet)
        network, mask = subnet
        if mask > 64:
            raise RuntimeError("Subnet mask of %d bits is too high; "
                    "need 64 or less." % mask)
        elif mask < 0:
            raise RuntimeError("Invalid subnet mask %d" % mask)

        # Make sure the hostpart of the address is zeroed
        self.network = network & ~((1 << (128 - mask)) - 1)
        self.mask = mask

    def generate(self):
        mac = self.generateMAC()
        ipv6 = self.network | self.mac48ToEUI64(mac)
        return formatMAC(mac), formatIPv6(ipv6, self.mask)

    @staticmethod<commit_msg>Add subnet generator<commit_after>import random
import struct


class AddressGenerator(object):
    def __init__(self, subnet):
        if isinstance(subnet, basestring):
            subnet = parseIPv6(subnet)
        network, mask = subnet
        if mask > 64:
            raise RuntimeError("Subnet mask of %d bits is too high; "
                    "need 64 or less." % mask)
        elif mask < 0:
            raise RuntimeError("Invalid subnet mask %d" % mask)

        # Make sure the hostpart of the address is zeroed
        self.network = network & ~((1 << (128 - mask)) - 1)
        self.mask = mask

    def generateHost(self):
        """
        Generate a random MAC-48/IPv6 address pair from the selected
        subnet.
        """
        mac = self.generateMAC()
        ipv6 = self.network | self.mac48ToEUI64(mac)
        return formatMAC(mac), formatIPv6(ipv6, self.mask)

    @staticmethod
    def generateSubnet():
        """
        Generate a random 48-bit network prefix in the RFC 4193
        (Unique Local Address) space.
        """
        address = 0xFD << 120
        address |= random.getrandbits(40) << 80
        return address, 48

    @staticmethod
{'fraction_non_alphanumeric': 0.09494949494949495, 'fraction_numerical': 0.027777777777777776, 'mean_word_length': 2.0476923076923077, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4975553', 'n_tokens_mistral': 605, 'n_tokens_neox': 559, 'n_words': 181}