def testGetAddressParts(self):
     addresses = {
         "/foo": ["foo"],
         "/foo/bar": ["foo", "bar"],
         "/foo/bar/ham": ["foo", "bar", "ham"],
         "/egg/[1-2]": ["egg", "[1-2]"],
         "/egg/*": ["egg", "*"],
         "/egg/?": ["egg", "?"],
         }
     for k, v in addresses.iteritems():
         self.failUnlessEqual(osc.getAddressParts(k), v)
示例#2
0
 def testGetAddressParts(self):
     addresses = {
         "/foo": ["foo"],
         "/foo/bar": ["foo", "bar"],
         "/foo/bar/ham": ["foo", "bar", "ham"],
         "/egg/[1-2]": ["egg", "[1-2]"],
         "/egg/*": ["egg", "*"],
         "/egg/?": ["egg", "?"],
     }
     for k, v in addresses.iteritems():
         self.failUnlessEqual(osc.getAddressParts(k), v)
示例#3
0
 def dispatch(self, element, client):
     """
     Dispatch an element to all matching callbacks.
     
     Executes every callback matching the message address with element as
     argument.  The order in which the callbacks are called is undefined.
     
     @param element: A Message or Bundle.
     @param client: A (host, port) tuple with the originator's address
     """
     if isinstance(element, osc.Bundle):
         messages = element.getMessages()
     else:
         messages = [element]
     for msg in messages:
         matched = False
         address_list = osc.getAddressParts(msg.address)
         value_list = msg.getValues()
         for callback in self.getCallbacks(msg.address):
             callback(address_list, value_list, client)
             matched = True
         if not matched:
             self.fallback(address_list, value_list, client)