def _get_link(self, cobj):
fname_idx = None<EOL>full_name = cobj['<STR_LIT>'] + '<STR_LIT:.>' + cobj['<STR_LIT:name>']<EOL>if full_name in self._searchindex['<STR_LIT>']:<EOL><INDENT>value = self._searchindex['<STR_LIT>'][full_name]<EOL>if isinstance(value, dict):<EOL><INDENT>value = value[next(iter(value.keys()))]<EOL><DEDENT>fname_idx = value[<NUM_LIT:0>]<EOL><DEDENT>elif cobj['<STR_LIT>'] in self._searchindex['<STR_LIT>']:<EOL><INDENT>value = self._searchindex['<STR_LIT>'][cobj['<STR_LIT>']]<EOL>if cobj['<STR_LIT:name>'] in value.keys():<EOL><INDENT>fname_idx = value[cobj['<STR_LIT:name>']][<NUM_LIT:0>]<EOL><DEDENT><DEDENT>if fname_idx is not None:<EOL><INDENT>fname = self._searchindex['<STR_LIT>'][fname_idx] + '<STR_LIT>'<EOL>if self._is_windows:<EOL><INDENT>fname = fname.replace('<STR_LIT:/>', '<STR_LIT:\\>')<EOL>link = os.path.join(self.doc_url, fname)<EOL><DEDENT>else:<EOL><INDENT>link = posixpath.join(self.doc_url, fname)<EOL><DEDENT>if hasattr(link, '<STR_LIT>'):<EOL><INDENT>link = link.decode('<STR_LIT:utf-8>', '<STR_LIT:replace>')<EOL><DEDENT>if link in self._page_cache:<EOL><INDENT>html = self._page_cache[link]<EOL><DEDENT>else:<EOL><INDENT>html = get_data(link, self.gallery_dir)<EOL>self._page_cache[link] = html<EOL><DEDENT>comb_names = [cobj['<STR_LIT>'] + '<STR_LIT:.>' + cobj['<STR_LIT:name>']]<EOL>if self.extra_modules_test is not None:<EOL><INDENT>for mod in self.extra_modules_test:<EOL><INDENT>comb_names.append(mod + '<STR_LIT:.>' + cobj['<STR_LIT:name>'])<EOL><DEDENT><DEDENT>url = False<EOL>if hasattr(html, '<STR_LIT>'):<EOL><INDENT>html = html.decode('<STR_LIT:utf-8>', '<STR_LIT:replace>')<EOL><DEDENT>for comb_name in comb_names:<EOL><INDENT>if hasattr(comb_name, '<STR_LIT>'):<EOL><INDENT>comb_name = comb_name.decode('<STR_LIT:utf-8>', '<STR_LIT:replace>')<EOL><DEDENT>if comb_name in html:<EOL><INDENT>url = link + u'<STR_LIT:#>' + comb_name<EOL><DEDENT><DEDENT>link = url<EOL><DEDENT>else:<EOL><INDENT>link = False<EOL><DEDENT>return link<EOL>
Get a valid link, False if not found