示例#1
0
 def rulesetReturn(msg):
     nodes = xp.queryObject(msg)
     if nodes:
         self.result = XML.allText(nodes[0]).strip()
     else:
         self.result = None
     raise RulesetReturnException()
示例#2
0
文件: Util.py 项目: Justasic/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
示例#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)