@@ -23,24 +23,24 @@ def __iter__(self):
23
23
if type in ("StartTag" , "EmptyTag" ):
24
24
name = token ["name" ]
25
25
if 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 } )
27
27
if 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 } )
29
29
if not name :
30
30
raise LintError (_ ("Empty tag name" ))
31
31
if 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 } )
33
33
elif 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" ]} )
35
35
if type == "StartTag" :
36
36
open_elements .append (name )
37
37
for name , value in token ["data" ]:
38
38
if 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 } )
40
40
if not name :
41
41
raise LintError (_ ("Empty attribute name" ))
42
42
if 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 } )
44
44
if name in cdataElements :
45
45
contentModelFlag = "CDATA"
46
46
elif name in rcdataElements :
@@ -51,14 +51,14 @@ def __iter__(self):
51
51
elif type == "EndTag" :
52
52
name = token ["name" ]
53
53
if 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 } )
55
55
if not name :
56
56
raise LintError (_ ("Empty tag name" ))
57
57
if 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 } )
59
59
start_name = open_elements .pop ()
60
60
if 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 } )
62
62
contentModelFlag = "PCDATA"
63
63
64
64
elif type == "Comment" :
@@ -68,26 +68,26 @@ def __iter__(self):
68
68
elif type in ("Characters" , "SpaceCharacters" ):
69
69
data = token ["data" ]
70
70
if 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 } )
72
72
if not data :
73
- raise LintError (_ ("%s token with empty data" ) % type )
73
+ raise LintError (_ ("%(type) s token with empty data" ) % { " type" : type } )
74
74
if type == "SpaceCharacters" :
75
75
data = data .strip (spaceCharacters )
76
76
if 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 } )
78
78
79
79
elif type == "Doctype" :
80
80
name = token ["name" ]
81
81
if 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 } )
83
83
if 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 } )
85
85
# XXX: what to do with token["data"] ?
86
86
87
87
elif type in ("ParseError" , "SerializeError" ):
88
88
pass
89
89
90
90
else :
91
- raise LintError (_ ("Unknown token type: %s" ) % type )
91
+ raise LintError (_ ("Unknown token type: %(type) s" ) % { " type" : type } )
92
92
93
93
yield token
0 commit comments