Exemple #1
0
 def _analyse_module_to_import(self, origin_node: ast.AST,
                               target: str) -> Optional[ImportAnalyser]:
     analyser = ImportAnalyser(target)
     if analyser.can_be_imported:
         return analyser
     else:
         self._log_unresolved_import(origin_node, target)
Exemple #2
0
    def update_symbol_table_with_imports(self):
        if self._included_imported_files:
            return

        import os
        from boa3.analyser.importanalyser import ImportAnalyser
        from boa3.model.imports.importsymbol import Import

        imports = self._imported_files.copy()
        paths_already_imported = [
            imported.origin for imported in self.symbol_table.values() if
            isinstance(imported, Import) and isinstance(imported.origin, str)
        ]
        if isinstance(self.path, str):
            paths_already_imported.append(
                self.path.replace(os.path.sep, constants.PATH_SEPARATOR))

        for file_path, analyser in imports.items():
            if file_path not in paths_already_imported:
                import_analyser = ImportAnalyser(
                    file_path,
                    self.root,
                    already_imported_modules=imports,
                    log=False,
                    get_entry=True)
                import_symbol = Import(file_path, analyser.ast_tree,
                                       import_analyser, {})
                self.symbol_table[file_path] = import_symbol

        self._included_imported_files = True