当前位置: 首页>>代码示例>>Python>>正文


Python TextWrapper.break_on_hyphens方法代码示例

本文整理汇总了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))
开发者ID:handsomegui,项目名称:mpd-win32-build,代码行数:9,代码来源:buildtool.py

示例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)
开发者ID:ApachePointObservatory,项目名称:Totoro,代码行数:30,代码来源:logger.py

示例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)
开发者ID:JTumelty,项目名称:gff3toembl,代码行数:12,代码来源:EMBLContig.py

示例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
开发者ID:matt-hayden,项目名称:python-utilities,代码行数:13,代码来源:spss_functions.py

示例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
开发者ID:neishm,项目名称:pygeode,代码行数:24,代码来源:var.py

示例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
开发者ID:aerler,项目名称:pygeode,代码行数:25,代码来源:dataset.py

示例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)
开发者ID:handsomegui,项目名称:mpd-win32-build,代码行数:8,代码来源:buildtool.py


注:本文中的textwrap.TextWrapper.break_on_hyphens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。