string search and modification
John Machin
sjmachin at lexicon.net
Thu Sep 7 07:12:43 EDT 2006
Jim Britain wrote:
>
> Final integration:
>
> def identifyHost(self):
> for line in self.fileContents:
> if re.search("throttling", line.lower()):
> p=r'\[((\d{1,3}\.){3}\d{1,3})\]'
> ip=re.search(p,line)
A prudent pessimist might test for the complete absence of an IP
address:
if not ip:
print "Huh?" # or whatever
> if ip.group(1) in self.ignoreList:
> continue
> if not ip.group(1) in self.banList:
> self.banList.append(ip.group(1))
>
>
More information about the Python-list
mailing list