Exemple #1
0
 def unregister(self, event, callback):
     regex = redis_to_py_pattern(event)
     entry = self.callbacks.get(regex)
     if entry:
         if callback in entry.callbacks:
             entry.callbacks.remove(callback)
             if not entry.callbacks:
                 self.callbacks.pop(regex)
Exemple #2
0
 def test_redis_to_py_pattern(self):
     p = redis_to_py_pattern('h?llo')
     c = re.compile(p)
     self.match(c, 'hello')
     self.match(c, 'hallo')
     self.not_match(c, 'haallo')
     self.not_match(c, 'hallox')
     #
     p = redis_to_py_pattern('h*llo')
     c = re.compile(p)
     self.match(c, 'hello')
     self.match(c, 'hallo')
     self.match(c, 'hasjdbvhckjcvkfcdfllo')
     self.not_match(c, 'haallox')
     self.not_match(c, 'halloouih')
     #
     p = redis_to_py_pattern('h[ae]llo')
     c = re.compile(p)
     self.match(c, 'hello')
     self.match(c, 'hallo')
     self.not_match(c, 'hollo')
Exemple #3
0
 def test_redis_to_py_pattern(self):
     p = redis_to_py_pattern('h?llo')
     c = re.compile(p)
     self.match(c, 'hello')
     self.match(c, 'hallo')
     self.not_match(c, 'haallo')
     self.not_match(c, 'hallox')
     #
     p = redis_to_py_pattern('h*llo')
     c = re.compile(p)
     self.match(c, 'hello')
     self.match(c, 'hallo')
     self.match(c, 'hasjdbvhckjcvkfcdfllo')
     self.not_match(c, 'haallox')
     self.not_match(c, 'halloouih')
     #
     p = redis_to_py_pattern('h[ae]llo')
     c = re.compile(p)
     self.match(c, 'hello')
     self.match(c, 'hallo')
     self.not_match(c, 'hollo')
Exemple #4
0
    def register(self, event, callback):
        """Register a ``callback`` for ``event``
        """
        regex = redis_to_py_pattern(event)
        entry = self.callbacks.get(regex)
        if not entry:
            entry = regex_callbacks(re.compile(regex), [])
            self.callbacks[regex] = entry

        if callback not in entry.callbacks:
            entry.callbacks.append(callback)

        return entry
Exemple #5
0
 def event_pattern(self, event):
     """Channel pattern for an event name
     """
     return redis_to_py_pattern(event)
Exemple #6
0
 def event_pattern(self, event):
     """Channel pattern for an event name
     """
     return redis_to_py_pattern(event)
Exemple #7
0
 def unregister(self, event, callback):
     regex = redis_to_py_pattern(event)
     entry = self.callbacks.get(regex)
     if entry:
         self._remove_callback(entry, callback)