예제 #1
0
 def finish(self, data):
     """ finish processing of an xml stanza. """
     methods = []
     self.final['subelements'] = self.subelements
     for subelement in self.subelements:
         logging.debug("%s - %s" % (self.cfg.name, str(subelement)))
         for elem in subelement:
             logging.debug("%s - setting %s handler" % (self.cfg.name, elem))
             methods.append(self.getHandler(elem))
         for method in methods:
             if not method: continue
             try:
                 result = GozerEvent(subelement)
                 result.bot = self
                 result.orig = data
                 result.jabber = True
                 method(result) 
             except Exception, ex: handle_exception()
     if self.tags:
         element = self.tags[0]
         logging.debug("%s - setting element: %s" % (self.cfg.name, element))
     else: element = 'stream'
     self.final['element'] = element
     method = self.getHandler(element)
     if method:
         try:
             result = GozerEvent(self.final)
             result.bot = self
             result.orig = data
             result.jabber = True
             method(result) 
         except Exception, ex:
             handle_exception()
             result = {}
예제 #2
0
파일: core.py 프로젝트: melmothx/jsonbot
             result.bot = self
             result.orig = data
             result.jabber = True
             method(result)
         except Exception, ex:
             handle_exception()
 if self.tags:
     element = self.tags[0]
     logging.debug("%s - setting element: %s" % (self.name, element))
 else:
     element = 'stream'
 self.final['element'] = element
 method = self.getHandler(element)
 if method:
     try:
         result = GozerEvent(self.final)
         result.bot = self
         result.orig = data
         result.jabber = True
         method(result)
     except Exception, ex:
         handle_exception()
         result = {}
 else:
     logging.error("%s - can't find handler for %s" %
                   (self.name, element))
     result = {}
 if result:
     self.final = {}
     self.reslist = []
     self.tags = []