[clug] Help with a python regexp?
Francis Whittle
fj.whittle at gmail.com
Sat Feb 21 21:51:29 GMT 2009
The way I'd do it in Perl would be to match a parenthesised exchange.idl
at the beginning of the line and discard if the parenthesis match, well,
matched.
if(m/^(exchange.idl)?.*warning[: ].*/ && $1 eq ''){
#do stuff
}
You'd then be able to just add in exclusions to the paren match....
Now I've done barely any python ever but if it does regular expressions
in a Perl or POSIX way (doesn't it do the later?) it should be much
similar.
If you want to stick to only the regexp, you'd need some way of matching
_not_ the first bit. This is tricky as exclusions are defined one
character at a time.
On Fri, 2009-02-20 at 21:08 +1100, Brad Hards wrote:
> Hi,
>
> I've been playing with buildbot (http://buildbot.net:80/trac), and I've run
> into a problem.
>
> A bit of background first. One of the thing that happens with the compile step
> is that it extracts the warnings messages from the rest of stdout.
> So given this:
> http://colo1.frogmouth.net:8010/builders/full-centos52/builds/109/steps/compile/logs/stdio
> it pulls out:
> http://colo1.frogmouth.net:8010/builders/full-centos52/builds/109/steps/compile/logs/warnings
>
> The method to do that looks like this:
>
> def createSummary(self, log):
> self.warnCount = 0
>
> if not self.warningPattern:
> return
>
> wre = self.warningPattern
> if isinstance(wre, str):
> wre = re.compile(wre)
>
> # Check if each line in the output from this command matched our
> # warnings regular expressions. If did, bump the warnings count and
> # add the line to the collection of lines with warnings
> warnings = []
> for line in log.getText().split("\n"):
> if wre.match(line):
> warnings.append(line)
> self.warnCount += 1
>
> The warningPattern is (by default) is
> warningPattern = '.*warning[: ].*'
>
> The problem is that I can't fix some of the warnings. Basically, all those
> lines that start with "exchange.idl" are hiding the real compile warnings.
>
> I don't want to hide the lines in a normal build (e.g. by piping
> to /dev/null), only filtering on the buildbot. Hacking the method is a
> possibility, but I'd prefer to just have a better regexp.
>
> So how to I match a line containing "warning:", as long as it doesn't start
> with "exchange.idl"?
>
> All help much appreciated
>
> Brad
More information about the linux
mailing list