本文整理汇总了Python中Tardis.Util.getTerminalSize方法的典型用法代码示例。如果您正苦于以下问题:Python Util.getTerminalSize方法的具体用法?Python Util.getTerminalSize怎么用?Python Util.getTerminalSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tardis.Util
的用法示例。
在下文中一共展示了Util.getTerminalSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: computeColumnWidth
# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import getTerminalSize [as 别名]
def computeColumnWidth(names):
"""
Given a list of names, compute the columns widths
"""
if len(list(names)) == 0:
return (1, '%s')
longestName = max(list(map(len, names)), default=0)
if args.columns:
columns = args.columns
else:
if os.isatty(sys.stdout.fileno()):
(_, width) = Util.getTerminalSize()
logger.debug("Setting width to %d", width)
width -= 2 # lop a couple characters off the end to avoid annoying wraps in some cases.
columns = int(width / (longestName + 4))
if columns == 0:
columns = 1
else:
columns = 1
fmt = "%%-%ds " % (longestName + 2)
logger.debug("Setting columns to %d", columns)
return (columns, fmt)
示例2: computeColumnWidth
# 需要导入模块: from Tardis import Util [as 别名]
# 或者: from Tardis.Util import getTerminalSize [as 别名]
def computeColumnWidth(names):
"""
Given a list of names, compute the columns widths
"""
if len(names) == 0:
return (1, '%s')
longestName = max(map(len, names))
if args.columns:
columns = args.columns
else:
if os.isatty(sys.stdout.fileno()):
_, width = Util.getTerminalSize()
width -= 2 # lop a couple characters off the end to avoid annoying wraps in some cases.
columns = width / (longestName + 4)
else:
columns = 1
fmt = "%%-%ds " % (longestName + 2)
return (columns, fmt)