Example #1
0
 def get_names(self, import_name: str) -> FrozenSet[str]:
     if is_std(import_name):
         return get_dir(import_name)
     visitor = self.__class__()
     source = get_source(import_name)
     if source:
         visitor.traverse(source)
         return visitor.get_all() or visitor.get_suggestion()
     return frozenset()
Example #2
0
 def get_names(self, package: str) -> FrozenSet[str]:
     if utils.is_std(package):
         return utils.get_dir(package)
     source = utils.get_source(package)
     if source:
         try:
             tree = ast.parse(source)
         except SyntaxError:
             return frozenset()
         else:
             visitor = self.__class__()
             visitor.traverse(tree)
             return visitor.get_all() or visitor.get_suggestion()
     return frozenset()
Example #3
0
    def get_names(cls, package: str) -> FrozenSet[str]:
        if utils.is_std(package):
            return utils.get_dir(package)

        source = utils.get_source(package)
        if source:
            try:
                tree = ast.parse(source)
            except SyntaxError:
                return frozenset()
            else:
                visitor = cls()
                relate(tree)
                visitor.visit(tree)
                return visitor.get_all() or visitor.get_suggestion()
        return frozenset()