Example #1
0
def extractSummary(element, widthLimit=80):
    """Extract all text from the given XML element, remove extra
       whitespace, and truncate it to no longer than the given width.
       """
    # Extract all text, eating extra whitespace
    text = re.sub("\s+", " ", XML.allText(element)).strip()

    # Use wrapLine to cleanly break it if possible, but
    # truncate it if necessary- wrapLine will not break words in
    # half if they are longer than the wrap width.
    lines = wrapLine(text, widthLimit)
    if lines:
        summary = lines[0][:widthLimit]
        if len(summary) < len(text):
            summary += "..."
        return summary
Example #2
0
File: Util.py Project: Kays/cia-vc
def extractSummary(element, widthLimit=80):
    """Extract all text from the given XML element, remove extra
       whitespace, and truncate it to no longer than the given width.
       """
    # Extract all text, eating extra whitespace
    text = re.sub("\s+", " ", XML.allText(element)).strip()

    # Use wrapLine to cleanly break it if possible, but
    # truncate it if necessary- wrapLine will not break words in
    # half if they are longer than the wrap width.
    lines = wrapLine(text, widthLimit)
    if lines:
        summary = lines[0][:widthLimit]
        if len(summary) < len(text):
            summary += "..."
        return summary
Example #3
0
 def format(self, args):
     colorText = XML.dig(args.message.xml, "message", "body", "colorText")
     if self.color:
         return self.formatter.parse(colorText)
     else:
         return XML.allText(colorText)
Example #4
0
 def format(self, args):
     colorText = XML.dig(args.message.xml, "message", "body", "colorText")
     if self.color:
         return self.formatter.parse(colorText)
     else:
         return XML.allText(colorText)