當前位置: 首頁>>代碼示例>>Python>>正文


Python binascii.Incomplete方法代碼示例

本文整理匯總了Python中binascii.Incomplete方法的典型用法代碼示例。如果您正苦於以下問題:Python binascii.Incomplete方法的具體用法?Python binascii.Incomplete怎麽用?Python binascii.Incomplete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在binascii的用法示例。


在下文中一共展示了binascii.Incomplete方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: read

# 需要導入模塊: import binascii [as 別名]
# 或者: from binascii import Incomplete [as 別名]
def read(self, totalwtd):
        """Read at least wtd bytes (or until EOF)"""
        decdata = ''
        wtd = totalwtd
        #
        # The loop here is convoluted, since we don't really now how
        # much to decode: there may be newlines in the incoming data.
        while wtd > 0:
            if self.eof: return decdata
            wtd = ((wtd+2)//3)*4
            data = self.ifp.read(wtd)
            #
            # Next problem: there may not be a complete number of
            # bytes in what we pass to a2b. Solve by yet another
            # loop.
            #
            while 1:
                try:
                    decdatacur, self.eof = \
                            binascii.a2b_hqx(data)
                    break
                except binascii.Incomplete:
                    pass
                newdata = self.ifp.read(1)
                if not newdata:
                    raise Error, \
                          'Premature EOF on binhex file'
                data = data + newdata
            decdata = decdata + decdatacur
            wtd = totalwtd - len(decdata)
            if not decdata and not self.eof:
                raise Error, 'Premature EOF on binhex file'
        return decdata 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:35,代碼來源:binhex.py

示例2: test_exceptions

# 需要導入模塊: import binascii [as 別名]
# 或者: from binascii import Incomplete [as 別名]
def test_exceptions(self):
        # Check module exceptions
        self.assertTrue(issubclass(binascii.Error, Exception))
        self.assertTrue(issubclass(binascii.Incomplete, Exception)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_binascii.py

示例3: read

# 需要導入模塊: import binascii [as 別名]
# 或者: from binascii import Incomplete [as 別名]
def read(self, totalwtd):
        """Read at least wtd bytes (or until EOF)"""
        decdata = b''
        wtd = totalwtd
        #
        # The loop here is convoluted, since we don't really now how
        # much to decode: there may be newlines in the incoming data.
        while wtd > 0:
            if self.eof: return decdata
            wtd = ((wtd + 2) // 3) * 4
            data = self.ifp.read(wtd)
            #
            # Next problem: there may not be a complete number of
            # bytes in what we pass to a2b. Solve by yet another
            # loop.
            #
            while True:
                try:
                    decdatacur, self.eof = binascii.a2b_hqx(data)
                    break
                except binascii.Incomplete:
                    pass
                newdata = self.ifp.read(1)
                if not newdata:
                    raise Error('Premature EOF on binhex file')
                data = data + newdata
            decdata = decdata + decdatacur
            wtd = totalwtd - len(decdata)
            if not decdata and not self.eof:
                raise Error('Premature EOF on binhex file')
        return decdata 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:33,代碼來源:binhex.py

示例4: base64ToString

# 需要導入模塊: import binascii [as 別名]
# 或者: from binascii import Incomplete [as 別名]
def base64ToString(s):
    try:
        return base64.decodestring(s)
    except binascii.Error as e:
        raise SyntaxError(e)
    except binascii.Incomplete as e:
        raise SyntaxError(e) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:9,代碼來源:cryptomath.py

示例5: test_exceptions

# 需要導入模塊: import binascii [as 別名]
# 或者: from binascii import Incomplete [as 別名]
def test_exceptions(self):
        # Check module exceptions
        self.assert_(issubclass(binascii.Error, Exception))
        self.assert_(issubclass(binascii.Incomplete, Exception)) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:6,代碼來源:test_binascii.py


注:本文中的binascii.Incomplete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。