7dcd2908aca58e6f9013a752c3e8af982ce85908
20 def load(self
, filename
):
24 for line
in file(filename
).readlines():
28 cmd
= string
.split(line
)[0]
29 tail
= string
.join(string
.split(line
)[1:])
37 print "Unkown command", cmd
42 def store(self
, filename
):
44 f
= file(filename
, "w")
46 for b
in self
.breakpoints
:
47 self
.__writeBreak
(f
, b
)
49 for w
in self
.watches
:
50 self
.__writeWatch
(f
, w
)
53 def parseBreak(self
, tail
):
56 rx
= re
.compile("^[\w\._\-]+:\d+(\s+if\s+\S+.*)?$")
58 if not rx
.search(tail
):
59 print "Wrong breakpoint format:", tail
62 preif
= string
.split(tail
, "if")[0].strip()
63 postif
= string
.join( string
.split(tail
, "if")[1:], "if").strip()
65 [file,lineno
] = string
.split(preif
, ":")
72 self
.addBreak(file, lineno
, cond
)
75 def parseWatch(self
, tail
):
79 def __writeBreak(self
, f
, b
):
81 f
.write("break %(file)s:%(lineno)d if %(cond)s\n" % b
)
83 f
.write("break %(file)s:%(lineno)d\n" % b
)
85 def __writeWatch(self
, f
, w
):
86 f
.write("watch %(expr)s\n" % w
)
89 def addBreak(self
, file, lineno
, cond
=None):
90 self
.breakpoints
+= [ {"file" : file, "lineno" : lineno
, "cond" : cond
} ]
92 def addWatch(self
, expr
):
93 self
.watches
+= [ {"expr" : expr
.strip() } ]
96 return "breakpoints=" + str(self
.breakpoints
) + ", watches=" + str(self
.watches
)