diff options
author | Guido van Rossum <guido@python.org> | 1995-03-04 22:28:49 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-03-04 22:28:49 (GMT) |
commit | 1dba24eecadc76e682745ecb5fecf7f49b0811cc (patch) | |
tree | 647f48f9a28ccaa93aeb360edf5203a3a75b4830 /Lib/sgmllib.py | |
parent | 7b5430f2e82a6fca7d77bb5b4a4d9e588dc3ad05 (diff) | |
download | cpython-1dba24eecadc76e682745ecb5fecf7f49b0811cc.zip cpython-1dba24eecadc76e682745ecb5fecf7f49b0811cc.tar.gz cpython-1dba24eecadc76e682745ecb5fecf7f49b0811cc.tar.bz2 |
remove redundant backslashes; some cosnetics
Diffstat (limited to 'Lib/sgmllib.py')
-rw-r--r-- | Lib/sgmllib.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index af75e0d..17e5745 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -14,8 +14,8 @@ import string # Regular expressions used for parsing -incomplete = regex.compile( \ - '<!-?\|</[a-zA-Z][a-zA-Z0-9]*[ \t\n]*\|</?\|' + \ +incomplete = regex.compile( + '<!-?\|</[a-zA-Z][a-zA-Z0-9]*[ \t\n]*\|</?\|' + '&#[a-zA-Z0-9]*\|&[a-zA-Z][a-zA-Z0-9]*\|&') entityref = regex.compile('&[a-zA-Z][a-zA-Z0-9]*[;.]') charref = regex.compile('&#[a-zA-Z0-9]+;') @@ -59,7 +59,7 @@ class SGMLParser: # Interface -- feed some data to the parser. Call this as # often as you want, with as little or as much text as you # want (may include '\n'). (This just saves the text, all the - # processing is done by process() or close().) + # processing is done by goahead().) def feed(self, data): self.rawdata = self.rawdata + data self.goahead(0) @@ -172,9 +172,9 @@ class SGMLParser: # Now parse the data between i+1 and j into a tag and attrs attrs = [] tagfind = regex.compile('[a-zA-Z][a-zA-Z0-9]*') - attrfind = regex.compile( \ - '[ \t\n]+\([a-zA-Z][a-zA-Z0-9]*\)' + \ - '\([ \t\n]*=[ \t\n]*' + \ + attrfind = regex.compile( + '[ \t\n]+\([a-zA-Z][a-zA-Z0-9]*\)' + + '\([ \t\n]*=[ \t\n]*' + '\(\'[^\']*\';\|"[^"]*"\|[-a-zA-Z0-9./:+*%?!()_#]+\)\)?') k = tagfind.match(rawdata, i+1) if k < 0: @@ -196,7 +196,7 @@ class SGMLParser: attrvalue = attrvalue[1:-1] else: attrvalue = '' - attrs.append(string.lower(attrname), attrvalue) + attrs.append((string.lower(attrname), attrvalue)) k = k + l j = j+1 try: @@ -253,7 +253,7 @@ class SGMLParser: # Example -- handle entity reference, no need to override def handle_entityref(self, name): - table = self.__class__.entitydefs + table = self.entitydefs name = string.lower(name) if table.has_key(name): self.handle_data(table[name]) @@ -318,4 +318,5 @@ def test(): x.feed(line) -#test() +if __name__ == '__main__': + test() |