Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit106c0af

Browse files
committed
Update lint filter for Py3 and namespaced attributes.
1 parent1e14765 commit106c0af

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

‎html5lib/filters/lint.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
from __future__importabsolute_import,division,unicode_literals
22

3+
fromgettextimportgettext
4+
_=gettext
5+
6+
fromsiximporttext_type
7+
38
from .import_base
49
from ..constantsimportcdataElements,rcdataElements,voidElements
510

@@ -21,7 +26,7 @@ def __iter__(self):
2126
name=token["name"]
2227
ifcontentModelFlag!="PCDATA":
2328
raiseLintError("StartTag not in PCDATA content model flag: %(tag)s"% {"tag":name})
24-
ifnotisinstance(name,str):
29+
ifnotisinstance(name,text_type):
2530
raiseLintError("Tag name is not a string: %(tag)r"% {"tag":name})
2631
ifnotname:
2732
raiseLintError("Empty tag name")
@@ -31,12 +36,14 @@ def __iter__(self):
3136
raiseLintError("Non-void element reported as EmptyTag token: %(tag)s"% {"tag":token["name"]})
3237
iftype=="StartTag":
3338
open_elements.append(name)
34-
forname,valueintoken["data"]:
35-
ifnotisinstance(name,str):
39+
for (ns,name),valueintoken["data"].items():
40+
ifnsisnotNoneandnotisinstance(ns,text_type):
41+
raiseLintError("Attribute namespace is not None or a string: %(name)r"% {"name":name})
42+
ifnotisinstance(name,text_type):
3643
raiseLintError("Attribute name is not a string: %(name)r"% {"name":name})
3744
ifnotname:
3845
raiseLintError("Empty attribute name")
39-
ifnotisinstance(value,str):
46+
ifnotisinstance(value,text_type):
4047
raiseLintError("Attribute value is not a string: %(value)r"% {"value":value})
4148
ifnameincdataElements:
4249
contentModelFlag="CDATA"
@@ -47,7 +54,7 @@ def __iter__(self):
4754

4855
eliftype=="EndTag":
4956
name=token["name"]
50-
ifnotisinstance(name,str):
57+
ifnotisinstance(name,text_type):
5158
raiseLintError("Tag name is not a string: %(tag)r"% {"tag":name})
5259
ifnotname:
5360
raiseLintError("Empty tag name")
@@ -64,7 +71,7 @@ def __iter__(self):
6471

6572
eliftypein ("Characters","SpaceCharacters"):
6673
data=token["data"]
67-
ifnotisinstance(data,str):
74+
ifnotisinstance(data,text_type):
6875
raiseLintError("Attribute name is not a string: %(name)r"% {"name":data})
6976
ifnotdata:
7077
raiseLintError("%(type)s token with empty data"% {"type":type})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp