<commit_before>"""This module defines a set of classes and free functions for building
   BitBake values.  Values can either be created directly or parsed from
   a string."""

import re
from collections import deque
from itertools import chain
import bb.data
from bb import msg, utils

class RecursionError(RuntimeError):
    def __init__(self, variable):
        self.variable = variable

    def __str__(self):
        return "Recursive variable reference for '%s'" % self.variable

class PythonExpansionError(Exception):
    def __init__(self, exception, node):
        self.exception = exception
        self.node = node

    def __str__(self):
        return "'%s' while resolving '%s'" % (self.exception, str(self.node))


# The following Visitor infrastructure was heavily inspired by the one
# implemented in the Python standard library module 'ast'.

def iter_fields(node):
    """
    Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
    that is present on *node*.
    """

    for field in dir(node):
        if field.startswith('field_'):
            try:
                yield field, getattr(node, field)
            except AttributeError:
                pass

class Vistor(object):
    def visit(self, node):
        """Visit a node."""

        method = 'visit_' + node.__class__.__name__
        visitor = getattr(self, method, self.generic_visit)
        return visitor(node)

    def generic_visit(self, node):
        """Called if no explicit visitor function exists for a node."""

        for field, value in iter_fields(node):
            if isinstance(value, list):
                for item in value:
                    if isinstance(item, Value):
                        self.visit(item)
            elif isinstance(value, Value):
                self.visit(value)

class Value(object):
    """A simple value that is meant as a base class for all other values."""

    def __init__(self, metadata):
        self.metadata = metadata

    def __eq__(self, other):
        return isinstance(other, type(self)) and \
               self.metadata == other.metadata

    def __ne__(self, other):
        return not self == other

    def __hash__(self):<commit_msg>Fix metadata comparison in __eq__<commit_after>"""This module defines a set of classes and free functions for building
   BitBake values.  Values can either be created directly or parsed from
   a string."""

import re
from collections import deque
from itertools import chain
import bb.data
from bb import msg, utils

class RecursionError(RuntimeError):
    def __init__(self, variable):
        self.variable = variable

    def __str__(self):
        return "Recursive variable reference for '%s'" % self.variable

class PythonExpansionError(Exception):
    def __init__(self, exception, node):
        self.exception = exception
        self.node = node

    def __str__(self):
        return "'%s' while resolving '%s'" % (self.exception, str(self.node))


# The following Visitor infrastructure was heavily inspired by the one
# implemented in the Python standard library module 'ast'.

def iter_fields(node):
    """
    Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields``
    that is present on *node*.
    """

    for field in dir(node):
        if field.startswith('field_'):
            try:
                yield field, getattr(node, field)
            except AttributeError:
                pass

class Vistor(object):
    def visit(self, node):
        """Visit a node."""

        method = 'visit_' + node.__class__.__name__
        visitor = getattr(self, method, self.generic_visit)
        return visitor(node)

    def generic_visit(self, node):
        """Called if no explicit visitor function exists for a node."""

        for field, value in iter_fields(node):
            if isinstance(value, list):
                for item in value:
                    if isinstance(item, Value):
                        self.visit(item)
            elif isinstance(value, Value):
                self.visit(value)

class Value(object):
    """A simple value that is meant as a base class for all other values."""

    def __init__(self, metadata):
        self.metadata = metadata

    def __eq__(self, other):
        return isinstance(other, type(self)) and \
               self.metadata is other.metadata

    def __ne__(self, other):
        return not self == other

    def __hash__(self):
{'fraction_non_alphanumeric': 0.09315931593159316, 'fraction_numerical': 0.0, 'mean_word_length': 2.480814408770556, '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': '5581012', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1138, 'n_words': 436}