<commit_before>import copy
import logging

import colander
import webhelpers2.html.tags as tags
from ziggurat_form.exceptions import FormInvalid

log = logging.getLogger(__name__)


def while_parent(widget, path):
    if widget.position is not None:
        path.append(str(widget.position))
    else:
        path.append(widget.name)
    if widget.parent_widget and not isinstance(widget.parent_widget, FormWidget):
        while_parent(widget.parent_widget, path)
    return path


class DummyNode(object):
    def __init__(self, name, widget=None):
        self.name = name
        self.widget = widget
        self.required = colander.required


class BaseWidget(object):
    _marker_type = None

    def __init__(self, custom_label=None, validators=None,
                 blank_widget_data=False, *args, **kwargs):
        self.cloned = False
        self.custom_label = custom_label
        self.args = args
        self.kwargs = kwargs
        self.form = None
        self.validators = validators or []
        self.position = None
        self.node = None<commit_msg>widget: path generation inline with what colander asdict() returns<commit_after>import copy
import logging

import colander
import webhelpers2.html.tags as tags
from ziggurat_form.exceptions import FormInvalid

log = logging.getLogger(__name__)


def while_parent(widget, path):
    if widget.position is not None:
        path.append(str(widget.position))
    elif widget.name:
        path.append(widget.name)
    if widget.parent_widget and not isinstance(widget.parent_widget, FormWidget):
        while_parent(widget.parent_widget, path)
    return path


class DummyNode(object):
    def __init__(self, name, widget=None):
        self.name = name
        self.widget = widget
        self.required = colander.required


class BaseWidget(object):
    _marker_type = None

    def __init__(self, custom_label=None, validators=None,
                 blank_widget_data=False, *args, **kwargs):
        self.cloned = False
        self.custom_label = custom_label
        self.args = args
        self.kwargs = kwargs
        self.form = None
        self.validators = validators or []
        self.position = None
        self.node = None
{'fraction_non_alphanumeric': 0.08209291835814163, 'fraction_numerical': 0.0009021199819576004, 'mean_word_length': 2.8844133099824867, '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': '1747414', 'n_tokens_mistral': 630, 'n_tokens_neox': 625, 'n_words': 162}