本文整理汇总了Python中PySide.QtCore.QUrl.queryItems方法的典型用法代码示例。如果您正苦于以下问题:Python QUrl.queryItems方法的具体用法?Python QUrl.queryItems怎么用?Python QUrl.queryItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QUrl
的用法示例。
在下文中一共展示了QUrl.queryItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAddQueryItem
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import queryItems [as 别名]
def testAddQueryItem(self):
#QUrl.addQueryItem
url = QUrl()
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))
示例2: testSetQueryItems
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import queryItems [as 别名]
def testSetQueryItems(self):
#QUrl.setQueryItems
urla = QUrl('http://www.google.com/search?q=python&hl=en')
urlb = QUrl('http://www.google.com/search')
urlb.setQueryItems(urla.queryItems())
self.assertEqual(urla, urlb)
示例3: _slot_httpResponseFinished
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import queryItems [as 别名]
def _slot_httpResponseFinished(self, reply):
"""
Slot for QWebView's QNetworkAccessManager finished signal.
@param reply (QNetworkReply)
"""
#print "REPLY::ERROR>> ", reply.error()
#print "REPLY::FINISHED>> ", self.url()
url = self.url()
# # -------------------------------------------------------------------------
#
# def _slot_urlChanged(self, url):
# """
# Slot for QWebView urlChanged signal.
#
# @param url (QUrl)
# """
# ---------------------------------------------------------------------
# PARSE URL DATA
# ---------------------------------------------------------------------
fragment = url.fragment()
path = url.path()
query_items = dict(url.queryItems())
fragment_items = []
if fragment:
qu = QUrl()
qu.setEncodedQuery(str(fragment))
fragment_items = qu.queryItems()
# push fragment values into query items dict
for i in fragment_items:
query_items[i[0]] = i[1]
state = ""
if "state" in query_items:
state = query_items["state"]
# ---------------------------------------------------------------------
# FIRE DESTINATION SIGNALS
# ---------------------------------------------------------------------
if "error" in query_items:
error_reason = ""
if "error_reason" in query_items:
reason = query_items["error_reason"]
error_description = ""
if "error_description" in query_items:
description = query_items["error_description"].replace("+"," ")
# user canceled before granting permissions
self.signal_permsNotAuthorized.emit(query_items["error"], reason,
description, state)
return
if path == "/login.php":
if "skip_api_login" in query_items:
# initial load of the login form
self.signal_authFormReady.emit(state)
return
elif "login_attempt" in query_items:
# user login credentials invalid
self.signal_authFail.emit(state)
return
elif path == "/dialog/permissions.request":
if "from_login" in query_items:
# user authenticated successfully
self.signal_authSuccess.emit(state)
return
elif path == "/connect/login_success.html":
if "access_token" in query_items:
access_token = query_items["access_token"]
expires_in = 0
if "expires_in" in query_items:
expires_in = int(query_items["expires_in"])
# permissions authorized and access token received
self.signal_permsAuthorizedAccessToken.emit(access_token,
expires_in, state)
return
elif "code" in query_items:
oauth_code = query_items["code"]
#.........这里部分代码省略.........
示例4: testQueryItems
# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import queryItems [as 别名]
def testQueryItems(self):
#QUrl.queryItems
url = QUrl('http://www.google.com/search?q=python&hl=en')
valid_data = [(('q'), ('python')), (('hl'), ('en'))]
self.assertEqual(sorted(url.queryItems()), sorted(valid_data))