def __get_bugs_by_search()

in libmozdata/bugzilla.py [0:0]


    def __get_bugs_by_search(self):
        """Get the bugs in making a search query"""
        url = Bugzilla.API_URL + "?"
        header = self.get_header()
        specials = {"count_only", "limit", "order", "offset"}
        for query in self.bugids:
            if isinstance(query, six.string_types):
                url = Bugzilla.API_URL + "?" + query
                self.bugs_results.append(
                    self.session.get(
                        url,
                        headers=header,
                        verify=True,
                        timeout=self.TIMEOUT,
                        hooks={"response": self.__bugs_cb},
                    )
                )
            elif specials.isdisjoint(query.keys()):
                url = Bugzilla.API_URL
                params = query.copy()
                params["count_only"] = 1
                r = requests.get(
                    url,
                    params=params,
                    headers=header,
                    verify=True,
                    timeout=self.TIMEOUT,
                )
                if r.ok:
                    count = r.json()["bug_count"]
                    del params["count_only"]
                    params["limit"] = Bugzilla.BUGZILLA_CHUNK_SIZE
                    params["order"] = "bug_id"
                    for i in range(0, count, Bugzilla.BUGZILLA_CHUNK_SIZE):
                        # Batch the execution to avoid timeouts
                        params = params.copy()
                        params["offset"] = i
                        self.bugs_results.append(
                            self.session.get(
                                url,
                                params=params,
                                headers=header,
                                verify=True,
                                timeout=self.TIMEOUT,
                                hooks={"response": self.__bugs_cb},
                            )
                        )
            else:
                self.bugs_results.append(
                    self.session.get(
                        url,
                        params=query,
                        headers=header,
                        verify=True,
                        timeout=self.TIMEOUT,
                        hooks={"response": self.__bugs_cb},
                    )
                )