<commit_before>#
# Jasy - Web Tooling Framework
# Copyright 2013 <NAME>
#

import itertools
        
def assembleDot(node, result=None):
    """
    Joins a dot node (cascaded supported, too) into a single string like "foo.bar.Baz"
    """
    
    if result == None:
        result = []

    for child in node:
        if child.type == "identifier":
            result.append(child.value)
        elif child.type == "dot":
            assembleDot(child, result)
        else:
            return None

    return ".".join(result)



def combineSelector(node):
    """
    Figures out the fully qualified selector of the given Node
    """

    selector = []

    while node:
        if node.type == "selector":
            selector.append(node.name)
        elif node.type == "mixin":
            selector.append(node.selector)

        node = getattr(node, "parent", None)

    return [" ".join(item) for item in itertools.product(*reversed(selector))]

<commit_msg>Re-build selector join part of combineSelector to correctly deal with '&' ampersand placeholders in selectors<commit_after>#
# Jasy - Web Tooling Framework
# Copyright 2013 <NAME>
#

import itertools
        
def assembleDot(node, result=None):
    """
    Joins a dot node (cascaded supported, too) into a single string like "foo.bar.Baz"
    """
    
    if result == None:
        result = []

    for child in node:
        if child.type == "identifier":
            result.append(child.value)
        elif child.type == "dot":
            assembleDot(child, result)
        else:
            return None

    return ".".join(result)



def combineSelector(node):
    """
    Figures out the fully qualified selector of the given Node
    """

    selector = []

    current = node
    while current:
        if current.type == "selector":
            selector.append(current.name)
        elif current.type == "mixin":
            selector.append(current.selector)

        current = getattr(current, "parent", None)

    result = []
    for item in itertools.product(*reversed(selector)):
        combined = ""
        for part in item:
            if combined:
                if "&" in part:
                    combined = part.replace("&", combined)
                else:
                    combined = "%s %s" % (combined, part)
            else:
                if "&" in part:
                    raise Exception("Can't merge selector %s - parent missing - at line %s!" % (part, node.line))
                else:
                    combined = part

        result.append(combined)

    return result

{'fraction_non_alphanumeric': 0.10930232558139535, 'fraction_numerical': 0.0031007751937984496, 'mean_word_length': 1.8934977578475336, 'pattern_counts': {'":': 8, '<': 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': '2532054', 'n_tokens_mistral': 737, 'n_tokens_neox': 699, 'n_words': 217}