Based on
            https://www.mediawiki.org/wiki/API:Query#Continuing_queries
513781
def _continued_query(self, query_params, key="pages"):
        
        query_params.update(self.__title_query_param())

        last_cont = dict()
        prop = query_params.get("prop")

        while True:
            params = query_params.copy()
            params.update(last_cont)

            request = self.mediawiki.wiki_request(params)

            if "query" not in request:
                break

            pages = request["query"][key]
            if "generator" in query_params:
                for datum in pages.values():
                    yield datum
            elif isinstance(pages, list):
                for datum in list(enumerate(pages)):
                    yield datum[1]
            else:
                for datum in pages[self.pageid].get(prop, list()):
                    yield datum

            if "continue" not in request or request["continue"] == last_cont:
                break

            last_cont = request["continue"]
354753
def query_all():
        '''
        
        '''
        recs = TabPost2Tag.select(
            TabPost2Tag,
            TabTag.kind.alias('tag_kind'),
        ).join(
            TabTag,
            on=(TabPost2Tag.tag_id == TabTag.uid)
        )
        return recs
880861
def continue_list_folder(cursor)
      resp = request('/files/list_folder/continue', cursor: cursor)
      resp['entries'].map { |e| parse_tagged_response(e) }
    end
1207725
def search(self, query, delegate, args=None, extra_args=None):
        """"""
        if args is None:
            args = {}
        args['q'] = query
        return self.__doDownloadPage(self.search_url + '?' + self._urlencode(args),
            txml.Feed(delegate, extra_args), agent=self.agent)
1128298
def query(self, query_string=""):
        

        def query_notify(operation):
            w = get_operation_notify_widget(operation, display_always=False)
            if w:
                self.ui.notify_widget(w)

        if query_string is not None:
            self.filter_query = query_string.strip()

        # FIXME: this could be part of filter command since it's command line
        backend_query = {
            "cached": False,
            "containers": True,
            "images": True,
        }

        def containers():
            backend_query["containers"] = True
            backend_query["images"] = not backend_query["images"]
            backend_query["cached"] = True

        def images():
            backend_query["containers"] = not backend_query["containers"]
            backend_query["images"] = True
            backend_query["cached"] = True

        def running():
            backend_query["stopped"] = False
            backend_query["cached"] = True
            backend_query["images"] = False

        query_conf = [
            {
                "query_keys": ["t", "type"],
                "query_values": ["c", "container", "containers"],
                "callback": containers
            }, {
                "query_keys": ["t", "type"],
                "query_values": ["i", "images", "images"],
                "callback": images
            }, {
                "query_keys": ["s", "state"],
                "query_values": ["r", "running"],
                "callback": running
            },
        ]
        query_list = re.split(r"[\s,]", self.filter_query)
        unprocessed = []
        for query_str in query_list:
            if not query_str:
                continue
            # process here x=y queries and pass rest to parent filter()
            try:
                query_key, query_value = query_str.split("=", 1)
            except ValueError:
                unprocessed.append(query_str)
            else:
                logger.debug("looking up query key %r and query value %r", query_key, query_value)
                for c in query_conf:
                    if query_key in c["query_keys"] and query_value in c["query_values"]:
                        c["callback"]()
                        break
                else:
                    raise NotifyError("Invalid query string: %r", query_str)

        widgets = []
        logger.debug("doing query %s", backend_query)
        query, c_op, i_op = self.d.filter(**backend_query)

        for o in query:
            try:
                line = MainLineWidget(o)
            except NotAvailableAnymore:
                continue
            widgets.append(line)
        if unprocessed:
            new_query = " ".join(unprocessed)
            logger.debug("doing parent query for unprocessed string: %r", new_query)
            super().filter(new_query, widgets_to_filter=widgets)
        else:
            self.set_body(widgets)
            self.ro_content = widgets

        query_notify(i_op)
        query_notify(c_op)
363571
function updateQuery() {
  let query = {};

  switch(queryTemplates.value) {
    case '0': // All raddecs
      query = {
          "size": 10,
          "query": { "match_all": {} },
          "_source": [ "transmitterId", "transmitterIdType", "receiverId",
                       "receiverIdType", "rssi", "timestamp",
                       "numberOfDecodings", "numberOfReceivers",
                       "numberOfPackets" ]
      };
      queryBox.value = JSON.stringify(query, null, 2);
      break;
    case '1': // Specific transmitterId
      query = {
          "size": 10,
          "query": { "term": { "transmitterId": "" } },
          "_source": [ "receiverId", "receiverIdType", "rssi", "timestamp",
                       "numberOfDecodings", "numberOfReceivers",
                       "numberOfPackets", "packets" ]
      };
      queryBox.value = JSON.stringify(query, null, 2);
      break;
    case '2': // Prefix transmitterId
      query = {
          "size": 10,
          "query": { "prefix": { "transmitterId": "" } },
          "_source": [ "transmitterId", "transmitterIdType", "receiverId",
                       "receiverIdType", "rssi", "timestamp",
                       "numberOfDecodings", "numberOfReceivers",
                       "numberOfPackets" ]
      };
      queryBox.value = JSON.stringify(query, null, 2);
      break;
    case '3': // Aggregate receiverId
      query = {
          "size": 0,
          "aggs" : {
            "receivers" : {
              "terms" : {
                "field" : "receiverId.keyword",
                "order" : { "_count" : "desc" },
                "size": 12
              }
            }
          }
      };
      queryBox.value = JSON.stringify(query, null, 2);
      break;
    case '4': // Aggregate rec/dec/pac
      query = {
          "size": 0,
          "aggs" : {
            "numberOfReceivers" : {
              "histogram" : {
                "field" : "numberOfReceivers",
                "interval" : 1
              }
            },
            "numberOfDecodings" : {
              "histogram" : {
                "field" : "numberOfDecodings",
                "interval" : 1,
                "min_doc_count" : 1
              }
            },
            "numberOfDistinctPackets" : {
              "histogram" : {
                "field" : "numberOfDistinctPackets",
                "interval" : 1
              }
            }
          }
      };
      queryBox.value = JSON.stringify(query, null, 2);
      break;
    case '5': // Auto-date histogram
      query = {
          "size": 0,
          "aggs" : {
            "periods" : {
              "auto_date_histogram" : {
                "field" : "timestamp",
                "buckets" : 12
              }
            }
          }
      };
      queryBox.value = JSON.stringify(query, null, 2);
      break;
  }
  queryBox.rows = countNumberOfLines(queryBox.value);
  parseQuery();
}
977673
def request(self, api_query, url=None):
        
        api_query['format'] = 'json'
        if url is not None:
            api_url = url + "/api.php"
        else:
            api_url = self.api_url

        size = sum([sys.getsizeof(v) for k, v in iteritems(api_query)])

        if size > (1024 * 8):
            # if request is bigger than 8 kB (the limit is somewhat arbitrary,
            # see https://www.mediawiki.org/wiki/API:Edit#Large_texts) then
            # transmit as multipart message

            req = self._prepare_long_request(url=api_url,
                                             api_query=api_query)
            req.send()
            if self.return_json:
                return req.response.json()
            else:
                return req.response.text
        else:
            auth1 = OAuth1(
                self.consumer_token.key,
                client_secret=self.consumer_token.secret,
                resource_owner_key=session['mwoauth_access_token']['key'],
                resource_owner_secret=session['mwoauth_access_token']['secret'])
            if self.return_json:
                return requests.post(api_url, data=api_query, auth=auth1).json()
            else:
                return requests.post(api_url, data=api_query, auth=auth1).text
817890
def currentQuery( self ):
        
        widgets = self.lineWidgets()
        output = []
        for widget in widgets:
            output.append(widget.query())
        return output
495426
def _wiki_request(params):
  '''
  
  '''
  global RATE_LIMIT_LAST_CALL
  global USER_AGENT

  params['format'] = 'json'
  if not 'action' in params:
    params['action'] = 'query'

  headers = {
    'User-Agent': USER_AGENT
  }

  if RATE_LIMIT and RATE_LIMIT_LAST_CALL and \
    RATE_LIMIT_LAST_CALL + RATE_LIMIT_MIN_WAIT > datetime.now():

    # it hasn't been long enough since the last API call
    # so wait until we're in the clear to make the request

    wait_time = (RATE_LIMIT_LAST_CALL + RATE_LIMIT_MIN_WAIT) - datetime.now()
    time.sleep(int(wait_time.total_seconds()))

  r = requests.get(API_URL, params=params, headers=headers)

  if RATE_LIMIT:
    RATE_LIMIT_LAST_CALL = datetime.now()

  return r.json()
972146
def _get_query(self, order=None, filters=None):
        
        order = self._get_order(order)
        return self.posts.all().order_by(order)
401250
def search_anime(self, query):
        

        r = self._query_('/search/anime', 'GET',
                         params={'query': query})

        results = [Anime(item) for item in r.json()]
        return results
1133710
def query(self, titles, pageids=None, cparams=None):
        
        query = self.QUERY.substitute(
            WIKI=self.uri,
            ENDPOINT=self.endpoint,
            TITLES=safequote(titles) or pageids)
        status = titles or pageids

        if pageids and not titles:
            query = query.replace('&titles=', '&pageids=')

        if cparams:
            query += cparams
            status += " (%s)" % cparams

        if self.variant:
            query += '&variant=' + self.variant

        self.set_status('query', status)

        return query
1218025
def suggest(query):
  '''
  
  '''

  search_params = {
    'list': 'search',
    'srinfo': 'suggestion',
    'srprop': '',
  }
  search_params['srsearch'] = query

  raw_result = _wiki_request(search_params)

  if raw_result['query'].get('searchinfo'):
    return raw_result['query']['searchinfo']['suggestion']

  return None
1261929
def all(page = 1, limit = 100, latest = true)
      opts = connection.version == 2 ? {:unseen => latest} : {:latest => latest}
      connection.get(resource_uri, {:query => {:limit => limit, :page => page}.merge(opts)})
    end
346832
def all_resource_urls(query):
    '''  '''
    urls = []
    next = True
    while next:
        response = requests.get(query)
        json_data = json.loads(response.content)
        for resource in json_data['results']:
            urls.append(resource['url'])
        if bool(json_data['next']):
            query = json_data['next']
        else:
            next = False
    return urls
1136364
def query(options, collection_name, num_to_skip,
          num_to_return, query, field_selector, opts, check_keys=False):
    
    data = struct.pack("<I", options)
    data += bson._make_c_string(collection_name)
    data += struct.pack("<i", num_to_skip)
    data += struct.pack("<i", num_to_return)
    encoded = bson.BSON.encode(query, check_keys, opts)
    data += encoded
    max_bson_size = len(encoded)
    if field_selector is not None:
        encoded = bson.BSON.encode(field_selector, False, opts)
        data += encoded
        max_bson_size = max(len(encoded), max_bson_size)
    (request_id, query_message) = __pack_message(2004, data)
    return (request_id, query_message, max_bson_size)
1253750
def query_most(num=8, kind='1'):
        '''
        
        '''
        return TabWiki.select().where(
            TabWiki.kind == kind
        ).order_by(
            TabWiki.view_count.desc()
        ).limit(num)