<commit_before>import re

class NetworkInterface(object):
    def __init__(self, name='eth0'):
        self.name = name
        self.ip = None

    def __repr__(self):
        return 'NetworkInterface(name=%r, ip=%r)' % (self.name, self.ip)


def parse_ifconfig_output(output, only_active_interfaces=True):
    """
    Parse the output of an `ifconfig` command and return a list of
    NetworkInterface objects.
    """
    interfaces = []
    current_interface = None

    for l in output.split('\n'):
        if l:
            # At any line starting with eth0, lo, tap7, etc..
            # Start a new interface.
            if not l[0].isspace():
                current_interface = NetworkInterface(l.split()[0].rstrip(':'))
                interfaces.append(current_interface)
                l = ' '.join(l.split()[1:])

            if current_interface:
                # If this line contains 'inet'
                for inet_addr in re.findall(r'inet (addr:)?(([0-9]*\.){3}[0-9]*)', l):
                    current_interface.ip = inet_addr[1]

    # Return only the interfaces that have an IP address.
    if only_active_interfaces:
        return filter(lambda i: i.ip, interfaces)
    else:
        return interfaces
<commit_msg>forgot to commit ifconfig changes.<commit_after>import re

class NetworkInterface(object):
    def __init__(self, name='eth0'):
        self.name = name
        self.ip = None

    def __repr__(self):
        return 'NetworkInterface(name=%r, ip=%r)' % (self.name, self.ip)


class IfConfig(object):
    def __init__(self):
        self.interfaces = []

    def __repr__(self):
        return 'IfConfig(interfaces=%r)' % self.interfaces


def parse_ifconfig_output(output, only_active_interfaces=True):
    """
    Parse the output of an `ifconfig` command and return a list of
    NetworkInterface objects.
    """
    ifconfig = IfConfig()
    current_interface = None

    for l in output.split('\n'):
        if l:
            # At any line starting with eth0, lo, tap7, etc..
            # Start a new interface.
            if not l[0].isspace():
                current_interface = NetworkInterface(l.split()[0].rstrip(':'))
                ifconfig.interfaces.append(current_interface)
                l = ' '.join(l.split()[1:])

            if current_interface:
                # If this line contains 'inet'
                for inet_addr in re.findall(r'inet (addr:)?(([0-9]*\.){3}[0-9]*)', l):
                    current_interface.ip = inet_addr[1]

    # Return only the interfaces that have an IP address.
    if only_active_interfaces:
        ifconfig.interfaces = filter(lambda i: i.ip, ifconfig.interfaces)

    return ifconfig

{'fraction_non_alphanumeric': 0.11941964285714286, 'fraction_numerical': 0.008928571428571428, 'mean_word_length': 2.2633495145631066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1649606', 'n_tokens_mistral': 813, 'n_tokens_neox': 783, 'n_words': 212}