1 |
joko |
1.3 |
import os |
2 |
|
|
|
3 |
xabbu |
1.1 |
import fraggleParserXML |
4 |
joko |
1.3 |
from fraggleEngine import * |
5 |
xabbu |
1.1 |
|
6 |
xabbu |
1.2 |
def create(parent): |
7 |
|
|
return fraggleCtlPreferences(parent) |
8 |
|
|
|
9 |
xabbu |
1.1 |
class fraggleCtlPreferences: |
10 |
|
|
|
11 |
xabbu |
1.2 |
def __init_fraggle_xml__(self): |
12 |
|
|
self.fraggleXML = fraggleParserXML.create(self) |
13 |
xabbu |
1.1 |
|
14 |
|
|
def __init__(self,parent): |
15 |
|
|
self.__init_fraggle_xml__() |
16 |
xabbu |
1.5 |
self.restoreProfiles() |
17 |
xabbu |
1.1 |
|
18 |
|
|
#def savePrefs(): |
19 |
|
|
|
20 |
|
|
|
21 |
xabbu |
1.2 |
def setConfig(self,username,password,url,retrieval): |
22 |
|
|
self.configList = {'username': username,'password': password,'url': url,'retrieval': retrieval} |
23 |
|
|
|
24 |
|
|
def getConfig(self): |
25 |
|
|
return self.configList |
26 |
|
|
|
27 |
xabbu |
1.4 |
|
28 |
|
|
def loadConfig(self,inputLocation): |
29 |
|
|
self.configList = self.fraggleXML.unmarshalXML(inputLocation) |
30 |
|
|
|
31 |
|
|
|
32 |
xabbu |
1.2 |
def saveConfig(self): |
33 |
joko |
1.3 |
engine = FraggleEngine() |
34 |
xabbu |
1.5 |
|
35 |
joko |
1.3 |
prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml') |
36 |
xabbu |
1.5 |
#self.fraggleXML.marshalXML(self.profileDictionary, prefsfile) |
37 |
joko |
1.3 |
self.fraggleXML.marshalXML(self.configList, prefsfile) |
38 |
xabbu |
1.5 |
|
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 |
|
|
|