pylint/pyreverse/inspector.py
def project_from_files(
    files, func_wrapper=_astroid_wrapper, project_name="no name", black_list=("CVS",)
):
    """return a Project from a list of files or modules"""
    # build the project representation
    astroid_manager = manager.AstroidManager()
    project = Project(project_name)
    for something in files:
        if not os.path.exists(something):
            fpath = modutils.file_from_modpath(something.split("."))
        elif os.path.isdir(something):
            fpath = os.path.join(something, "__init__.py")
        else:
            fpath = something
        ast = func_wrapper(astroid_manager.ast_from_file, fpath)
        if ast is None:
            continue
        # XXX why is first file defining the project.path ?
        project.path = project.path or ast.file
        project.add_module(ast)
        base_name = ast.name
        # recurse in package except if __init__ was explicitly given
        if ast.package and something.find("__init__") == -1:
            # recurse on others packages / modules if this is a package
            for fpath in modutils.get_module_files(
                os.path.dirname(ast.file), black_list
            ):
                ast = func_wrapper(astroid_manager.ast_from_file, fpath)
                if ast is None or ast.name == base_name:
                    continue
                project.add_module(ast)
    return project
def project_from_files(
    files, func_wrapper=_astroid_wrapper, project_name="no name", black_list=("CVS",)
):
    # build the project representation
    astroid_manager = manager.AstroidManager()
    project = Project(project_name)
    for something in files:
        if not os.path.exists(something):
            fpath = modutils.file_from_modpath(something.split("."))
        elif os.path.isdir(something):
            fpath = os.path.join(something, "__init__.py")
        else:
            fpath = something
        ast = func_wrapper(astroid_manager.ast_from_file, fpath)
        if ast is None:
            continue
        # XXX why is first file defining the project.path ?
        project.path = project.path or ast.file
        project.add_module(ast)
        base_name = ast.name
        # recurse in package except if __init__ was explicitly given
        if ast.package and something.find("__init__") == -1:
            # recurse on others packages / modules if this is a package
            for fpath in modutils.get_module_files(
                os.path.dirname(ast.file), black_list
            ):
                ast = func_wrapper(astroid_manager.ast_from_file, fpath)
                if ast is None or ast.name == base_name:
                    continue
                project.add_module(ast)
    return project
def project_from_files ( files , func_wrapper = _astroid_wrapper , project_name = "no name" , black_list = ( "CVS" , ) ) : # build the project representation astroid_manager = manager . AstroidManager ( ) project = Project ( project_name ) for something in files : if not os . path . exists ( something ) : fpath = modutils . file_from_modpath ( something . split ( "." ) ) elif os . path . isdir ( something ) : fpath = os . path . join ( something , "__init__.py" ) else : fpath = something ast = func_wrapper ( astroid_manager . ast_from_file , fpath ) if ast is None : continue # XXX why is first file defining the project.path ? project . path = project . path or ast . file project . add_module ( ast ) base_name = ast . name # recurse in package except if __init__ was explicitly given if ast . package and something . find ( "__init__" ) == - 1 : # recurse on others packages / modules if this is a package for fpath in modutils . get_module_files ( os . path . dirname ( ast . file ) , black_list ) : ast = func_wrapper ( astroid_manager . ast_from_file , fpath ) if ast is None or ast . name == base_name : continue project . add_module ( ast ) return project
return a Project from a list of files or modules
return a Project from a list of files or modules