当前位置: 首页>>代码示例>>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;未经允许,请勿转载。