def translate_glob(pat, subentries_match=None):
    """Translate a glob PATTERN to a regular expression."""
    translated_parts = []
    for part in iexplode_path(pat):
        translated_parts.append(translate_glob_part(part))
    res = join_translated(translated_parts, os_sep_class, subentries_match=subentries_match)
    res = r'(?s:{res})\Z'.format(res=res)
    return res
Translate a glob PATTERN to a regular expression.
src/globmatch/translation.py