def short_name_match()

in libmozdata/patchanalysis.py [0:0]


def short_name_match(short_name, real_name, email, exact_matching=True):
    short_name = short_name.lower()
    real_name = real_name.lower()

    if exact_matching:
        return (
            ":" + short_name + "]" in real_name
            or ":" + short_name + ")" in real_name
            or ":" + short_name + "," in real_name
            or ":" + short_name + "." in real_name
            or ":" + short_name + " " in real_name
        )
    else:
        names = real_name.split(" ")
        possible_short_name1 = (
            names[0][0] + names[1] if names and len(names) >= 2 else ""
        )
        possible_short_name2 = names[0] + names[1] if names and len(names) >= 2 else ""

        return (
            (short_name in real_name)
            or (short_name + "@mozilla.com" in real_name)
            or (possible_short_name1 and short_name == possible_short_name1)
            or (possible_short_name2 and short_name == possible_short_name2)
            or (email.startswith(short_name + "@"))
            or (short_name == email[email.index("@") + 1 : email.rindex(".")])
        )