예제 #1
0
 def _channel(self, channel, as_bytes=True):
     # Construct a channel name using any specified namespace.
     if self._namespace is not None:
         channel = build_id(self._namespace, channel)
     if as_bytes:
         return to_bytes(channel)
     return channel
예제 #2
0
 def set_default(self, key, val):
     self._settings.setdefault(key, to_bytes(val))
예제 #3
0
 def set(self, key, val):
     self._settings[key] = to_bytes(val)
예제 #4
0
 def get(self, key):
     section, option = self._config_components(key)
     val = section.get(option, None)
     if val is not None:
         val = to_bytes(val)
     return val
예제 #5
0
 def publish(self, channel, message):
     # Enumerate all the callbacks for the specified channel and invoke them.
     message = to_bytes(message)
     if channel in self._bus:
         for cb in self._bus[channel]:
             cb(to_bytes(channel), message)
예제 #6
0
 def test_bytes(self):
     self.assertEqual(service_utils.to_bytes(b'bar'), b'bar')
예제 #7
0
 def test_number(self):
     self.assertEqual(service_utils.to_bytes(123), b'123')
예제 #8
0
 def test_string(self):
     self.assertEqual(service_utils.to_bytes('foo'), b'foo')