コード例 #1
0
    def testAddRemove(self):
        query = QUrlQuery()

        query.addQueryItem("a", "b");
        self.assertTrue(not query.isEmpty())
        self.assertTrue(query.hasQueryItem("a"))
        self.assertEqual(query.queryItemValue("a"), "b")
        self.assertEqual(query.allQueryItemValues("a"), ["b"])
コード例 #2
0
 def build_request(self, query_items):
     query = QUrlQuery()
     for k, v in query_items.items():
         query.addQueryItem(k, v)
     url = QUrl(self.base_url)
     url.setQuery(query)
     request = QNetworkRequest(self.base_request)
     request.setUrl(url)
     return request
コード例 #3
0
ファイル: qurl_test.py プロジェクト: zwadar/pyside-setup
    def testAddQueryItem(self):
        url = QUrlQuery()
        valid_data = [('hl', 'en'), ('user', 'konqui')]

        url.addQueryItem(*valid_data[0])
        self.assertEqual(url.queryItems()[0], valid_data[0])

        url.addQueryItem(*valid_data[1])
        self.assertEqual(sorted(url.queryItems()), sorted(valid_data))
コード例 #4
0
ファイル: qurl_test.py プロジェクト: zwadar/pyside-setup
    def testAllQueryItemsValues(self):
        url = QUrlQuery()
        key = 'key'
        valid_data = ['data', 'valid', 'test']

        for i, data in enumerate(valid_data):
            url.addQueryItem(key, data)
            self.assertEqual(url.allQueryItemValues(key),
                             list(valid_data[:i + 1]))
コード例 #5
0
 def time_by_city(self, city: str) -> None:
     url = QUrl(WeatherDate.BASE_URL)
     query = QUrlQuery()
     query.addQueryItem("q", city)
     query.addQueryItem("appid", self.api_key)
     url.setQuery(query)
     request = QtNetwork.QNetworkRequest(url)
     reply: QtNetwork.QNetworkReply = self.manager.get(request)
     reply.finished.connect(self.tim)
コード例 #6
0
    def update_by_city(self, city: str):

        url = QUrl(WeatherWrapper.BASE_URL)
        query = QUrlQuery()
        query.addQueryItem("q", city)
        query.addQueryItem("appid", self.api_key)
        url.setQuery(query)

        request = QtNetwork.QNetworkRequest(url)
        reply: QtNetwork.QNetworkReply = self.manager.get(request)
        reply.finished.connect(self._handle_reply)