本文整理汇总了Python中PyQt5.Qt.QUrl.path方法的典型用法代码示例。如果您正苦于以下问题:Python QUrl.path方法的具体用法?Python QUrl.path怎么用?Python QUrl.path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QUrl
的用法示例。
在下文中一共展示了QUrl.path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_rule
# 需要导入模块: from PyQt5.Qt import QUrl [as 别名]
# 或者: from PyQt5.Qt.QUrl import path [as 别名]
def process_rule(self, rule, is_ancestor, maximum_specificities):
selector = rule['selector']
sheet_index = rule['sheet_index']
rule_address = rule['rule_address'] or ()
if selector is not None:
try:
specificity = [0] + list(parse(selector)[0].specificity())
except (AttributeError, TypeError, SelectorError):
specificity = [0, 0, 0, 0]
else: # style attribute
specificity = [1, 0, 0, 0]
specificity.extend((sheet_index, tuple(rule_address)))
ancestor_specificity = 0 if is_ancestor else 1
properties = []
for prop in rule['properties']:
important = 1 if prop[-1] == 'important' else 0
p = Property(prop, [ancestor_specificity] + [important] + specificity)
properties.append(p)
if p.specificity > maximum_specificities.get(p.name, (0,0,0,0,0,0)):
maximum_specificities[p.name] = p.specificity
rule['properties'] = properties
href = rule['href']
if hasattr(href, 'startswith') and href.startswith('%s://%s' % (FAKE_PROTOCOL, FAKE_HOST)):
qurl = QUrl(href)
name = qurl.path()[1:]
if name:
rule['href'] = name
示例2: set_message
# 需要导入模块: from PyQt5.Qt import QUrl [as 别名]
# 或者: from PyQt5.Qt.QUrl import path [as 别名]
def set_message(self, text, color_, bold=False, is_permanent=False):
from vise.view import certificate_error_domains
key = (text, color_.name(), bold, is_permanent)
if key == self.current_key:
return
self.current_key = key
self.is_permanent = is_permanent
prefix = text.partition(':')[0]
self.is_address = self.is_permanent and prefix.lower() in {'http', 'https', 'vise'}
self.is_secure = prefix.lower() in {'https', 'vise'}
color_ = color_ or self.palette().color(self.palette().WindowText)
if self.is_address:
qurl = QUrl(text)
if self.is_secure and qurl.host() in certificate_error_domains:
self.is_secure = False
if qurl.scheme() == 'vise':
host = qurl.path()
rest = ''
sep = ':'
else:
host = qurl.host()
rest = qurl.toDisplayString(QUrl.PrettyDecoded | QUrl.RemoveScheme | QUrl.RemoveAuthority)
sep = '://'
self.static_text = QStaticText(
'<span style="white-space:nowrap; color: {fg}">'
'<span style="color:{emph}; font-weight:bold">{scheme}</span><span style="color:{dull}">{sep}</span>'
'<span style="color:{fg}">{host}</span>'
'<span style="color:{dull}">{rest}</span>'.format(
fg=color_.name(), emph='green' if self.is_secure else 'red', scheme=escape(qurl.scheme()),
host=escape(host), dull=color('status bar dull foreground', 'gray'), sep=sep,
rest=escape(rest)
))
else:
self.static_text = QStaticText('<span style="color:{}; font-weight: {}; white-space:nowrap">{}</span>'.format(
color_.name(), ('bold' if bold else 'normal'), escape(text)))
to = QTextOption(Qt.AlignLeft | Qt.AlignTop)
to.setWrapMode(to.NoWrap)
self.static_text.setTextOption(to)
self.static_text.prepare(font=self.font())
self.update()