本文整理匯總了Python中StringIO.StringIO.truncate方法的典型用法代碼示例。如果您正苦於以下問題:Python StringIO.truncate方法的具體用法?Python StringIO.truncate怎麽用?Python StringIO.truncate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類StringIO.StringIO
的用法示例。
在下文中一共展示了StringIO.truncate方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: truncate
# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import truncate [as 別名]
def truncate(self, size=None):
StringIO.truncate(self, size)
if hasattr(self, "softspace"):
del self.softspace
###########################################################################
# Update Runner
###########################################################################
示例2: _check_output
# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import truncate [as 別名]
def _check_output(self, example):
want = example.want
optionflags = self._get_optionflags(example)
got = sys.stdout.getvalue()
sys.stdout.truncate(0)
if not self.checker.check_output(want, got, optionflags):
self.runner.report_failure(self.save_stdout.write,
self.test, example, got)
return False
else:
return True
示例3: truncate
# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import truncate [as 別名]
def truncate(self, size=None):
StringIO.truncate(self, size)
if hasattr(self, "softspace"):
del self.softspace
# Worst-case linear-time ellipsis matching.
示例4: truncate
# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import truncate [as 別名]
def truncate(self, size=None):
StringIO.truncate(self, size)
if hasattr(self, "softspace"):
del self.softspace
if not self.buf:
# Reset it to an empty string, to make sure it's not unicode.
self.buf = ''
# Worst-case linear-time ellipsis matching.
示例5: _reset_buffer
# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import truncate [as 別名]
def _reset_buffer(self):
# For some reason calling StringIO.truncate() here will lead to
# inconsistent writes so just set _buffer to a new StringIO object.
self._buffer = StringIO()
self._len = 0
示例6: truncate
# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import truncate [as 別名]
def truncate(self, size=None):
StringIO.truncate(self, size)
if hasattr(self, "softspace"):
del self.softspace
###########################################################################
# MyParser
###########################################################################
示例7: _check_output
# 需要導入模塊: from StringIO import StringIO [as 別名]
# 或者: from StringIO.StringIO import truncate [as 別名]
def _check_output(self, example):
want = example.want
optionflags = self._get_optionflags(example)
got = sys.stdout.getvalue()
sys.stdout.truncate(0)
if not self.checker.check_output(want, got, optionflags):
self.runner.report_failure(self.save_stdout.write,
self.test, example, got)
return False
else:
return True