<commit_before>import re

BAD_SLUG_PATTERN = '([/\\<>\s])'
BAD_XML = '^xml+'


def clean_fixture_field_name(field_name):
    """Effectively slugifies a fixture's field name so that we don't send
    bad XML back from the phone. Ideally, the fixture name should be
    verified as a good slug before using it.
    """
    return re.sub(BAD_XML, re.sub(BAD_SLUG_PATTERN, '_', field_name), '')


def is_field_name_invalid(field_name):
    return bool(re.search(BAD_SLUG_PATTERN, field_name))<commit_msg>make sure that in the event a string gets to here and does start with xml (i think there are checks prior) that it replaces the xml wtih an underscore to avoid hard failures<commit_after>import re

BAD_SLUG_PATTERN = r"([/\\<>\s])"


def clean_fixture_field_name(field_name):
    """Effectively slugifies a fixture's field name so that we don't send
    bad XML back from the phone. Ideally, the fixture name should be
    verified as a good slug before using it.
    """
    subbed_string = re.sub(BAD_SLUG_PATTERN, '_', field_name)
    if subbed_string.startswith('xml'):
        subbed_string = subbed_string.replace('xml', '_', 1)
    return subbed_string


def is_field_name_invalid(field_name):
    return bool(re.search(BAD_SLUG_PATTERN, field_name))
{'fraction_non_alphanumeric': 0.09785202863961814, 'fraction_numerical': 0.0007955449482895784, 'mean_word_length': 4.330508474576271, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, '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': '7531199', 'n_tokens_mistral': 425, 'n_tokens_neox': 404, 'n_words': 132}