def decideRecursion(module_filename, module_name, module_package, module_kind): # Many branches, which make decisions immediately, pylint: disable=R0911 if module_kind == "shlib": if Options.isStandaloneMode(): return True, "Shared library for inclusion." else: return False, "Shared library cannot be inspected." if module_package is None: full_name = module_name else: full_name = module_package + "." + module_name if isFrozenModule(full_name): return False, "Module is frozen." no_case_modules = Options.getShallFollowInNoCase() for no_case_module in no_case_modules: if full_name == no_case_module: return (False, "Module listed explicitely to not recurse to.") if full_name.startswith(no_case_module + "."): return (False, "Module in package listed explicitely to not recurse to.") any_case_modules = Options.getShallFollowModules() for any_case_module in any_case_modules: if full_name == any_case_module: return (True, "Module listed explicitely to recurse to.") if full_name.startswith(any_case_module + "."): return (True, "Module in package listed explicitely to recurse to.") if Options.shallFollowNoImports(): return (False, "Requested to not recurse at all.") if Importing.isStandardLibraryPath(module_filename): return (Options.shallFollowStandardLibrary(), "Requested to %srecurse to standard library." % ("" if Options.shallFollowStandardLibrary() else "not ")) if Options.shallFollowAllImports(): return (True, "Requested to recurse to all non-standard library modules.") # Means, we were not given instructions how to handle things. return (None, "Default behaviour, not recursing without request.")
def _decide( module_filename, module_name, module_package ): # Many branches, which make decisions immediately, pylint: disable=R0911 no_case_modules = Options.getShallFollowInNoCase() if module_package is None: full_name = module_name else: full_name = module_package + "." + module_name for no_case_module in no_case_modules: if full_name == no_case_module: return False if full_name.startswith( no_case_module + "." ): return False any_case_modules = Options.getShallFollowModules() for any_case_module in any_case_modules: if full_name == any_case_module: return True if full_name.startswith( any_case_module + "." ): return True if Options.shallFollowNoImports(): return False if Importing.isStandardLibraryPath( module_filename ): return Options.shallFollowStandardLibrary() if Options.shallFollowAllImports(): return True # Means, I don't know. return None
def _decide(module_filename, module_name, module_package): # Many branches, which make decisions immediately, pylint: disable=R0911 no_case_modules = Options.getShallFollowInNoCase() if module_package is None: full_name = module_name else: full_name = module_package + "." + module_name for no_case_module in no_case_modules: if full_name == no_case_module: return False if full_name.startswith(no_case_module + "."): return False any_case_modules = Options.getShallFollowModules() for any_case_module in any_case_modules: if full_name == any_case_module: return True if full_name.startswith(any_case_module + "."): return True if Options.shallFollowNoImports(): return False if Importing.isStandardLibraryPath(module_filename): return Options.shallFollowStandardLibrary() if Options.shallFollowAllImports(): return True # Means, I don't know. return None
def decideRecursion(module_filename, module_name, module_package, module_kind ): # Many branches, which make decisions immediately, pylint: disable=R0911 if module_kind == "shlib": if Options.isStandaloneMode(): return True, "Shared library for inclusion." else: return False, "Shared library cannot be inspected." if module_package is None: full_name = module_name else: full_name = module_package + "." + module_name if isFrozenModule(full_name): return False, "Module is frozen." no_case_modules = Options.getShallFollowInNoCase() for no_case_module in no_case_modules: if full_name == no_case_module: return ( False, "Module listed explicitely to not recurse to." ) if full_name.startswith(no_case_module + "."): return ( False, "Module in package listed explicitely to not recurse to." ) any_case_modules = Options.getShallFollowModules() for any_case_module in any_case_modules: if full_name == any_case_module: return ( True, "Module listed explicitely to recurse to." ) if full_name.startswith( any_case_module + "." ): return ( True, "Module in package listed explicitely to recurse to." ) if Options.shallFollowNoImports(): return ( False, "Requested to not recurse at all." ) if Importing.isStandardLibraryPath(module_filename): return ( Options.shallFollowStandardLibrary(), "Requested to %srecurse to standard library." % ( "" if Options.shallFollowStandardLibrary() else "not " ) ) if Options.shallFollowAllImports(): return ( True, "Requested to recurse to all non-standard library modules." ) # Means, we were not given instructions how to handle things. return ( None, "Default behaviour, not recursing without request." )
def isWhiteListedImport(node): module = node.getParentModule() return Importing.isStandardLibraryPath(module.getFilename())
def isWhiteListedImport(node): module = node.getParentModule() return Importing.isStandardLibraryPath(module.getFilename())