+ @staticmethod
+ def list_rewrap_p(msg):
+ return len(MSG_LIST_WRAP_PATTERN.findall(msg.body)) >= 2
+
+ @classmethod
+ def partial_rewrap(cls, body, width, indent):
+ try:
+ ret = ''
+ bindent = ''
+ for m in MSG_LIST_WRAP_PATTERN.split(body):
+ if not m:
+ continue
+ if MSG_LIST_WRAP_PATTERN.match(m):
+ # Bullet
+ if ret:
+ ret += indent
+ ret += m
+ bindent = ' ' * util.glyphwidth(m)
+ else:
+ # Content
+ # collapse whitespace and wrap.
+ ret += textwrap.fill(re.sub(r'\s+', ' ', m), width,
+ initial_indent=indent+bindent,
+ subsequent_indent=indent+bindent,
+ break_long_words=False,
+ break_on_hyphens=False).lstrip()
+ ret += '\n'
+
+ return ret.rstrip()
+ except Exception as e:
+ return str(e)
+