--- nfo/projects/netfraggle/bin/fraggleCtlPreferences.py 2004/08/25 21:43:53 1.4 +++ nfo/projects/netfraggle/bin/fraggleCtlPreferences.py 2004/08/29 22:52:40 1.5 @@ -11,12 +11,9 @@ def __init_fraggle_xml__(self): self.fraggleXML = fraggleParserXML.create(self) - - - def __init__(self,parent): self.__init_fraggle_xml__() - + self.restoreProfiles() #def savePrefs(): @@ -34,7 +31,67 @@ def saveConfig(self): engine = FraggleEngine() + prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml') + #self.fraggleXML.marshalXML(self.profileDictionary, prefsfile) self.fraggleXML.marshalXML(self.configList, prefsfile) - - + + def saveProfiles(self): + engine = FraggleEngine() + profilesTemp = os.path.join(engine.getDefaultDir(), 'profiles.xml') + self.fraggleXML.marshalXML(self.profileDictionary, profilesTemp) + #print self.profileDictionary + + def restoreProfiles(self): + engine = FraggleEngine() + profiles = os.path.join(engine.getDefaultDir(), 'profiles.xml') + self.profileDictionary = self.fraggleXML.unmarshalXML(profiles) + #print self.profileDictionary + + def appendProfile(self,profileKey,configList): + #print "Appending: " + #print self.profileDictionary + list = self.getProfileList() + try: + temp = list.index(profileKey) + #print "Index Collision" + return 1 + except ValueError: + try: + self.profileDictionary.append(profileKey) + self.profileDictionary.append(configList) + except AttributeError: + self.profileDictionary = [profileKey,configList] + return 0 + #print self.profileDictionary + + + def loadProfile(self,profileKey): + try: + key = self.profileDictionary.index(profileKey) + self.configList = self.profileDictionary[key+1] + finally: + pass + + def getProfileList(self): + #print self.profileDictionary + try: + profileBuffer = self.profileDictionary + x = len(profileBuffer) -1 + tempList = [] + while x >= 0: + tempList.append(profileBuffer[x-1]) + x = x-2 + return tempList + except TypeError: + return [] + except IndexError: + return [] + + def deleteProfile(self,profileId): + try: + self.profileDictionary.pop(self.profileDictionary.index(profileId)+1) + self.profileDictionary.pop(self.profileDictionary.index(profileId)) + except IndexError: + pass + \ No newline at end of file