예제 #1
0
파일: indexers.py 프로젝트: kleintom/dxr
    def __init__(self, path, contents, plugin_name, tree, tree_analysis):
        """
        :arg tree_analysis: TreeAnalysisResult object with the results
            from the post-build analysis.

        """
        super(FileToIndex, self).__init__(path, contents, plugin_name, tree)

        self.tree_analysis = tree_analysis
        self.abs_module_name = path_to_module(tree_analysis.python_path, self.path)

        self._visitor = None
예제 #2
0
파일: indexers.py 프로젝트: mcphail/dxr
    def __init__(self, path, contents, plugin_name, tree, tree_analysis):
        """
        :arg tree_analysis: TreeAnalysisResult object with the results
        from the post-build analysis.

        """
        super(FileToIndex, self).__init__(path, contents, plugin_name, tree)

        self.tree_analysis = tree_analysis
        self.abs_module_name = path_to_module(tree_analysis.python_path,
                                              self.path)

        self._visitor = None
예제 #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)