本文整理匯總了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()