本文整理汇总了Python中six.StringIO.endswith方法的典型用法代码示例。如果您正苦于以下问题:Python StringIO.endswith方法的具体用法?Python StringIO.endswith怎么用?Python StringIO.endswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.StringIO
的用法示例。
在下文中一共展示了StringIO.endswith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __str__
# 需要导入模块: from six import StringIO [as 别名]
# 或者: from six.StringIO import endswith [as 别名]
def __str__(self):
self.parse()
contents = StringIO()
for (line_type, components) in self._contents:
if line_type == 'blank':
contents.write("%s\n" % (components[0]))
elif line_type == 'all_comment':
contents.write("%s\n" % (components[0]))
elif line_type == 'hostname':
(hostname, tail) = components
contents.write("%s%s\n" % (hostname, tail))
# Ensure trailing newline
contents = contents.getvalue()
if not contents.endswith("\n"):
contents += "\n"
return contents
示例2: error_msg
# 需要导入模块: from six import StringIO [as 别名]
# 或者: from six.StringIO import endswith [as 别名]
def error_msg(debugger_args):
"""Error has been caught and we were given chance to report it"""
debug_no, params = parse_args(debugger_args)
if debug_no == '3':
exc_info = sys.exc_info()
if exc_info[0]:
exception_data = StringIO()
traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], None, exception_data)
exception_data = exception_data.getvalue()
if exception_data.endswith('\n'):
exception_data = exception_data[:-1]
#pydev is truncating data (no help printing in loop)
sys.stderr.write('\n\n...')
sys.stderr.write(exception_data[-600:])
sys.stderr.write('\n\n')