def tttest_setting_values(self): """this test is needed, because deleting a key from inifile is not trivial. See below, deleting a section I couldn't get to work """ testinifile = os.path.join(self.tmpTest, 'inifiletest.ini') f1 = open(testinifile, 'w') f1.close() win32api.WriteProfileVal('s1', 'k1', 'v1', testinifile) win32api.WriteProfileVal('s1', 'k2', 'v2', testinifile) win32api.WriteProfileVal('s2', 'kk1', 'vv1', testinifile) section = win32api.GetProfileSection('s1', testinifile) expected = ['k1=v1', 'k2=v2'] self.assert_( expected == section, "section |%s| not as expected: |%s|" % (section, expected)) # this call deletes a key::::: win32api.WriteProfileVal('s1', 'k2', None, testinifile) section = win32api.GetProfileSection('s1', testinifile) expected = ['k1=v1'] self.assert_( expected == section, "section |%s| after deleted keys is not as expected: |%s|" % (section, expected)) pass
def getMore(self, section, key): self.UpdateData(1) #get the items out of the ini file ini = win32ui.GetProfileFileName() secitems = win32api.GetProfileSection(section, ini) items = [] for secitem in secitems: items.append(secitem.split('=')[1]) dlg = TheParamsDialog(items) if dlg.DoModal() == win32con.IDOK: itemstr = ';'.join(dlg.getItems()) self._obj_.data[key] = itemstr #update the ini file with dlg.getNew() i = 0 newitems = dlg.getNew() if newitems: items = items + newitems for item in items: win32api.WriteProfileVal(section, repr(i), item, ini) i = i + 1 self.UpdateData(0)
def keys(self): Keys = win32api.GetProfileSection(self.section, self.filename) Keys = [k.split('=')[0].strip() for k in Keys] #print 'return Keys: %s'% Keys return Keys