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.__init_fraggle_xml__() |
self.__init_fraggle_xml__() |
16 |
|
self.restoreProfiles() |
17 |
|
|
18 |
#def savePrefs(): |
#def savePrefs(): |
19 |
|
|
31 |
|
|
32 |
def saveConfig(self): |
def saveConfig(self): |
33 |
engine = FraggleEngine() |
engine = FraggleEngine() |
34 |
|
|
35 |
prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml') |
prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml') |
36 |
|
#self.fraggleXML.marshalXML(self.profileDictionary, prefsfile) |
37 |
self.fraggleXML.marshalXML(self.configList, prefsfile) |
self.fraggleXML.marshalXML(self.configList, prefsfile) |
38 |
|
|
39 |
|
def saveProfiles(self): |
40 |
|
engine = FraggleEngine() |
41 |
|
profilesTemp = os.path.join(engine.getDefaultDir(), 'profiles.xml') |
42 |
|
self.fraggleXML.marshalXML(self.profileDictionary, profilesTemp) |
43 |
|
#print self.profileDictionary |
44 |
|
|
45 |
|
def restoreProfiles(self): |
46 |
|
engine = FraggleEngine() |
47 |
|
profiles = os.path.join(engine.getDefaultDir(), 'profiles.xml') |
48 |
|
self.profileDictionary = self.fraggleXML.unmarshalXML(profiles) |
49 |
|
#print self.profileDictionary |
50 |
|
|
51 |
|
def appendProfile(self,profileKey,configList): |
52 |
|
#print "Appending: " |
53 |
|
#print self.profileDictionary |
54 |
|
list = self.getProfileList() |
55 |
|
try: |
56 |
|
temp = list.index(profileKey) |
57 |
|
#print "Index Collision" |
58 |
|
return 1 |
59 |
|
except ValueError: |
60 |
|
try: |
61 |
|
self.profileDictionary.append(profileKey) |
62 |
|
self.profileDictionary.append(configList) |
63 |
|
except AttributeError: |
64 |
|
self.profileDictionary = [profileKey,configList] |
65 |
|
return 0 |
66 |
|
#print self.profileDictionary |
67 |
|
|
68 |
|
|
69 |
|
def loadProfile(self,profileKey): |
70 |
|
try: |
71 |
|
key = self.profileDictionary.index(profileKey) |
72 |
|
self.configList = self.profileDictionary[key+1] |
73 |
|
finally: |
74 |
|
pass |
75 |
|
|
76 |
|
def getProfileList(self): |
77 |
|
#print self.profileDictionary |
78 |
|
try: |
79 |
|
profileBuffer = self.profileDictionary |
80 |
|
x = len(profileBuffer) -1 |
81 |
|
tempList = [] |
82 |
|
while x >= 0: |
83 |
|
tempList.append(profileBuffer[x-1]) |
84 |
|
x = x-2 |
85 |
|
return tempList |
86 |
|
except TypeError: |
87 |
|
return [] |
88 |
|
except IndexError: |
89 |
|
return [] |
90 |
|
|
91 |
|
def deleteProfile(self,profileId): |
92 |
|
try: |
93 |
|
self.profileDictionary.pop(self.profileDictionary.index(profileId)+1) |
94 |
|
self.profileDictionary.pop(self.profileDictionary.index(profileId)) |
95 |
|
except IndexError: |
96 |
|
pass |
97 |
|
|