def _early_rewrite_bailout(self, name, state):
if self.session is not None and not self._session_paths_checked:<EOL><INDENT>self._session_paths_checked = True<EOL>for path in self.session._initialpaths:<EOL><INDENT>parts = str(path).split(os.path.sep)<EOL>self._basenames_to_check_rewrite.add(os.path.splitext(parts[-<NUM_LIT:1>])[<NUM_LIT:0>])<EOL><DEDENT><DEDENT>parts = name.split("<STR_LIT:.>")<EOL>if parts[-<NUM_LIT:1>] in self._basenames_to_check_rewrite:<EOL><INDENT>return False<EOL><DEDENT>path = PurePath(os.path.sep.join(parts) + "<STR_LIT>")<EOL>for pat in self.fnpats:<EOL><INDENT>if os.path.dirname(pat):<EOL><INDENT>return False<EOL><DEDENT>if fnmatch_ex(pat, path):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>if self._is_marked_for_rewrite(name, state):<EOL><INDENT>return False<EOL><DEDENT>state.trace("<STR_LIT>" % (name,))<EOL>return True<EOL>
This is a fast way to get out of rewriting modules. Profiling has
shown that the call to imp.find_module (inside of the find_module
from this class) is a major slowdown, so, this method tries to
filter what we're sure won't be rewritten before getting to it.