def _handle_ns(packageName, path_item):
importer = get_importer(path_item)<EOL>if importer is None:<EOL><INDENT>return None<EOL><DEDENT>with warnings.catch_warnings():<EOL><INDENT>warnings.simplefilter("<STR_LIT:ignore>")<EOL>loader = importer.find_module(packageName)<EOL><DEDENT>if loader is None:<EOL><INDENT>return None<EOL><DEDENT>module = sys.modules.get(packageName)<EOL>if module is None:<EOL><INDENT>module = sys.modules[packageName] = types.ModuleType(packageName)<EOL>module.__path__ = []<EOL>_set_parent_ns(packageName)<EOL><DEDENT>elif not hasattr(module, '<STR_LIT>'):<EOL><INDENT>raise TypeError("<STR_LIT>", packageName)<EOL><DEDENT>handler = _find_adapter(_namespace_handlers, importer)<EOL>subpath = handler(importer, path_item, packageName, module)<EOL>if subpath is not None:<EOL><INDENT>path = module.__path__<EOL>path.append(subpath)<EOL>loader.load_module(packageName)<EOL>_rebuild_mod_path(path, packageName, module)<EOL><DEDENT>return subpath<EOL>
Ensure that named package includes a subpath of path_item (if needed)