本文整理汇总了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