本文整理汇总了Python中textwrap.TextWrapper.break_on_hyphens方法的典型用法代码示例。如果您正苦于以下问题:Python TextWrapper.break_on_hyphens方法的具体用法?Python TextWrapper.break_on_hyphens怎么用?Python TextWrapper.break_on_hyphens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类textwrap.TextWrapper
的用法示例。
在下文中一共展示了TextWrapper.break_on_hyphens方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrap_for_make
# 需要导入模块: from textwrap import TextWrapper [as 别名]
# 或者: from textwrap.TextWrapper import break_on_hyphens [as 别名]
def wrap_for_make(items):
line = join(sorted(items))
wrapper = TextWrapper()
wrapper.width = 60
wrapper.break_on_hyphens = False
wrapper.subsequent_indent = '\t' * 2
return ' \\\n'.join(wrapper.wrap(line))
示例2: _stream_formatter
# 需要导入模块: from textwrap import TextWrapper [as 别名]
# 或者: from textwrap.TextWrapper import break_on_hyphens [as 别名]
def _stream_formatter(self, record):
"""The formatter for standard output."""
if record.levelno < logging.DEBUG:
print(record.levelname, end='')
elif(record.levelno < logging.INFO):
colourPrint(record.levelname, 'green', end='')
elif(record.levelno < IMPORTANT):
colourPrint(record.levelname, 'magenta', end='')
elif(record.levelno < logging.WARNING):
colourPrint(record.levelname, 'lightblue', end='')
elif(record.levelno < logging.ERROR):
colourPrint(record.levelname, 'brown', end='')
else:
colourPrint(record.levelname, 'red', end='')
if record.levelno == logging.WARN:
message = '{0}'.format(record.msg[record.msg.find(':')+2:])
else:
message = '{0}'.format(record.msg)
if len(message) > self.wrapperLength:
tw = TextWrapper()
tw.width = self.wrapperLength
tw.subsequent_indent = ' ' * (len(record.levelname)+2)
tw.break_on_hyphens = False
message = '\n'.join(tw.wrap(message))
print(': ' + message)
示例3: product_attribute_formatter
# 需要导入模块: from textwrap import TextWrapper [as 别名]
# 或者: from textwrap.TextWrapper import break_on_hyphens [as 别名]
def product_attribute_formatter(self, key, value):
# Products can include very long enzyme names which we don't want to break
wrapper = TextWrapper()
wrapper.initial_indent='FT '
wrapper.subsequent_indent='FT '
wrapper.width=79
wrapper.break_on_hyphens=True
attribute_text_template='/{attribute_key}="{attribute_value}"'
attribute_text=attribute_text_template.format(attribute_key=key, attribute_value=value)
return wrapper.fill(attribute_text)
示例4: linewrap
# 需要导入模块: from textwrap import TextWrapper [as 别名]
# 或者: from textwrap.TextWrapper import break_on_hyphens [as 别名]
def linewrap(width = None):
"""Returns a function that wraps long lines to a max of 251 characters.
Note that this function returns a list of lines, which is suitable as the
argument for the spss.Submit function.
"""
wrapper = TextWrapper()
wrapper.width = width or 251
wrapper.replace_whitespace = True
wrapper.break_long_words = False
wrapper.break_on_hyphens = False
return wrapper.wrap
示例5: __str__
# 需要导入模块: from textwrap import TextWrapper [as 别名]
# 或者: from textwrap.TextWrapper import break_on_hyphens [as 别名]
def __str__ (self):
# {{{
from textwrap import TextWrapper
# axes_list = '(' + ', '.join(a.name if a.name != '' else repr(a) for a in self.axes) + ')'
# axes_details = ''.join([' '+str(a) for a in self.axes])
# s = repr(self) + ':\n\n axes: ' + axes_list + '\n shape: ' + str(self.shape) + '\n\n' + axes_details
s = repr(self) + ':\n'
if self.units != '':
s += ' Units: ' + self.units
s += ' Shape:'
s += ' (' + ','.join(a.name for a in self.axes) + ')'
s += ' (' + ','.join(str(len(a)) for a in self.axes) + ')\n'
s += ' Axes:\n'
for a in self.axes:
s += ' '+str(a) + '\n'
w = TextWrapper(width=80)
w.initial_indent = w.subsequent_indent = ' '
w.break_on_hyphens = False
s += ' Attributes:\n' + w.fill(str(self.atts)) + '\n'
s += ' Type: %s (dtype="%s")' % (self.__class__.__name__, self.dtype.name)
return s
示例6: __str__
# 需要导入模块: from textwrap import TextWrapper [as 别名]
# 或者: from textwrap.TextWrapper import break_on_hyphens [as 别名]
def __str__ (self):
from textwrap import TextWrapper
# Degenerate case - no variables??
if len(self.vars) == 0:
return '<empty Dataset>'
lines = list(self.__str_vararr__())
pad1 = max(len(a[0]) for a in lines) + 1
pad2 = max(len(a[1]) for a in lines) + 1
s = '<' + self.__class__.__name__ + '>:\n'
s = s + 'Vars:\n'
for name,dims,shape in lines:
s = s + ' ' + name.ljust(pad1) + dims.ljust(pad2) + shape + '\n'
s = s + 'Axes:\n ' + ' '.join([str(a)+'\n' for a in self.axes])
w = TextWrapper(width=80)
w.initial_indent = w.subsequent_indent = ' '
w.break_on_hyphens = False
s = s + 'Global Attributes:\n' + w.fill(str(self.atts))
return s
示例7: wrap_for_usage
# 需要导入模块: from textwrap import TextWrapper [as 别名]
# 或者: from textwrap.TextWrapper import break_on_hyphens [as 别名]
def wrap_for_usage(prefix, items):
line = prefix + join(sorted(items))
wrapper = TextWrapper()
wrapper.break_on_hyphens = False
wrapper.subsequent_indent = ' ' * len(prefix)
return wrapper.fill(line)