def testNewkey(self): x = es.keypcreate() es.keypsetname(x, "justice") self.keytest2(x) es.keypdelete(x) x = es.keypcreate() es.keypsetname(x, "justice2") self.keytest3(x) es.keypdelete(x) return
def __init__(self, name=None, parent=None, existingid=None, filename=None): ''' You can create a new KeyValues object by passing in different combinations of arguments: With only an existingid, KeyValues returns a wrapper around that existing id (i.e. C++ pointer). With only a parent, we'll create a new randomly named subkey. With a parent and name, we'll find/make a subkey of that name. With a name only, we'll create an unparented key with that name. With a filename, we'll load the KeyValues tree from disk and return it as the parent. ''' if existingid is not None: #print "kv", existingid, parent self._id_ = existingid self._parent_ = parent else: if parent is None: self._id_ = es.keypcreate() if filename is not None: self.load(filename) if name is not None: es.keypsetname(self._id_, str(name)) else: self._parent_ = parent if name is None: self._id_ = es.keypcreatesubkey(parent._id_) else: self._id_ = es.keypfindsubkey(parent._id_, str(name))
def keytest3(self,x): es.keyploadfromfile(x, server_var['eventscripts_addondir'] + "/pyunittest/myfile.vdf") y = es.keypfindsubkey(x, "subkey", False) outcome = es.keypgetint(y, "hello") self.failUnless(outcome==99) z = es.keypfindsubkey(y, "test", True) name = es.keypgetname(z) self.failUnless(name =="test") pp = es.keypcreate() es.keyploadfromfile(pp, server_var['eventscripts_addondir'] + "/pyunittest/myfile.vdf") es.keyprecursivekeycopy(z, pp) name = es.keypgetname(z) self.failUnless(name == "justice2")
def keytest3(self, x): es.keyploadfromfile( x, server_var['eventscripts_addondir'] + "/pyunittest/myfile.vdf") y = es.keypfindsubkey(x, "subkey", False) outcome = es.keypgetint(y, "hello") self.failUnless(outcome == 99) z = es.keypfindsubkey(y, "test", True) name = es.keypgetname(z) self.failUnless(name == "test") pp = es.keypcreate() es.keyploadfromfile( pp, server_var['eventscripts_addondir'] + "/pyunittest/myfile.vdf") es.keyprecursivekeycopy(z, pp) name = es.keypgetname(z) self.failUnless(name == "justice2")