예제 #1
0
파일: indexers.py 프로젝트: kleintom/dxr
    def visitor(self):
        """Return IndexingNodeVisitor for this file, lazily creating and
        running it if it doesn't exist yet.

        """
        if not self._visitor:
            self.node_start_table, self.call_start_table = self.analyze_tokens()
            self._visitor = IndexingNodeVisitor(self, self.tree_analysis)
            syntax_tree = ast_parse(self.contents)
            self._visitor.visit(syntax_tree)
        return self._visitor
예제 #2
0
    def visitor(self):
        """Return IndexingNodeVisitor for this file, lazily creating and
        running it if it doesn't exist yet.

        """
        if not self._visitor:
            self.node_start_table = self.analyze_tokens()
            self._visitor = IndexingNodeVisitor(self, self.tree_analysis)
            syntax_tree = ast_parse(self.contents)
            self._visitor.visit(syntax_tree)
        return self._visitor
예제 #3
0
파일: analysis.py 프로젝트: modulexcite/dxr
    def _analyze_file(self, path, encoding):
        """Analyze an individual file. If the file isn't valid Python, add
        it to the ignore_paths list on the analysis.

        """
        try:
            syntax_tree = ast_parse(file_contents(path, encoding))
        except (IOError, SyntaxError, TypeError, UnicodeDecodeError) as error:
            rel_path = os.path.relpath(path, self.source_folder)
            warn('Failed to analyze {filename} due to error "{error}".'.format(
                 filename=rel_path, error=error))
            self.ignore_paths.add(rel_path)
            return

        abs_module_name = path_to_module(self.python_path, path)  # e.g. package.sub.current_file
        visitor = AnalyzingNodeVisitor(abs_module_name, self)
        visitor.visit(syntax_tree)