try:
cnt = 0
#Parse all lines
- for line in file(filename).readlines():
+ f = file(filename, "r")
+ for line in f.readlines():
cnt += 1
#Get command and tail
else:
cnt -= 1
print "Unkown command", cmd
+ f.close()
return cnt
+
except IOError:
return None
def store(self, filename):
+ try:
+ f = file(filename, "w")
- f = file(filename, "w")
+ for b in self.breakpoints:
+ self.__writeBreak(f, b)
- for b in self.breakpoints:
- self.__writeBreak(f, b)
+ for w in self.watches:
+ self.__writeWatch(f, w)
- for w in self.watches:
- self.__writeWatch(f, w)
+ for s in self.ints:
+ self.__writeInt(f, s)
- for s in self.ints:
- self.__writeInt(f, s)
+ f.close()
+ return True
+
+ except IOError:
+ return False
def parseBreak(self, tail):
tail = tail.strip()
- rx = re.compile("^[\w\._\-]+:\d+(\s+if\s+\S+.*)?$")
+ rx = re.compile("^[\w/\._\-]+:\d+(\s+if\s+\S+.*)?$")
if not rx.search(tail):
print "Wrong breakpoint format:", tail
f.write("watch %(expr)s\n" % w)
- def addBreak(self, file, lineno, cond=None):
- self.breakpoints += [ {"file" : file, "lineno" : lineno, "cond" : cond} ]
+ def addBreak(self, file, lineno, cond=None):
+ bp = {"file" : file, "lineno" : lineno, "cond" : cond}
+ if not bp in self.breakpoints:
+ self.breakpoints += [bp]
def addInt(self, name, val):
- self.ints += [{"name": name, "val": val}]
+ i = {"name": name, "val": val}
+ if not i in self.ints:
+ self.ints += [i]
def addWatch(self, expr):
- self.watches += [ {"expr" : expr.strip() } ]
+ w = {"expr" : expr.strip() }
+ if not w in self.watches:
+ self.watches += [w]
def findInt(self, name):