本文整理汇总了Python中PyQt5.QtCore.QUrlQuery.addQueryItem方法的典型用法代码示例。如果您正苦于以下问题:Python QUrlQuery.addQueryItem方法的具体用法?Python QUrlQuery.addQueryItem怎么用?Python QUrlQuery.addQueryItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QUrlQuery
的用法示例。
在下文中一共展示了QUrlQuery.addQueryItem方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: suggestionsUrl
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def suggestionsUrl(self, searchTerm):
"""
Public method to get a URL ready for suggestions.
@param searchTerm term to search for (string)
@return URL (QUrl)
"""
if not self._suggestionsUrlTemplate:
return QUrl()
ret = QUrl.fromEncoded(QByteArray(self.parseTemplate(
searchTerm, self._suggestionsUrlTemplate).encode("utf-8")))
if self.__searchMethod != "post":
if qVersion() >= "5.0.0":
from PyQt5.QtCore import QUrlQuery
urlQuery = QUrlQuery(ret)
for parameter in self._suggestionsParameters:
urlQuery.addQueryItem(
parameter[0],
self.parseTemplate(searchTerm, parameter[1]))
ret.setQuery(urlQuery)
else:
for parameter in self._suggestionsParameters:
ret.addQueryItem(
parameter[0],
self.parseTemplate(searchTerm, parameter[1]))
return ret
示例2: test_file_pathsep
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def test_file_pathsep(self, sep):
url = QUrl('qute://pdfjs/file')
query = QUrlQuery()
query.addQueryItem('filename', 'foo{}bar'.format(sep))
url.setQuery(query)
with pytest.raises(qutescheme.RequestDeniedError):
qutescheme.data_for_url(url)
示例3: getHttp
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def getHttp(self, uri, params):
QgsApplication.setOverrideCursor(Qt.WaitCursor)
try:
rq = QUrl(uri)
q = QUrlQuery()
for (k, v) in params.items():
q.addQueryItem(k, v)
rq.setQuery(q)
req = QNetworkRequest(rq)
try:
reply = self.nominatim_networkAccessManager.blockingGet(req)
resource = reply.content().data().decode('utf8')
r = json.loads(resource)
if (isinstance(r, list)):
self.populateTable(r)
else:
self.populateTable([r])
except:
self.tableResult.clearContents()
finally:
QgsApplication.restoreOverrideCursor()
示例4: get_main_url
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def get_main_url(filename):
"""Get the URL to be opened to view a local PDF."""
url = QUrl('qute://pdfjs/web/viewer.html')
query = QUrlQuery()
query.addQueryItem('filename', filename) # read from our JS
query.addQueryItem('file', '') # to avoid pdfjs opening the default PDF
url.setQuery(query)
return url
示例5: email
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def email(subject, body):
"""Opens the e-mail composer with the given subject and body, with version information added to it."""
subject = "[{0} {1}] {2}".format(appinfo.appname, appinfo.version, subject)
body = "{0}\n\n{1}\n\n".format(debuginfo.version_info_string(' -- '), body)
url = QUrl("mailto:" + appinfo.maintainer_email)
query = QUrlQuery()
query.addQueryItem("subject", subject)
query.addQueryItem("body", body)
url.setQuery(query)
helpers.openUrl(url, "email")
示例6: load_account_page
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def load_account_page(self, account, tab=None, task=None, reset_history=False, set_home=False):
self.tab = tab
self.task = task
self.account = account
url = QUrl(account.server.settings_url)
url_query = QUrlQuery()
for name, value in self.query_items:
url_query.addQueryItem(name, value)
url.setQuery(url_query)
if set_home:
self.homepage = url
if reset_history:
self.history().clear()
self.page().mainFrame().evaluateJavaScript('window.location.replace("{}");'.format(url.toString())) # this will replace the current url in the history
else:
self.load(url)
示例7: exchange_authorization_code
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def exchange_authorization_code(self, authorization_code, scopes, callback):
log.debug("OAuth: exchanging authorization_code %s for an access_token", authorization_code)
host, port = config.setting['server_host'], config.setting['server_port']
path = "/oauth2/token"
url = QUrl()
url_query = QUrlQuery()
url_query.addQueryItem("grant_type", "authorization_code")
url_query.addQueryItem("code", authorization_code)
url_query.addQueryItem("client_id", MUSICBRAINZ_OAUTH_CLIENT_ID)
url_query.addQueryItem("client_secret", MUSICBRAINZ_OAUTH_CLIENT_SECRET)
url_query.addQueryItem("redirect_uri", "urn:ietf:wg:oauth:2.0:oob")
url.setQuery(url_query.query(QUrl.FullyEncoded))
data = string_(url.query())
self.webservice.post(host, port, path, data,
partial(self.on_exchange_authorization_code_finished, scopes, callback),
parse_response_type=None, mblogin=True, priority=True, important=True)
示例8: loadMessages
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def loadMessages(self, skip=None, beforeId=None, afterId=None, limit=50):
logger.debug("listMessages")
url = QUrl(
GITTER_API + "/rooms/{}/chatMessages".format(self.id)
)
query = QUrlQuery()
if skip:
query.addQueryItem("skip", str(skip))
if beforeId:
query.addQueryItem("beforeId", str(beforeId))
if afterId:
query.addQueryItem("afterId", str(afterId))
elif self._messages.last_id:
query.addQueryItem("afterId", str(self._messages.last_id()))
if limit:
query.addQueryItem("limit", str(limit))
url.setQuery(query)
req = makeRequest(url, self._auth)
reply = self._net.get(req)
reply.finished.connect(lambda: self.readMessages(reply))
示例9: _generate_pdfjs_script
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def _generate_pdfjs_script(filename):
"""Generate the script that shows the pdf with pdf.js.
Args:
filename: The name of the file to open.
"""
url = QUrl('qute://pdfjs/file')
url_query = QUrlQuery()
url_query.addQueryItem('filename', filename)
url.setQuery(url_query)
return jinja.js_environment.from_string("""
document.addEventListener("DOMContentLoaded", function() {
if (typeof window.PDFJS !== 'undefined') {
// v1.x
{% if disable_create_object_url %}
window.PDFJS.disableCreateObjectURL = true;
{% endif %}
window.PDFJS.verbosity = window.PDFJS.VERBOSITY_LEVELS.info;
} else {
// v2.x
const options = window.PDFViewerApplicationOptions;
{% if disable_create_object_url %}
options.set('disableCreateObjectURL', true);
{% endif %}
options.set('verbosity', pdfjsLib.VerbosityLevel.INFOS);
}
const viewer = window.PDFView || window.PDFViewerApplication;
viewer.open({{ url }});
});
""").render(
url=javascript.to_js(url.toString(QUrl.FullyEncoded)),
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-70420
disable_create_object_url=(
not qtutils.version_check('5.12') and
not qtutils.version_check('5.7.1', exact=True, compiled=False) and
objects.backend == usertypes.Backend.QtWebEngine))
示例10: exceptHook
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def exceptHook(type_, value, tback):
stack = ''.join(traceback.format_exception(type_, value, tback))
title = QApplication.translate("ExcpHook", "System error")
text = QApplication.translate("ExcpHook",
"A system error occurred.\n"
"Do you want to send an error message to the author?")
msgBox = QMessageBox(QMessageBox.Information, title, text)
msgBox.setDetailedText(stack)
msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
if msgBox.exec_() == QMessageBox.Yes:
line = traceback.extract_tb(tback)[-1]
subject = "[v%s] %s - %s:%d" % (version.Version, type_.__name__,
line[0], line[1])
errorMessage = []
# errorMessage.append(QApplication.translate(
# "ExcpHook",
# "PLEASE ADD A COMMENT, IT WILL HELP IN SOLVING THE PROBLEM"))
# errorMessage.append('')
errorMessage.append("%s: %s" % (version.AppName, version.Version))
errorMessage.append("OS: %s %s (%s)" % (platform.system(),
platform.release(),
platform.version()))
errorMessage.append("Python: %s (%s)" % (platform.python_version(),
platform.architecture()[0]))
errorMessage.append("Qt: %s" % PYQT_VERSION_STR)
try:
errorMessage.append("Locale: %s" % Settings()['locale'])
except:
pass
errorMessage.append('')
errorMessage.append(stack)
url = QUrl('http://opennumismat.idea.informer.com/proj/')
query = QUrlQuery()
query.addQueryItem('mod', 'add')
query.addQueryItem('cat', '3')
query.addQueryItem('idea', subject)
query.addQueryItem('descr', '\n'.join(errorMessage))
url.setQuery(query)
executor = QDesktopServices()
executor.openUrl(url)
# Call the default handler
sys.__excepthook__(type_, value, tback)
示例11: exceptHook
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def exceptHook(type_, value, tback):
stack = ''.join(traceback.format_exception(type_, value, tback))
title = QApplication.translate("ExcpHook", "System error")
text = QApplication.translate("ExcpHook",
"A system error occurred.\n"
"Do you want to send an error message to the author\n"
"(Google account required)?")
msgBox = QMessageBox(QMessageBox.Information, title, text)
msgBox.setDetailedText(stack)
msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
if msgBox.exec_() == QMessageBox.Yes:
line = traceback.extract_tb(tback, 1)[0]
subject = "[v%s] %s - %s:%d" % (version.Version, type_.__name__,
line[0], line[1])
errorMessage = []
errorMessage.append("%s: %s" % (version.AppName, version.Version))
errorMessage.append("OS: %s %s %s (%s)" % (platform.system(),
platform.release(),
platform.architecture()[0],
platform.version()))
errorMessage.append("Python: %s" % platform.python_version())
errorMessage.append("Qt: %s" % PYQT_VERSION_STR)
errorMessage.append('')
errorMessage.append(stack)
url = QUrl('https://code.google.com/p/open-numismat/issues/entry')
query = QUrlQuery()
query.addQueryItem('summary', subject)
query.addQueryItem('comment', '\n'.join(errorMessage))
url.setQuery(query)
executor = QDesktopServices()
executor.openUrl(url)
# Call the default handler
sys.__excepthook__(type_, value, tback)
示例12: refresh_access_token
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def refresh_access_token(self, callback):
refresh_token = config.persist["oauth_refresh_token"]
log.debug("OAuth: refreshing access_token with a refresh_token %s", refresh_token)
host, port = config.setting['server_host'], config.setting['server_port']
path = "/oauth2/token"
url = QUrl()
url_query = QUrlQuery()
url_query.addQueryItem("grant_type", "refresh_token")
url_query.addQueryItem("refresh_token", refresh_token)
url_query.addQueryItem("client_id", MUSICBRAINZ_OAUTH_CLIENT_ID)
url_query.addQueryItem("client_secret", MUSICBRAINZ_OAUTH_CLIENT_SECRET)
url.setQuery(url_query.query(QUrl.FullyEncoded))
data = string_(url.query())
self.webservice.post(host, port, path, data,
partial(self.on_refresh_access_token_finished, callback),
parse_response_type=None, mblogin=True, priority=True, important=True)
示例13: _sendRequest
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def _sendRequest(self, url, params, headers={}):
if self.asynchonous:
if self.reply is not None:
self.reply.finished.disconnect(self.reply_finished)
self.reply.abort()
self.reply = None
url = QUrl(url)
q = QUrlQuery(url)
for key, value in params.items():
q.addQueryItem(key, value)
url.setQuery(q)
QgsLogger.debug('Request: {}'.format(url.toEncoded()))
request = QNetworkRequest(url)
for key, value in headers.items():
request.setRawHeader(key, value)
self.reply = QgsNetworkAccessManager.instance().get(request)
self.reply.finished.connect(self.reply_finished)
else:
response = urlopen(self.url + '?' + urllib.urlencode(params))
data = json.load(response)
self.load_data(data)
示例14: encode_uri
# 需要导入模块: from PyQt5.QtCore import QUrlQuery [as 别名]
# 或者: from PyQt5.QtCore.QUrlQuery import addQueryItem [as 别名]
def encode_uri(ds_uri, schema_name, project_name=None):
u = QUrl()
urlQuery = QUrlQuery()
u.setScheme("postgresql")
u.setHost(ds_uri.host())
if ds_uri.port() != '':
u.setPort(int(ds_uri.port()))
if ds_uri.username() != '':
u.setUserName(ds_uri.username())
if ds_uri.password() != '':
u.setPassword(ds_uri.password())
if ds_uri.service() != '':
urlQuery.addQueryItem("service", ds_uri.service())
if ds_uri.authConfigId() != '':
urlQuery.addQueryItem("authcfg", ds_uri.authConfigId())
if ds_uri.sslMode() != QgsDataSourceUri.SslPrefer:
urlQuery.addQueryItem("sslmode", QgsDataSourceUri.encodeSslMode(ds_uri.sslMode()))
urlQuery.addQueryItem("dbname", ds_uri.database())
urlQuery.addQueryItem("schema", schema_name)
if project_name:
urlQuery.addQueryItem("project", project_name)
u.setQuery(urlQuery)
return str(u.toEncoded(), 'utf-8')