1 from traceback
import print_exc
2 from PyQt4
import QtCore
8 def __init__(self
, file='settings.txt'):
15 def get(self
, name
, default
=None):
16 for line
in self
.lines
:
17 if line
[0:len(name
)]==name
:
18 return line
[len(name
):].strip()
21 def set(self
, name
, value
):
22 newvalue
="%s\t%s"%(name
,value
)
23 for i
in xrange(len(self
.lines
)):
25 if line
[0:len(name
)]==name
:
26 self
.lines
[i
]=newvalue
29 self
.lines
.append(newvalue
)
31 def getIntTuple(self
, name
):
32 """Note this might return an exception!"""
35 x
,y
=int(val
[0:i
]), int(val
[i
:])
38 def setIntTuple(self
, name
, val1
, val2
):
39 self
.set(name
, "%i %i"%(val1
, val2
))
48 self
.lines
.append(line
.strip().replace('$NEWLINE', '\n'))
55 f
=open(self
.fileName
, 'wb')
56 for line
in self
.lines
:
57 f
.write("%s\n"%(line
.replace('\n', '$NEWLINE')))