1 from __future__
import print_function
6 from functools
import reduce
9 A simple word-wrap function that wraps text on exactly width characters. 10 It doesn't split the text in words. 12 return '\n'.
join([ text[width*i:width*(i+1)] \
13 for i
in xrange(
int(math.ceil(1.*len(text)/width))) ])
17 A word-wrap function that preserves existing line breaks 18 and most spaces in the text. Expects that existing line 19 breaks are posix newlines (\n). 21 return reduce(
lambda line, word, width=width:
'%s%s%s' %
23 ' \n'[(len(line[line.rfind(
'\n')+1:])
24 + len(word.split(
'\n',1)[0]
31 Similar to wrap_onspace, but enforces the width constraint: 32 words longer than width are split. 34 wordRegex = re.compile(
r'\S{'+
str(width)+
r',}')
37 if __name__ ==
'__main__':
def wrap_onspace(text, width)
def wrap_always(text, width)
S & print(S &os, JobReport::InputFile const &f)
def wrap_onspace_strict(text, width)
static std::string join(char **cmd)