1
1
from __future__ import absolute_import , division , unicode_literals
2
2
3
- from gettext import gettext
4
- _ = gettext
5
-
6
3
from . import _base
7
4
from ..constants import cdataElements , rcdataElements , voidElements
8
5
@@ -23,24 +20,24 @@ def __iter__(self):
23
20
if type in ("StartTag" , "EmptyTag" ):
24
21
name = token ["name" ]
25
22
if contentModelFlag != "PCDATA" :
26
- raise LintError (_ ( "StartTag not in PCDATA content model flag: %(tag)s" ) % {"tag" : name })
23
+ raise LintError ("StartTag not in PCDATA content model flag: %(tag)s" % {"tag" : name })
27
24
if not isinstance (name , str ):
28
- raise LintError (_ ( "Tag name is not a string: %(tag)r" ) % {"tag" : name })
25
+ raise LintError ("Tag name is not a string: %(tag)r" % {"tag" : name })
29
26
if not name :
30
- raise LintError (_ ( "Empty tag name" ) )
27
+ raise LintError ("Empty tag name" )
31
28
if type == "StartTag" and name in voidElements :
32
- raise LintError (_ ( "Void element reported as StartTag token: %(tag)s" ) % {"tag" : name })
29
+ raise LintError ("Void element reported as StartTag token: %(tag)s" % {"tag" : name })
33
30
elif type == "EmptyTag" and name not in voidElements :
34
- raise LintError (_ ( "Non-void element reported as EmptyTag token: %(tag)s" ) % {"tag" : token ["name" ]})
31
+ raise LintError ("Non-void element reported as EmptyTag token: %(tag)s" % {"tag" : token ["name" ]})
35
32
if type == "StartTag" :
36
33
open_elements .append (name )
37
34
for name , value in token ["data" ]:
38
35
if not isinstance (name , str ):
39
- raise LintError (_ ( "Attribute name is not a string: %(name)r" ) % {"name" : name })
36
+ raise LintError ("Attribute name is not a string: %(name)r" % {"name" : name })
40
37
if not name :
41
- raise LintError (_ ( "Empty attribute name" ) )
38
+ raise LintError ("Empty attribute name" )
42
39
if not isinstance (value , str ):
43
- raise LintError (_ ( "Attribute value is not a string: %(value)r" ) % {"value" : value })
40
+ raise LintError ("Attribute value is not a string: %(value)r" % {"value" : value })
44
41
if name in cdataElements :
45
42
contentModelFlag = "CDATA"
46
43
elif name in rcdataElements :
@@ -51,43 +48,43 @@ def __iter__(self):
51
48
elif type == "EndTag" :
52
49
name = token ["name" ]
53
50
if not isinstance (name , str ):
54
- raise LintError (_ ( "Tag name is not a string: %(tag)r" ) % {"tag" : name })
51
+ raise LintError ("Tag name is not a string: %(tag)r" % {"tag" : name })
55
52
if not name :
56
- raise LintError (_ ( "Empty tag name" ) )
53
+ raise LintError ("Empty tag name" )
57
54
if name in voidElements :
58
- raise LintError (_ ( "Void element reported as EndTag token: %(tag)s" ) % {"tag" : name })
55
+ raise LintError ("Void element reported as EndTag token: %(tag)s" % {"tag" : name })
59
56
start_name = open_elements .pop ()
60
57
if start_name != name :
61
- raise LintError (_ ( "EndTag (%(end)s) does not match StartTag (%(start)s)" ) % {"end" : name , "start" : start_name })
58
+ raise LintError ("EndTag (%(end)s) does not match StartTag (%(start)s)" % {"end" : name , "start" : start_name })
62
59
contentModelFlag = "PCDATA"
63
60
64
61
elif type == "Comment" :
65
62
if contentModelFlag != "PCDATA" :
66
- raise LintError (_ ( "Comment not in PCDATA content model flag" ) )
63
+ raise LintError ("Comment not in PCDATA content model flag" )
67
64
68
65
elif type in ("Characters" , "SpaceCharacters" ):
69
66
data = token ["data" ]
70
67
if not isinstance (data , str ):
71
- raise LintError (_ ( "Attribute name is not a string: %(name)r" ) % {"name" : data })
68
+ raise LintError ("Attribute name is not a string: %(name)r" % {"name" : data })
72
69
if not data :
73
- raise LintError (_ ( "%(type)s token with empty data" ) % {"type" : type })
70
+ raise LintError ("%(type)s token with empty data" % {"type" : type })
74
71
if type == "SpaceCharacters" :
75
72
data = data .strip (spaceCharacters )
76
73
if data :
77
- raise LintError (_ ( "Non-space character(s) found in SpaceCharacters token: %(token)r" ) % {"token" : data })
74
+ raise LintError ("Non-space character(s) found in SpaceCharacters token: %(token)r" % {"token" : data })
78
75
79
76
elif type == "Doctype" :
80
77
name = token ["name" ]
81
78
if contentModelFlag != "PCDATA" :
82
- raise LintError (_ ( "Doctype not in PCDATA content model flag: %(name)s" ) % {"name" : name })
79
+ raise LintError ("Doctype not in PCDATA content model flag: %(name)s" % {"name" : name })
83
80
if not isinstance (name , str ):
84
- raise LintError (_ ( "Tag name is not a string: %(tag)r" ) % {"tag" : name })
81
+ raise LintError ("Tag name is not a string: %(tag)r" % {"tag" : name })
85
82
# XXX: what to do with token["data"] ?
86
83
87
84
elif type in ("ParseError" , "SerializeError" ):
88
85
pass
89
86
90
87
else :
91
- raise LintError (_ ( "Unknown token type: %(type)s" ) % {"type" : type })
88
+ raise LintError ("Unknown token type: %(type)s" % {"type" : type })
92
89
93
90
yield token
0 commit comments