本文整理汇总了Python中PyQt5.QtCore.QByteArray.remove方法的典型用法代码示例。如果您正苦于以下问题:Python QByteArray.remove方法的具体用法?Python QByteArray.remove怎么用?Python QByteArray.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QByteArray
的用法示例。
在下文中一共展示了QByteArray.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FtpReply
# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import remove [as 别名]
class FtpReply(QNetworkReply):
"""
Class implementing a network reply for FTP resources.
"""
def __init__(self, url, accessHandler, parent=None):
"""
Constructor
@param url requested FTP URL (QUrl)
@param accessHandler reference to the access handler (FtpAccessHandler)
@param parent reference to the parent object (QObject)
"""
super(FtpReply, self).__init__(parent)
self.__manager = parent
self.__handler = accessHandler
self.__ftp = E5Ftp()
self.__items = []
self.__content = QByteArray()
self.__units = ["Bytes", "KB", "MB", "GB", "TB",
"PB", "EB", "ZB", "YB"]
self.__dirLineParser = FtpDirLineParser()
self.__fileBytesReceived = 0
if url.path() == "":
url.setPath("/")
self.setUrl(url)
# do proxy setup
if not Preferences.getUI("UseProxy"):
proxyType = E5FtpProxyType.NoProxy
else:
proxyType = Preferences.getUI("ProxyType/Ftp")
if proxyType != E5FtpProxyType.NoProxy:
self.__ftp.setProxy(
proxyType,
Preferences.getUI("ProxyHost/Ftp"),
Preferences.getUI("ProxyPort/Ftp"))
if proxyType != E5FtpProxyType.NonAuthorizing:
self.__ftp.setProxyAuthentication(
Preferences.getUI("ProxyUser/Ftp"),
Preferences.getUI("ProxyPassword/Ftp"),
Preferences.getUI("ProxyAccount/Ftp"))
QTimer.singleShot(0, self.__doFtpCommands)
def abort(self):
"""
Public slot to abort the operation.
"""
# do nothing
pass
def bytesAvailable(self):
"""
Public method to determined the bytes available for being read.
@return bytes available (integer)
"""
return self.__content.size()
def isSequential(self):
"""
Public method to check for sequential access.
@return flag indicating sequential access (boolean)
"""
return True
def readData(self, maxlen):
"""
Public method to retrieve data from the reply object.
@param maxlen maximum number of bytes to read (integer)
@return string containing the data (bytes)
"""
if self.__content.size():
len_ = min(maxlen, self.__content.size())
buffer = bytes(self.__content[:len_])
self.__content.remove(0, len_)
return buffer
def __doFtpCommands(self):
"""
Private slot doing the sequence of FTP commands to get the requested
result.
"""
retry = True
try:
username = self.url().userName()
password = self.url().password()
byAuth = False
while retry:
try:
self.__ftp.connect(self.url().host(),
self.url().port(ftplib.FTP_PORT),
timeout=10)
#.........这里部分代码省略.........
示例2: FileReply
# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import remove [as 别名]
class FileReply(QNetworkReply):
"""
Class implementing a network reply for directory resources.
"""
def __init__(self, url, parent=None):
"""
Constructor
@param url requested FTP URL (QUrl)
@param parent reference to the parent object (QObject)
"""
super(FileReply, self).__init__(parent)
self.__content = QByteArray()
self.__units = ["Bytes", "KB", "MB", "GB", "TB",
"PB", "EB", "ZB", "YB"]
if url.path() == "":
url.setPath("/")
self.setUrl(url)
QTimer.singleShot(0, self.__loadDirectory)
def abort(self):
"""
Public slot to abort the operation.
"""
# do nothing
pass
def bytesAvailable(self):
"""
Public method to determined the bytes available for being read.
@return bytes available (integer)
"""
return self.__content.size()
def isSequential(self):
"""
Public method to check for sequential access.
@return flag indicating sequential access (boolean)
"""
return True
def readData(self, maxlen):
"""
Public method to retrieve data from the reply object.
@param maxlen maximum number of bytes to read (integer)
@return string containing the data (bytes)
"""
if self.__content.size():
len_ = min(maxlen, self.__content.size())
buffer = bytes(self.__content[:len_])
self.__content.remove(0, len_)
return buffer
def __cssLinkClass(self, icon, size=32):
"""
Private method to generate a link class with an icon.
@param icon icon to be included (QIcon)
@param size size of the icon to be generated (integer)
@return CSS class string (string)
"""
cssString = \
"""a.{{0}} {{{{\n"""\
""" padding-left: {0}px;\n"""\
""" background: transparent url(data:image/png;base64,{1})"""\
""" no-repeat center left;\n"""\
""" font-weight: bold;\n"""\
"""}}}}\n"""
pixmap = icon.pixmap(size, size)
imageBuffer = QBuffer()
imageBuffer.open(QIODevice.ReadWrite)
if not pixmap.save(imageBuffer, "PNG"):
# write a blank pixmap on error
pixmap = QPixmap(size, size)
pixmap.fill(Qt.transparent)
imageBuffer.buffer().clear()
pixmap.save(imageBuffer, "PNG")
return cssString.format(
size + 4,
str(imageBuffer.buffer().toBase64(), encoding="ascii"))
def __loadDirectory(self):
"""
Private slot loading the directory and preparing the listing page.
"""
dir = QDir(self.url().toLocalFile())
dirItems = dir.entryInfoList(
QDir.AllEntries | QDir.Hidden | QDir.NoDotAndDotDot,
QDir.Name | QDir.DirsFirst)
u = self.url()
if not u.path().endswith("/"):
u.setPath(u.path() + "/")
#.........这里部分代码省略.........