def _handle_ns(packageName, path_item):
importer = get_importer(path_item)<EOL>if importer is None:<EOL><INDENT>return None<EOL><DEDENT>loader = importer.find_module(packageName)<EOL>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] = imp.new_module(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>for path_item in path:<EOL><INDENT>if path_item not in module.__path__:<EOL><INDENT>module.__path__.append(path_item)<EOL><DEDENT><DEDENT><DEDENT>return subpath<EOL>
Ensure that named package includes a subpath of path_item (if needed)