本文整理汇总了Python中Text.Text.readString方法的典型用法代码示例。如果您正苦于以下问题:Python Text.readString方法的具体用法?Python Text.readString怎么用?Python Text.readString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text.Text
的用法示例。
在下文中一共展示了Text.readString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readFields
# 需要导入模块: from Text import Text [as 别名]
# 或者: from Text.Text import readString [as 别名]
def readFields(self, data_input):
count = data_input.readInt()
if count < 0:
raise IOError("Invalid size: %d for file metadata object" % count)
for i in xrange(count):
key = Text.readString(data_input)
value = Text.readString(data_input)
self._meta[key] = value
示例2: _initialize
# 需要导入模块: from Text import Text [as 别名]
# 或者: from Text.Text import readString [as 别名]
def _initialize(self, path, start, length):
self._stream = self.getStream(path)
if length == 0:
self._end = self._stream.getPos() + self._stream.length()
else:
self._end = self._stream.getPos() + length
# Parse Header
version_block = self._stream.read(len(VERSION))
self._version = version_block[len(VERSION_PREFIX)]
if not self._version.startswith(VERSION_PREFIX):
raise VersionPrefixException(VERSION_PREFIX,
self._version[0:len(VERSION_PREFIX)])
if self._version > VERSION[len(VERSION_PREFIX)]:
raise VersionMismatchException(VERSION[len(VERSION_PREFIX)],
self._version)
if self._version < BLOCK_COMPRESS_VERSION:
# Same as below, but with UTF8 Deprecated Class
raise NotImplementedError
else:
self._key_class_name = Text.readString(self._stream)
self._value_class_name = Text.readString(self._stream)
if ord(self._version) > 2:
self._decompress = self._stream.readBoolean()
else:
self._decompress = False
if self._version >= BLOCK_COMPRESS_VERSION:
self._block_compressed = self._stream.readBoolean()
else:
self._block_compressed = False
# setup compression codec
if self._decompress:
if self._version >= CUSTOM_COMPRESS_VERSION:
codec_class = Text.readString(self._stream)
self._codec = CodecPool().getDecompressor(codec_class)
else:
self._codec = CodecPool().getDecompressor()
self._metadata = Metadata()
if self._version >= VERSION_WITH_METADATA:
self._metadata.readFields(self._stream)
if self._version > 1:
self._sync = self._stream.read(SYNC_HASH_SIZE)
self._header_end = self._stream.getPos()