def __format_text(text):
try:
maxcol = os.get_terminal_size().columns
# piped output to file or other process
except OSError:
maxcol = sys.maxsize
ret = ""
for line in text.splitlines():
ios = io.StringIO()
writer = formatter.DumbWriter(ios, maxcol=maxcol)
writer.send_flowing_data(line)
ret = "{0}{1}\n".format(ret, ios.getvalue())
ios.close()
return ret
评论列表
文章目录