@@ -23,24 +23,24 @@ def __iter__(self):
2323if type in ("StartTag" ,"EmptyTag" ):
2424name = token ["name" ]
2525if contentModelFlag != "PCDATA" :
26- raise LintError (_ ("StartTag not in PCDATA content model flag: %s" )% name )
26+ raise LintError (_ ("StartTag not in PCDATA content model flag: %(tag) s" )% { "tag" : name } )
2727if not isinstance (name ,str ):
28- raise LintError (_ ("Tag name is not a string: %r" )% name )
28+ raise LintError (_ ("Tag name is not a string: %(tag) r" )% { "tag" : name } )
2929if not name :
3030raise LintError (_ ("Empty tag name" ))
3131if type == "StartTag" and name in voidElements :
32- raise LintError (_ ("Void element reported as StartTag token: %s" )% name )
32+ raise LintError (_ ("Void element reported as StartTag token: %(tag) s" )% { "tag" : name } )
3333elif type == "EmptyTag" and name not in voidElements :
34- raise LintError (_ ("Non-void element reported as EmptyTag token: %s" )% token ["name" ])
34+ raise LintError (_ ("Non-void element reported as EmptyTag token: %(tag) s" )% { "tag" : token ["name" ]} )
3535if type == "StartTag" :
3636open_elements .append (name )
3737for name ,value in token ["data" ]:
3838if not isinstance (name ,str ):
39- raise LintError (_ ("Attribute name is not a string: %r" )% name )
39+ raise LintError (_ ("Attribute name is not a string: %(name) r" )% { " name" : name } )
4040if not name :
4141raise LintError (_ ("Empty attribute name" ))
4242if not isinstance (value ,str ):
43- raise LintError (_ ("Attribute value is not a string: %r" )% value )
43+ raise LintError (_ ("Attribute value is not a string: %(value) r" )% { " value" : value } )
4444if name in cdataElements :
4545contentModelFlag = "CDATA"
4646elif name in rcdataElements :
@@ -51,14 +51,14 @@ def __iter__(self):
5151elif type == "EndTag" :
5252name = token ["name" ]
5353if not isinstance (name ,str ):
54- raise LintError (_ ("Tag name is not a string: %r" )% name )
54+ raise LintError (_ ("Tag name is not a string: %(tag) r" )% { "tag" : name } )
5555if not name :
5656raise LintError (_ ("Empty tag name" ))
5757if name in voidElements :
58- raise LintError (_ ("Void element reported as EndTag token: %s" )% name )
58+ raise LintError (_ ("Void element reported as EndTag token: %(tag) s" )% { "tag" : name } )
5959start_name = open_elements .pop ()
6060if start_name != name :
61- raise LintError (_ ("EndTag (%s) does not match StartTag (%s)" )% ( name ,start_name ) )
61+ raise LintError (_ ("EndTag (%(end) s) does not match StartTag (%(start) s)" )% { "end" : name ,"start" : start_name } )
6262contentModelFlag = "PCDATA"
6363
6464elif type == "Comment" :
@@ -68,26 +68,26 @@ def __iter__(self):
6868elif type in ("Characters" ,"SpaceCharacters" ):
6969data = token ["data" ]
7070if not isinstance (data ,str ):
71- raise LintError (_ ("Attribute name is not a string: %r" )% data )
71+ raise LintError (_ ("Attribute name is not a string: %(name) r" )% { "name" : data } )
7272if not data :
73- raise LintError (_ ("%s token with empty data" )% type )
73+ raise LintError (_ ("%(type) s token with empty data" )% { " type" : type } )
7474if type == "SpaceCharacters" :
7575data = data .strip (spaceCharacters )
7676if data :
77- raise LintError (_ ("Non-space character(s) found in SpaceCharacters token: " )% data )
77+ raise LintError (_ ("Non-space character(s) found in SpaceCharacters token:%(token)r " )% { "token" : data } )
7878
7979elif type == "Doctype" :
8080name = token ["name" ]
8181if contentModelFlag != "PCDATA" :
82- raise LintError (_ ("Doctype not in PCDATA content model flag: %s" )% name )
82+ raise LintError (_ ("Doctype not in PCDATA content model flag: %(name) s" )% { " name" : name } )
8383if not isinstance (name ,str ):
84- raise LintError (_ ("Tag name is not a string: %r" )% name )
84+ raise LintError (_ ("Tag name is not a string: %(tag) r" )% { "tag" : name } )
8585# XXX: what to do with token["data"] ?
8686
8787elif type in ("ParseError" ,"SerializeError" ):
8888pass
8989
9090else :
91- raise LintError (_ ("Unknown token type: %s" )% type )
91+ raise LintError (_ ("Unknown token type: %(type) s" )% { " type" : type } )
9292
9393yield token