本文整理汇总了Python中mutagen.ogg.OggPage.packets方法的典型用法代码示例。如果您正苦于以下问题:Python OggPage.packets方法的具体用法?Python OggPage.packets怎么用?Python OggPage.packets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.ogg.OggPage
的用法示例。
在下文中一共展示了OggPage.packets方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_page_max_size
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets [as 别名]
def test_page_max_size(self):
page = OggPage()
page.packets = ["1" * 255 * 255]
page.complete = False
page2 = OggPage()
page2.packets = [""]
page2.sequence = 1
page2.continued = True
self.failUnlessEqual(["1" * 255 * 255], OggPage.to_packets([page, page2]))
示例2: test_packet_exactly_255
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets [as 别名]
def test_packet_exactly_255(self):
page = OggPage()
page.packets = [b"1" * 255]
page.complete = False
page2 = OggPage()
page2.packets = [b""]
page2.sequence = 1
page2.continued = True
self.failUnlessEqual([b"1" * 255], OggPage.to_packets([page, page2]))
示例3: test_read_max_size
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets [as 别名]
def test_read_max_size(self):
page = OggPage()
page.packets = [b"1" * 255 * 255]
page.complete = False
page2 = OggPage()
page2.packets = [b"", b"foo"]
page2.sequence = 1
page2.continued = True
data = page.write() + page2.write()
fileobj = BytesIO(data)
self.failUnlessEqual(OggPage(fileobj), page)
self.failUnlessEqual(OggPage(fileobj), page2)
self.failUnlessRaises(EOFError, OggPage, fileobj)
示例4: test_theora_bad_version
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets [as 别名]
def test_theora_bad_version(self):
page = OggPage(open(self.filename, "rb"))
packet = page.packets[0]
packet = packet[:7] + b"\x03\x00" + packet[9:]
page.packets = [packet]
fileobj = cBytesIO(page.write())
self.failUnlessRaises(IOError, OggTheoraInfo, fileobj)
示例5: test_crc_py25
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets [as 别名]
def test_crc_py25(self):
# Make sure page.write can handle both signed/unsigned int
# return values of crc32.
# http://code.google.com/p/mutagen/issues/detail?id=63
# http://docs.python.org/library/zlib.html#zlib.crc32
import zlib
old_crc = zlib.crc32
def zlib_uint(*args):
return (old_crc(*args) & 0xffffffff)
def zlib_int(*args):
return cdata.int_be(cdata.to_uint_be(old_crc(*args) & 0xffffffff))
try:
page = OggPage()
page.packets = [b"abc"]
zlib.crc32 = zlib_uint
uint_data = page.write()
zlib.crc32 = zlib_int
int_data = page.write()
finally:
zlib.crc32 = old_crc
self.failUnlessEqual(uint_data, int_data)
示例6: test_page_max_size_alone_too_big
# 需要导入模块: from mutagen.ogg import OggPage [as 别名]
# 或者: from mutagen.ogg.OggPage import packets [as 别名]
def test_page_max_size_alone_too_big(self):
page = OggPage()
page.packets = [b"1" * 255 * 255]
page.complete = True
self.failUnlessRaises(ValueError, page.write)