def generate_python_txt(): """Generate documentation for the hooks and elinks modules.""" import elinks import hooks # Remove anything that doesn't belong in the API documentation. # hooks_api_functions = ( 'follow_url_hook', 'goto_url_hook', 'pre_format_html_hook', 'proxy_for_hook', 'quit_hook', ) for key in hooks.__dict__.keys(): if key not in hooks_api_functions and not key.startswith('_'): del hooks.__dict__[key] hooks.__doc__ = hooks.__doc__.replace('Example Python', 'Python') # Generate the documentation. # try: output = separator.join((preface, document_modules(hooks, elinks))) finally: # Restore the hooks module to a sane state. reload(hooks) # View the documentation. # path = write_tempfile(output) elinks.open(path)
def _callback(self, url): """Open the given URL in a new tab.""" if 'goto_url_hook' in globals(): # Mimic the standard "Go to URL" dialog by calling goto_url_hook(). url = goto_url_hook(url) or url if url: elinks.open(url, new_tab=True)
def _callback(self, header, body): """Read a feed, identify unseen entries, and open them in new tabs.""" import anydbm import feedparser # you need to get this module from feedparser.org import os if not body: return seen = anydbm.open(os.path.join(elinks.home, "rss.seen"), "c") feed = feedparser.parse(body) new = 0 errors = 0 for entry in feed.entries: try: if not seen.has_key(entry.link): elinks.open(entry.link, new_tab=True) seen[entry.link] = "" new += 1 except: errors += 1 seen.close() self._tally(feed.channel.title, new, errors)