def test_keyPath(self): d = ConfigDict() setKeyPath(d, "one", "A") setKeyPath(d, "one", "B") setKeyPath(d, "two.one", "C") setKeyPath(d, "two.one", "D") setKeyPath(d, "two.two", "E") setKeyPath(d, "three.one.one", "F") setKeyPath(d, "three.one.two", "G") self.assertEquals(d.one, "B") self.assertEquals(d.two.one, "D") self.assertEquals(d.two.two, "E") self.assertEquals(d.three.one.one, "F") self.assertEquals(d.three.one.two, "G") self.assertEquals(getKeyPath(d, "one"), "B") self.assertEquals(getKeyPath(d, "two.one"), "D") self.assertEquals(getKeyPath(d, "two.two"), "E") self.assertEquals(getKeyPath(d, "three.one.one"), "F") self.assertEquals(getKeyPath(d, "three.one.two"), "G")
def command_readConfig(self, command): """ Return current configuration @param command: the dictionary parsed from the plist read from stdin @type command: C{dict} """ config.reload() # config.Memcached.Pools.Default.ClientEnabled = False result = {} for keyPath in WRITABLE_CONFIG_KEYS: value = getKeyPath(config, keyPath) if value is not None: # Note: config contains utf-8 encoded strings, but plistlib # wants unicode, so decode here: if isinstance(value, str): value = value.decode("utf-8") setKeyPath(result, keyPath, value) self.respond(command, result)