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 = {} |
self.configList = {} |
|
self.prefsfile = os.path.join(self.getDefaultDir(), 'prefs.xml') |
|
17 |
self.__init_fraggle_xml__() |
self.__init_fraggle_xml__() |
18 |
self.restoreProfiles() |
self.restoreProfiles() |
19 |
|
self.prefsfile = os.path.join(self.engine.getDefaultDir(), 'prefs.xml') |
20 |
|
|
21 |
#def savePrefs(): |
#def savePrefs(): |
22 |
|
|
23 |
|
|
37 |
self.fraggleXML.marshalXML(self.configList, self.prefsfile) |
self.fraggleXML.marshalXML(self.configList, self.prefsfile) |
38 |
|
|
39 |
def saveProfiles(self): |
def saveProfiles(self): |
40 |
profilesTemp = os.path.join(self.getDefaultDir(), 'profiles.xml') |
profilesTemp = os.path.join(self.engine.getDefaultDir(), 'profiles.xml') |
41 |
self.fraggleXML.marshalXML(self.profileDictionary, profilesTemp) |
self.fraggleXML.marshalXML(self.profileDictionary, profilesTemp) |
42 |
#print self.profileDictionary |
#print self.profileDictionary |
43 |
|
|
44 |
def restoreProfiles(self): |
def restoreProfiles(self): |
45 |
profiles = os.path.join(self.getDefaultDir(), 'profiles.xml') |
profiles = os.path.join(self.engine.getDefaultDir(), 'profiles.xml') |
46 |
self.profileDictionary = self.fraggleXML.unmarshalXML(profiles) |
self.profileDictionary = self.fraggleXML.unmarshalXML(profiles) |
47 |
#print self.profileDictionary |
#print self.profileDictionary |
48 |
|
|
93 |
except IndexError: |
except IndexError: |
94 |
pass |
pass |
95 |
|
|
|
# from Pears: http://project5.freezope.org/pears/ |
|
|
def getDefaultDir(self): |
|
|
"""Gets location of default dir and creates it |
|
|
if necessary. ($HOME/.pears/)""" |
|
|
try: |
|
|
import pearsdebug |
|
|
savedir = pearsdebug.savedir |
|
|
except: |
|
|
dir = '.netfraggle' |
|
|
savedir = os.path.expanduser(os.path.join('~', dir)) |
|
|
if len(savedir)<=len("c:\\/" + dir): |
|
|
# problem that might occur on Win2k (no $HOME environment variable) |
|
|
temp = os.path.join(os.path.expandvars('$USERPROFILE'), dir) |
|
|
if temp > len("c:\\/" + dir): |
|
|
savedir = temp |
|
|
# create dir if it doesn't exist |
|
|
if not os.path.exists(savedir): |
|
|
os.makedirs(savedir) |
|
|
return savedir |
|
96 |
|
|
97 |
|
|