wikibot/smw.py
def ask(self, query, title=None, limit=None):
        """
        Ask a query against Semantic MediaWiki.

        API doc: https://semantic-mediawiki.org/wiki/Ask_API

        Returns:
            Generator for retrieving all search results, with each answer as a dictionary.
            If the query is invalid, an APIError is raised. A valid query with zero
            results will not raise any error.

        Examples:

            >>> query = "[[Category:my cat]]|[[Has name::a name]]|?Has property"
            >>> for answer in site.ask(query):
            >>>     for title, data in answer.items()
            >>>         print(title)
            >>>         print(data)
        """
        kwargs = {}
        if title is None:
            kwargs['title'] = title

        offset = 0
        while offset is not None:
            results = self.site.raw_api('ask', query=u'{query}|offset={offset}'.format(
                query=query, offset=offset), http_method='GET', **kwargs)
            self.site.handle_api_result(results)  # raises APIError on error
            offset = results.get('query-continue-offset')
            # workaround limit
            if limit is not None and offset is not None and offset>=limit:
                offset=None
            yield results

        Ask a query against Semantic MediaWiki.

        API doc: https://semantic-mediawiki.org/wiki/Ask_API

        Returns:
            Generator for retrieving all search results, with each answer as a dictionary.
            If the query is invalid, an APIError is raised. A valid query with zero
            results will not raise any error.

        Examples:

            >>> query = "[[Category:my cat]]|[[Has name::a name]]|?Has property"
            >>> for answer in site.ask(query):
            >>>     for title, data in answer.items()
            >>>         print(title)
            >>>         print(data)
        
Ask a query against Semantic MediaWiki.
Ask a query against Semantic MediaWiki .
def ask(self, query, title=None, limit=None):
        kwargs = {}
        if title is None:
            kwargs['title'] = title
        offset = 0
        while offset is not None:
            results = self.site.raw_api('ask', query=u'{query}|offset={offset}'.format(
                query=query, offset=offset), http_method='GET', **kwargs)
            self.site.handle_api_result(results)  
            offset = results.get('query-continue-offset')
            if limit is not None and offset is not None and offset>=limit:
                offset=None
            yield results
def ask ( self , query , title = None , limit = None ) : kwargs = { } if title is None : kwargs [ 'title' ] = title offset = 0 while offset is not None : results = self . site . raw_api ( 'ask' , query = u'{query}|offset={offset}' . format ( query = query , offset = offset ) , http_method = 'GET' , ** kwargs ) self . site . handle_api_result ( results ) offset = results . get ( 'query-continue-offset' ) if limit is not None and offset is not None and offset >= limit : offset = None yield results
Ask a query against Semantic MediaWiki.
Ask a query against Semantic MediaWiki .
"""
        Ask a query against Semantic MediaWiki.

        API doc: https://semantic-mediawiki.org/wiki/Ask_API

        Returns:
            Generator for retrieving all search results, with each answer as a dictionary.
            If the query is invalid, an APIError is raised. A valid query with zero
            results will not raise any error.

        Examples:

            >>> query = "[[Category:my cat]]|[[Has name::a name]]|?Has property"
            >>> for answer in site.ask(query):
            >>>     for title, data in answer.items()
            >>>         print(title)
            >>>         print(data)
        """ # raises APIError on error # workaround limit
Generator for retrieving all search results, with each answer as a dictionary.
If the query is invalid, an APIError is raised. A valid query with zero
results will not raise any error.
Generator for retrieving all search results with each answer as a dictionary . If the query is invalid an APIError is raised . A valid query with zero results will not raise any error .
self
query
title
limit
examples
>>> query = "[[Category:my cat]]|[[Has name::a name]]|?Has property"
>>> for answer in site.ask(query):
>>>     for title, data in answer.items()
>>>         print(title)
>>>         print(data)
>>> query = " [[ Category : my cat ]] | [[ Has name :: a name ]] |?Has property " >>> for answer in site . ask ( query ) : >>> for title data in answer . items () >>> print ( title ) >>> print ( data )