def checkPluginPath(plugin_filename, module_package): debug( "Checking top level plugin path %s %s", plugin_filename, module_package ) plugin_info = considerFilename( module_package = module_package, module_filename = plugin_filename ) if plugin_info is not None: # File or package makes a difference, handle that if Utils.isFile(plugin_info[0]) or \ Importing.isPackageDir(plugin_info[0]): _checkPluginPath(plugin_filename, module_package) elif Utils.isDir(plugin_info[0]): for sub_path, sub_filename in Utils.listDir(plugin_info[0]): assert sub_filename != "__init__.py" if Importing.isPackageDir(sub_path) or \ sub_path.endswith(".py"): _checkPluginPath(sub_path, None) else: warning("Failed to include module from '%s'.", plugin_info[0]) else: warning("Failed to recurse to directory '%s'.", plugin_filename)
def _checkPluginPath(plugin_filename, module_package): plugin_info = considerFilename(module_package=module_package, module_filename=plugin_filename) if plugin_info is not None: module, added = recurseTo(module_filename=plugin_info[0], module_relpath=plugin_info[1], module_package=module_package) if module: if not added: warning("Recursed to %s '%s' at '%s' twice.", "package" if module.isPythonPackage() else "module", module.getName(), plugin_info[0]) if module.isPythonPackage(): package_dir = Utils.dirname(module.getFilename()) for sub_path, sub_filename in Utils.listDir(package_dir): if sub_filename == "__init__.py": continue assert sub_path != plugin_filename, package_dir if Importing.isPackageDir(sub_path) or sub_path.endswith( ".py"): _checkPluginPath(sub_path, module.getFullName()) else: warning("Failed to include module from '%s'.", plugin_info[0])
def checkPluginPath( plugin_filename, module_package ): plugin_info = considerFilename( module_package = module_package, module_filename = plugin_filename ) if plugin_info is not None: # File or package, handle that. if Utils.isFile( plugin_info[0] ) or Importing.isPackageDir( plugin_info[0] ): _checkPluginPath( plugin_filename, module_package ) elif Utils.isDir( plugin_info[0] ): for sub_path, sub_filename in Utils.listDir( plugin_info[0] ): assert sub_filename != "__init__.py" if Importing.isPackageDir( sub_path ) or sub_path.endswith( ".py" ): _checkPluginPath( sub_path, None ) else: warning( "Failed to include module from '%s'.", plugin_info[0] )
def checkPluginPath(plugin_filename, module_package): plugin_info = considerFilename(module_package=module_package, module_filename=plugin_filename) if plugin_info is not None: # File or package, handle that. if Utils.isFile(plugin_info[0]) or Importing.isPackageDir( plugin_info[0]): _checkPluginPath(plugin_filename, module_package) elif Utils.isDir(plugin_info[0]): for sub_path, sub_filename in Utils.listDir(plugin_info[0]): assert sub_filename != "__init__.py" if Importing.isPackageDir(sub_path) or sub_path.endswith( ".py"): _checkPluginPath(sub_path, None) else: warning("Failed to include module from '%s'.", plugin_info[0])
def _checkPluginPath( plugin_filename, module_package ): plugin_info = considerFilename( module_package = module_package, module_filename = plugin_filename ) if plugin_info is not None: module, added = recurseTo( module_filename = plugin_info[0], module_relpath = plugin_info[1], module_package = module_package ) if module: if not added: warning( "Recursed to %s '%s' at '%s' twice.", "package" if module.isPythonPackage() else "module", module.getName(), plugin_info[0] ) if module.isPythonPackage(): package_dir = Utils.dirname( module.getFilename() ) for sub_path, sub_filename in Utils.listDir( package_dir ): if sub_filename == "__init__.py": continue assert sub_path != plugin_filename, package_dir if Importing.isPackageDir( sub_path ) or sub_path.endswith( ".py" ): _checkPluginPath( sub_path, module.getFullName() ) else: warning( "Failed to include module from '%s'.", plugin_info[0] )
def _checkPluginPath(plugin_filename, module_package): debug( "Checking detail plugin path %s %s", plugin_filename, module_package ) plugin_info = considerFilename( module_package = module_package, module_filename = plugin_filename ) if plugin_info is not None: module, is_added = recurseTo( module_filename = plugin_info[0], module_relpath = plugin_info[1], module_package = module_package, module_kind = "py", reason = "Lives in plugin directory." ) if module: if not is_added: warning( "Recursed to %s '%s' at '%s' twice.", "package" if module.isPythonPackage() else "module", module.getName(), plugin_info[0] ) if not isSameModulePath(module.getFilename(), plugin_info[0]): warning( "Duplicate ignored '%s'.", plugin_info[1] ) return debug( "Recursed to %s %s %s", module.getName(), module.getPackage(), module ) if module.isPythonPackage(): package_filename = module.getFilename() if Utils.isDir(package_filename): # Must be a namespace package. assert Utils.python_version >= 330 package_dir = package_filename # Only include it, if it contains actual modules, which will # recurse to this one and find it again. useful = False else: package_dir = Utils.dirname(package_filename) # Real packages will always be included. useful = True debug( "Package directory %s", package_dir ) for sub_path, sub_filename in Utils.listDir(package_dir): if sub_filename in ("__init__.py", "__pycache__"): continue assert sub_path != plugin_filename if Importing.isPackageDir(sub_path) or \ sub_path.endswith(".py"): _checkPluginPath(sub_path, module.getFullName()) else: # Modules should always be included. useful = True if useful: ModuleRegistry.addRootModule(module) else: warning( "Failed to include module from '%s'.", plugin_info[0] )