<commit_before>import re
from zope.interface import implements
from nevow import inevow, tags
from formal import iformal


_IDENTIFIER_REGEX = re.compile('^[a-zA-Z_][a-zA-Z0-9_]*$')


def titleFromName(name):

    def _():

        it = iter(name)
        last = None

        while 1:
            ch = it.next()
            if ch == '_':
                if last != '_':
                    yield ' '
            elif last in (None,'_'):
                yield ch.upper()
            elif ch.isupper() and not last.isupper():
                yield ' '
                yield ch.upper()
            else:
                yield ch
            last = ch

    return ''.join(_())


def render_cssid(fieldKey, *extras):
    """
    Render the CSS id for the form field's key.
    """
    l = [tags.slot('formName'), '-', '-'.join(fieldKey.split('.'))]
    for extra in extras:
        l.append('-')
        l.append(extra)
    return l



def validIdentifier(name):
    """
    Test that name is a valid Python identifier.
    """
    return _IDENTIFIER_REGEX.match(name) is not None
<commit_msg>added keytocssid for backward compatibility<commit_after>import re
from zope.interface import implements
from nevow import inevow, tags
from formal import iformal


_IDENTIFIER_REGEX = re.compile('^[a-zA-Z_][a-zA-Z0-9_]*$')


def titleFromName(name):

    def _():

        it = iter(name)
        last = None

        while 1:
            ch = it.next()
            if ch == '_':
                if last != '_':
                    yield ' '
            elif last in (None,'_'):
                yield ch.upper()
            elif ch.isupper() and not last.isupper():
                yield ' '
                yield ch.upper()
            else:
                yield ch
            last = ch

    return ''.join(_())

def keytocssid(fieldKey, *extras):
    return render_cssid(fieldKey, *extras)

def render_cssid(fieldKey, *extras):
    """
    Render the CSS id for the form field's key.
    """
    l = [tags.slot('formName'), '-', '-'.join(fieldKey.split('.'))]
    for extra in extras:
        l.append('-')
        l.append(extra)
    return l



def validIdentifier(name):
    """
    Test that name is a valid Python identifier.
    """
    return _IDENTIFIER_REGEX.match(name) is not None

{'fraction_non_alphanumeric': 0.1272965879265092, 'fraction_numerical': 0.0026246719160104987, 'mean_word_length': 1.7389221556886227, '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': '2075601', 'n_tokens_mistral': 727, 'n_tokens_neox': 685, 'n_words': 194}