/[cvs]/nfo/projects/netfraggle/bin/fraggleCtlPreferences.py
ViewVC logotype

Diff of /nfo/projects/netfraggle/bin/fraggleCtlPreferences.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by xabbu, Wed Aug 25 21:43:53 2004 UTC revision 1.7 by xabbu, Wed Sep 1 21:43:30 2004 UTC
# Line 11  class fraggleCtlPreferences: Line 11  class fraggleCtlPreferences:
11      def __init_fraggle_xml__(self):      def __init_fraggle_xml__(self):
12          self.fraggleXML = fraggleParserXML.create(self)          self.fraggleXML = fraggleParserXML.create(self)
13                    
       
           
       
14      def __init__(self,parent):      def __init__(self,parent):
15            self.engine = parent
16            self.configList = {}
17          self.__init_fraggle_xml__()          self.__init_fraggle_xml__()
18                self.restoreProfiles()
19                self.prefsfile = os.path.join(self.engine.getDefaultDir(), 'prefs.xml')
20    
21      #def savePrefs():      #def savePrefs():
22                            
23            
# Line 25  class fraggleCtlPreferences: Line 25  class fraggleCtlPreferences:
25          self.configList = {'username': username,'password': password,'url': url,'retrieval': retrieval}          self.configList = {'username': username,'password': password,'url': url,'retrieval': retrieval}
26                    
27      def getConfig(self):      def getConfig(self):
28            if not self.configList:
29                self.loadConfig(self.prefsfile)
30          return self.configList          return self.configList
       
31                    
32      def loadConfig(self,inputLocation):      def loadConfig(self,inputLocation):
33          self.configList = self.fraggleXML.unmarshalXML(inputLocation)          self.configList = self.fraggleXML.unmarshalXML(inputLocation)
34                    
           
35      def saveConfig(self):      def saveConfig(self):
36          engine = FraggleEngine()          #self.fraggleXML.marshalXML(self.profileDictionary, self.prefsfile)
37          prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml')          self.fraggleXML.marshalXML(self.configList, self.prefsfile)
38          self.fraggleXML.marshalXML(self.configList, prefsfile)      
39                def saveProfiles(self):
40            profilesTemp = os.path.join(self.engine.getDefaultDir(), 'profiles.xml')
41            self.fraggleXML.marshalXML(self.profileDictionary, profilesTemp)
42            #print self.profileDictionary
43        
44        def restoreProfiles(self):
45            profiles = os.path.join(self.engine.getDefaultDir(), 'profiles.xml')
46            self.profileDictionary = self.fraggleXML.unmarshalXML(profiles)
47            #print self.profileDictionary
48        
49        def appendProfile(self,profileKey,configList):
50            #print "Appending: "
51            #print self.profileDictionary
52            list = self.getProfileList()
53            try:
54                temp = list.index(profileKey)
55                #print "Index Collision"
56                return 1
57            except ValueError:
58                try:
59                    self.profileDictionary.append(profileKey)
60                    self.profileDictionary.append(configList)
61                except AttributeError:
62                    self.profileDictionary = [profileKey,configList]
63                return 0
64            #print self.profileDictionary    
65            
66        
67        def loadProfile(self,profileKey):
68          try:
69              key = self.profileDictionary.index(profileKey)
70              self.configList = self.profileDictionary[key+1]
71          finally:
72              pass
73        
74        def getProfileList(self):
75             #print self.profileDictionary
76             try:
77                 profileBuffer = self.profileDictionary
78                 x = len(profileBuffer) -1
79                 tempList = []
80                 while x >= 0:
81                    tempList.append(profileBuffer[x-1])
82                    x = x-2
83                 return tempList
84             except TypeError:
85                 return []
86             except IndexError:
87                 return []
88              
89        def deleteProfile(self,profileId):
90            try:
91                self.profileDictionary.pop(self.profileDictionary.index(profileId)+1)
92                self.profileDictionary.pop(self.profileDictionary.index(profileId))
93            except IndexError:
94                pass
95    
96    
97            

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed