<commit_before>from win_unc.sanitizors import sanitize_username, sanitize_unc_path


def is_valid_drive_letter(string):
    """
    Drive letters are one character in length and between "A" and "Z". Case does not matter.
    """
    return (len(string) == 1
            and string[0].isalpha())


def is_valid_unc_path(string):
    """
    Valid UNC paths are at least three characters long, begin with "\\", do not start or end with
    whitepsace, and do not contain certain invalid characters (see `sanitize_unc_path`).
    """
    return (len(string) > 2
            and string.startswith('\\\\')
            and string == string.strip()
            and string == sanitize_unc_path(string))


def is_valid_username(string):
    """
    A valid Windows username (logon) is a non-empty string that does not start or end with
    whitespace, and does not contain certain invalid characters (see `sanitize_username`).
    """
    return (len(string) > 0
            and string == string.strip()
            and string == sanitize_username(string))<commit_msg>Fix bad refactor of is_valid_unc_path<commit_after>from win_unc.internal.utils import take_while
from win_unc.sanitizors import sanitize_username, sanitize_unc_path


def is_valid_drive_letter(string):
    """
    Drive letters are one character in length and between "A" and "Z". Case does not matter.
    """
    return (len(string) == 1
            and string[0].isalpha())


def is_valid_unc_path(string):
    """
    Valid UNC paths are at least three characters long, begin with exactly two backslashes, not
    start or end with whitepsace, and do not contain certain invalid characters
    (see `sanitize_unc_path`).
    """
    return (len(string) > 2
            and len(take_while(lambda c: c == '\\', string)) == 2
            and string == string.strip()
            and string == sanitize_unc_path(string))


def is_valid_username(string):
    """
    A valid Windows username (logon) is a non-empty string that does not start or end with
    whitespace, and does not contain certain invalid characters (see `sanitize_username`).
    """
    return (len(string) > 0
            and string == string.strip()
            and string == sanitize_username(string))
{'fraction_non_alphanumeric': 0.09722222222222222, 'fraction_numerical': 0.004032258064516129, 'mean_word_length': 3.0306859205776173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3910942', 'n_tokens_mistral': 641, 'n_tokens_neox': 632, 'n_words': 223}