def _translate_pattern(self, pattern, anchor=True, prefix=None,<EOL>is_regex=False):
if is_regex:<EOL><INDENT>if isinstance(pattern, str):<EOL><INDENT>return re.compile(pattern)<EOL><DEDENT>else:<EOL><INDENT>return pattern<EOL><DEDENT><DEDENT>if pattern:<EOL><INDENT>pattern_re = self._glob_to_re(pattern)<EOL><DEDENT>else:<EOL><INDENT>pattern_re = '<STR_LIT>'<EOL><DEDENT>base = re.escape(os.path.join(self.base, '<STR_LIT>'))<EOL>if prefix is not None:<EOL><INDENT>empty_pattern = self._glob_to_re('<STR_LIT>')<EOL>prefix_re = self._glob_to_re(prefix)[:-len(empty_pattern)]<EOL>sep = os.sep<EOL>if os.sep == '<STR_LIT:\\>':<EOL><INDENT>sep = r'<STR_LIT:\\>'<EOL><DEDENT>pattern_re = '<STR_LIT>' + base + sep.join((prefix_re,<EOL>'<STR_LIT>' + pattern_re))<EOL><DEDENT>else:                               <EOL><INDENT>if anchor:<EOL><INDENT>pattern_re = '<STR_LIT>' + base + pattern_re<EOL><DEDENT><DEDENT>return re.compile(pattern_re)<EOL>
Translate a shell-like wildcard pattern to a compiled regular
        expression.

        Return the compiled regex.  If 'is_regex' true,
        then 'pattern' is directly compiled to a regex (if it's a string)
        or just returned as-is (assumes it's a regex object).