'Translate a shell-like glob pattern to a regular expression.
Return a string containing the regex.  Differs from
\'fnmatch.translate()\' in that \'*\' does not match "special characters"
(which are platform-specific).'

def _glob_to_re(self, pattern):

    pattern_re = fnmatch.translate(pattern)
    sep = os.sep
    if (os.sep == '\\'):
        sep = '\\\\\\\\'
    escaped = ('\\1[^%s]' % sep)
    pattern_re = re.sub('((?<!\\\\)(\\\\\\\\)*)\\.', escaped, pattern_re)
    return pattern_re
