peng3d/peng.py
def sendEvent(self,event,data=None):
        """
        Sends an event with attached data.
        
        ``event`` should be a string of format ``<namespace>:<category1>.<subcategory2>.<name>``\ .
        There may be an arbitrary amount of subcategories. Also note that this
        format is not strictly enforced, but rather recommended by convention.
        
        ``data`` may be any Python Object, but it usually is a dictionary containing relevant parameters.
        For example, most built-in events use a dictionary containing at least the ``peng`` key set to an instance of this class.
        
        If there are no handlers for the event, a corresponding message will be printed to the log file.
        To prevent spam, the maximum amount of ignored messages can be configured via :confval:`events.maxignore` and defaults to 3.
        
        If the config value :confval:`debug.events.dumpfile` is a file path, the event type will be added to an internal list and be saved to the given file during program exit.
        """
        if self.cfg["debug.events.dumpfile"]!="" and event not in self.event_list:
            self.event_list.add(event)
        if event not in self.eventHandlers:
            if event not in self.events_ignored or self.events_ignored[event]<=self.cfg["events.maxignore"]: # Prevents spamming logfile with ignored event messages
                # TODO: write to logfile
                # Needs a logging module first...
                self.events_ignored[event] = self.events_ignored.get(event,0)+1
            return
        
        for handler in self.eventHandlers[event]:
            f = handler[0]
            try:
                f(event,data)
            except Exception:
                if not handler[1]:
                    raise
                else:
                    # TODO: write to logfile
                    if self.cfg["events.removeonerror"]:
                        self.delEventListener(event,f)
def sendEvent(self,event,data=None):
        """
        Sends an event with attached data.
        
        ``event`` should be a string of format ``<namespace>:<category1>.<subcategory2>.<name>``\ .
        There may be an arbitrary amount of subcategories. Also note that this
        format is not strictly enforced, but rather recommended by convention.
        
        ``data`` may be any Python Object, but it usually is a dictionary containing relevant parameters.
        For example, most built-in events use a dictionary containing at least the ``peng`` key set to an instance of this class.
        
        If there are no handlers for the event, a corresponding message will be printed to the log file.
        To prevent spam, the maximum amount of ignored messages can be configured via :confval:`events.maxignore` and defaults to 3.
        
        If the config value :confval:`debug.events.dumpfile` is a file path, the event type will be added to an internal list and be saved to the given file during program exit.
        """
        if self.cfg["debug.events.dumpfile"]!="" and event not in self.event_list:
            self.event_list.add(event)
        if event not in self.eventHandlers:
            if event not in self.events_ignored or self.events_ignored[event]<=self.cfg["events.maxignore"]: # Prevents spamming logfile with ignored event messages
                # TODO: write to logfile
                # Needs a logging module first...
                self.events_ignored[event] = self.events_ignored.get(event,0)+1
            return
        
        for handler in self.eventHandlers[event]:
            f = handler[0]
            try:
                f(event,data)
            except Exception:
                if not handler[1]:
                    raise
                else:
                    # TODO: write to logfile
                    if self.cfg["events.removeonerror"]:
                        self.delEventListener(event,f)
def sendEvent ( self , event , data = None ) : if self . cfg [ "debug.events.dumpfile" ] != "" and event not in self . event_list : self . event_list . add ( event ) if event not in self . eventHandlers : if event not in self . events_ignored or self . events_ignored [ event ] <= self . cfg [ "events.maxignore" ] : # Prevents spamming logfile with ignored event messages # TODO: write to logfile # Needs a logging module first... self . events_ignored [ event ] = self . events_ignored . get ( event , 0 ) + 1 return for handler in self . eventHandlers [ event ] : f = handler [ 0 ] try : f ( event , data ) except Exception : if not handler [ 1 ] : raise else : # TODO: write to logfile if self . cfg [ "events.removeonerror" ] : self . delEventListener ( event , f )
Sends an event with attached data.
        
        ``event`` should be a string of format ``<namespace>:<category1>.<subcategory2>.<name>``\ .
        There may be an arbitrary amount of subcategories. Also note that this
        format is not strictly enforced, but rather recommended by convention.
        
        ``data`` may be any Python Object, but it usually is a dictionary containing relevant parameters.
        For example, most built-in events use a dictionary containing at least the ``peng`` key set to an instance of this class.
        
        If there are no handlers for the event, a corresponding message will be printed to the log file.
        To prevent spam, the maximum amount of ignored messages can be configured via :confval:`events.maxignore` and defaults to 3.
        
        If the config value :confval:`debug.events.dumpfile` is a file path, the event type will be added to an internal list and be saved to the given file during program exit.
Sends an event with attached data . event should be a string of format <namespace > : <category1 > . <subcategory2 > . <name > \ . There may be an arbitrary amount of subcategories . Also note that this format is not strictly enforced but rather recommended by convention . data may be any Python Object but it usually is a dictionary containing relevant parameters . For example most built - in events use a dictionary containing at least the peng key set to an instance of this class . If there are no handlers for the event a corresponding message will be printed to the log file . To prevent spam the maximum amount of ignored messages can be configured via : confval : events . maxignore and defaults to 3 . If the config value : confval : debug . events . dumpfile is a file path the event type will be added to an internal list and be saved to the given file during program exit .