本文整理汇总了Python中PyQt5.QtCore.QByteArray.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Python QByteArray.isEmpty方法的具体用法?Python QByteArray.isEmpty怎么用?Python QByteArray.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QByteArray
的用法示例。
在下文中一共展示了QByteArray.isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AdBlockSubscription
# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import isEmpty [as 别名]
#.........这里部分代码省略.........
"""
if url == self.location():
return
self.__location = url.toEncoded()
self.__lastUpdate = QDateTime()
self.changed.emit()
def requiresLocation(self):
"""
Public method to get the location of a required subscription.
@return location of a required subscription (string)
"""
return self.__requiresLocation
def lastUpdate(self):
"""
Public method to get the date and time of the last update.
@return date and time of the last update (QDateTime)
"""
return self.__lastUpdate
def rulesFileName(self):
"""
Public method to get the name of the rules file.
@return name of the rules file (string)
"""
if self.location().scheme() == "file":
return self.location().toLocalFile()
if self.__location.isEmpty():
return ""
sha1 = bytes(QCryptographicHash.hash(
self.__location, QCryptographicHash.Sha1).toHex()).decode()
dataDir = os.path.join(
Utilities.getConfigDir(), "browser", "subscriptions")
if not os.path.exists(dataDir):
os.makedirs(dataDir)
fileName = os.path.join(
dataDir, "adblock_subscription_{0}".format(sha1))
return fileName
def __loadRules(self):
"""
Private method to load the rules of the subscription.
"""
fileName = self.rulesFileName()
f = QFile(fileName)
if f.exists():
if not f.open(QIODevice.ReadOnly):
E5MessageBox.warning(
None,
self.tr("Load subscription rules"),
self.tr(
"""Unable to open adblock file '{0}' for reading.""")
.format(fileName))
else:
textStream = QTextStream(f)
header = textStream.readLine(1024)
if not header.startswith("[Adblock"):
E5MessageBox.warning(
None,