sgmllib nit

Robin Becker robin at jessikat.fsnet.co.uk
Sat Dec 9 16:37:40 CET 2000


The current version of sgmllib doesn't allow the detection of attributes
without values. Instead the attribute name is used. Later the pair
(string.lower(attrname),attrvalue) is appended to the list of
attributes. The current code is
            
            attrname, rest, attrvalue = match.group(1, 2, 3)
            if not rest:
                attrvalue = attrname
            elif attrvalue[:1] == '\'' == attrvalue[-1:] or \
                 attrvalue[:1] == '"' == attrvalue[-1:]:
                attrvalue = attrvalue[1:-1]
            attrs.append((string.lower(attrname), attrvalue))


if this were changed to do the string lower first then one could use the
fact that the name, value pair both have the same id to detect the fact
that no = value was entered.

            attrname, rest, attrvalue = match.group(1, 2, 3)
            attrname = string.lower(attrname)
            if not rest:
                attrvalue = attrname
            elif attrvalue[:1] == '\'' == attrvalue[-1:] or \
                 attrvalue[:1] == '"' == attrvalue[-1:]:
                attrvalue = attrvalue[1:-1]
            attrs.append((attrname, attrvalue))
-- 
Robin Becker



More information about the Python-list mailing list