+ """Specialized HTML parser that looks for a specific anchor."""
def __init__(self, search_anchor):
if key in ('id', 'name') and value == self.search_anchor:
def check_anchor(f, hash):
"""Reads HTML data from a filelike object 'f' searching for anchor 'hash'.
- Returns True if anchor was found, False otherwise"""
+ Returns True if anchor was found, False otherwise.
parser = AnchorCheckParser(hash)
# Read file in chunks of 8192 bytes. If we find a matching anchor, we
- # break the loop early in hopes not to have to download the whole thing
+ # break the loop early in hopes not to have to download the whole thing.
while chunk and not parser.found:
# HTMLParser is usually pretty good with sloppy HTML, but it tends to
# choke on EOF. But we're done then anyway.