Ejemplo n.º 1
0
 def api_fetch(self):
     """
     Deprecated fetch() that gets parsed content from the API.
     The API doesn't cache parsed wikitext, and can be up to 10x slower
     depending on page complexity.
     """
     page = wapiti.get_articles(self.page_id)[0]
     pq = PyQuery(page.rev_text)
     return pq
Ejemplo n.º 2
0
def do_input(input_name, page_title='', page_id=None):
    if not page_title:
        page_title = request.query.title
    in_type = AVAIL_INPUTS.get(input_name.lower())
    page_title = request.query.title or page_title
    page_id = request.query.page_id or page_id
    if in_type is None:
        raise Exception('No input found with name "' + input_name + '"')
    if not page_title:
        raise Exception('You must pass in a page title (and preferably a page id)')
    if not page_id:
        page = wapiti.get_articles(titles=page_title, parsed=False)[0]
        page_id = page.page_id
    # TODO: optional page_id, do lookup if None
    in_obj = in_type(page_title, page_id)
    results = in_obj()
    results['durations'] = in_obj.durations
    return results