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

Commit5d925be

Browse files
committed
Regenerate the Py2 code using awkwardduet 1.1a4.
This finally sorts out the unicode/str mess, so yay!
1 parentc1029a4 commit5d925be

File tree

54 files changed

+4659
-3743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4659
-3743
lines changed

‎html5lib/__init__.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""
1+
u"""
22
HTML parsing library based on the WHATWG "HTML5"
33
specification. The parser is designed to be compatible with existing
44
HTML found in the wild and implements well-defined error recovery that
@@ -10,8 +10,9 @@
1010
f = open("my_document.html")
1111
tree = html5lib.parse(f)
1212
"""
13-
__version__="0.95-dev"
14-
fromhtml5parserimportHTMLParser,parse,parseFragment
15-
fromtreebuildersimportgetTreeBuilder
16-
fromtreewalkersimportgetTreeWalker
17-
fromserializerimportserialize
13+
from __future__importabsolute_import
14+
__version__=u"0.95-dev"
15+
from .html5parserimportHTMLParser,parse,parseFragment
16+
from .treebuildersimportgetTreeBuilder
17+
from .treewalkersimportgetTreeWalker
18+
from .serializerimportserialize

‎html5lib/constants.py‎

Lines changed: 543 additions & 542 deletions
Large diffs are not rendered by default.

‎html5lib/filters/_base.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
classFilter(object):
33
def__init__(self,source):
44
self.source=source
5+
__init__.func_annotations= {}
56

67
def__iter__(self):
78
returniter(self.source)
9+
__iter__.func_annotations= {}
810

911
def__getattr__(self,name):
1012
returngetattr(self.source,name)
13+
__getattr__.func_annotations= {}
Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,65 @@
1-
import_base
1+
from __future__importabsolute_import
2+
from .import_base
23

34
classFilter(_base.Filter):
45
def__init__(self,source,encoding):
56
_base.Filter.__init__(self,source)
67
self.encoding=encoding
8+
__init__.func_annotations= {}
79

810
def__iter__(self):
9-
state="pre_head"
11+
state=u"pre_head"
1012
meta_found= (self.encodingisNone)
1113
pending= []
1214

1315
fortokenin_base.Filter.__iter__(self):
14-
type=token["type"]
15-
iftype=="StartTag":
16-
iftoken["name"].lower()==u"head":
17-
state="in_head"
16+
type=token[u"type"]
17+
iftype==u"StartTag":
18+
iftoken[u"name"].lower()==u"head":
19+
state=u"in_head"
1820

19-
eliftype=="EmptyTag":
20-
iftoken["name"].lower()==u"meta":
21+
eliftype==u"EmptyTag":
22+
iftoken[u"name"].lower()==u"meta":
2123
# replace charset with actual encoding
2224
has_http_equiv_content_type=False
23-
for (namespace,name),valueintoken["data"].iteritems():
25+
for (namespace,name),valueintoken[u"data"].items():
2426
ifnamespace!=None:
2527
continue
2628
elifname.lower()==u'charset':
27-
token["data"][(namespace,name)]=self.encoding
29+
token[u"data"][(namespace,name)]=self.encoding
2830
meta_found=True
2931
break
3032
elifname==u'http-equiv'andvalue.lower()==u'content-type':
3133
has_http_equiv_content_type=True
3234
else:
33-
ifhas_http_equiv_content_typeand (None,u"content")intoken["data"]:
34-
token["data"][(None,u"content")]=u'text/html; charset=%s'%self.encoding
35+
ifhas_http_equiv_content_typeand (None,u"content")intoken[u"data"]:
36+
token[u"data"][(None,u"content")]=u'text/html; charset=%s'%self.encoding
3537
meta_found=True
3638

37-
eliftoken["name"].lower()==u"head"andnotmeta_found:
39+
eliftoken[u"name"].lower()==u"head"andnotmeta_found:
3840
# insert meta into empty head
39-
yield {"type":"StartTag","name":u"head",
40-
"data":token["data"]}
41-
yield {"type":"EmptyTag","name":u"meta",
42-
"data": {(None,u"charset"):self.encoding}}
43-
yield {"type":"EndTag","name":u"head"}
41+
yield {u"type":u"StartTag",u"name":u"head",
42+
u"data":token[u"data"]}
43+
yield {u"type":u"EmptyTag",u"name":u"meta",
44+
u"data": {(None,u"charset"):self.encoding}}
45+
yield {u"type":u"EndTag",u"name":u"head"}
4446
meta_found=True
4547
continue
4648

47-
eliftype=="EndTag":
48-
iftoken["name"].lower()==u"head"andpending:
49+
eliftype==u"EndTag":
50+
iftoken[u"name"].lower()==u"head"andpending:
4951
# insert meta into head (if necessary) and flush pending queue
5052
yieldpending.pop(0)
5153
ifnotmeta_found:
52-
yield {"type":"EmptyTag","name":u"meta",
53-
"data": {(None,u"charset"):self.encoding}}
54+
yield {u"type":u"EmptyTag",u"name":u"meta",
55+
u"data": {(None,u"charset"):self.encoding}}
5456
whilepending:
5557
yieldpending.pop(0)
5658
meta_found=True
57-
state="post_head"
59+
state=u"post_head"
5860

59-
ifstate=="in_head":
61+
ifstate==u"in_head":
6062
pending.append(token)
6163
else:
6264
yieldtoken
65+
__iter__.func_annotations= {}

‎html5lib/filters/lint.py‎

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from __future__importabsolute_import
12
fromgettextimportgettext
23
_=gettext
34

4-
import_base
5+
from .import_base
56
fromhtml5lib.constantsimportcdataElements,rcdataElements,voidElements
67

78
fromhtml5lib.constantsimportspaceCharacters
@@ -12,39 +13,39 @@ class LintError(Exception): pass
1213
classFilter(_base.Filter):
1314
def__iter__(self):
1415
open_elements= []
15-
contentModelFlag="PCDATA"
16+
contentModelFlag=u"PCDATA"
1617
fortokenin_base.Filter.__iter__(self):
17-
type=token["type"]
18-
iftypein ("StartTag","EmptyTag"):
19-
name=token["name"]
20-
ifcontentModelFlag!="PCDATA":
21-
raiseLintError(_("StartTag not in PCDATA content model flag: %s")%name)
18+
type=token[u"type"]
19+
iftypein (u"StartTag",u"EmptyTag"):
20+
name=token[u"name"]
21+
ifcontentModelFlag!=u"PCDATA":
22+
raiseLintError(_(u"StartTag not in PCDATA content model flag: %s")%name)
2223
ifnotisinstance(name,unicode):
2324
raiseLintError(_(u"Tag name is not a string: %r")%name)
2425
ifnotname:
2526
raiseLintError(_(u"Empty tag name"))
26-
iftype=="StartTag"andnameinvoidElements:
27+
iftype==u"StartTag"andnameinvoidElements:
2728
raiseLintError(_(u"Void element reported as StartTag token: %s")%name)
28-
eliftype=="EmptyTag"andnamenotinvoidElements:
29-
raiseLintError(_(u"Non-void element reported as EmptyTag token: %s")%token["name"])
30-
iftype=="StartTag":
29+
eliftype==u"EmptyTag"andnamenotinvoidElements:
30+
raiseLintError(_(u"Non-void element reported as EmptyTag token: %s")%token[u"name"])
31+
iftype==u"StartTag":
3132
open_elements.append(name)
32-
forname,valueintoken["data"]:
33+
forname,valueintoken[u"data"]:
3334
ifnotisinstance(name,unicode):
34-
raiseLintError(_("Attribute name is not a string: %r")%name)
35+
raiseLintError(_(u"Attribute name is not a string: %r")%name)
3536
ifnotname:
3637
raiseLintError(_(u"Empty attribute name"))
3738
ifnotisinstance(value,unicode):
38-
raiseLintError(_("Attribute value is not a string: %r")%value)
39+
raiseLintError(_(u"Attribute value is not a string: %r")%value)
3940
ifnameincdataElements:
40-
contentModelFlag="CDATA"
41+
contentModelFlag=u"CDATA"
4142
elifnameinrcdataElements:
42-
contentModelFlag="RCDATA"
43-
elifname=="plaintext":
44-
contentModelFlag="PLAINTEXT"
43+
contentModelFlag=u"RCDATA"
44+
elifname==u"plaintext":
45+
contentModelFlag=u"PLAINTEXT"
4546

46-
eliftype=="EndTag":
47-
name=token["name"]
47+
eliftype==u"EndTag":
48+
name=token[u"name"]
4849
ifnotisinstance(name,unicode):
4950
raiseLintError(_(u"Tag name is not a string: %r")%name)
5051
ifnotname:
@@ -54,35 +55,36 @@ def __iter__(self):
5455
start_name=open_elements.pop()
5556
ifstart_name!=name:
5657
raiseLintError(_(u"EndTag (%s) does not match StartTag (%s)")% (name,start_name))
57-
contentModelFlag="PCDATA"
58+
contentModelFlag=u"PCDATA"
5859

59-
eliftype=="Comment":
60-
ifcontentModelFlag!="PCDATA":
61-
raiseLintError(_("Comment not in PCDATA content model flag"))
60+
eliftype==u"Comment":
61+
ifcontentModelFlag!=u"PCDATA":
62+
raiseLintError(_(u"Comment not in PCDATA content model flag"))
6263

63-
eliftypein ("Characters","SpaceCharacters"):
64-
data=token["data"]
64+
eliftypein (u"Characters",u"SpaceCharacters"):
65+
data=token[u"data"]
6566
ifnotisinstance(data,unicode):
66-
raiseLintError(_("Attribute name is not a string: %r")%data)
67+
raiseLintError(_(u"Attribute name is not a string: %r")%data)
6768
ifnotdata:
6869
raiseLintError(_(u"%s token with empty data")%type)
69-
iftype=="SpaceCharacters":
70+
iftype==u"SpaceCharacters":
7071
data=data.strip(spaceCharacters)
7172
ifdata:
7273
raiseLintError(_(u"Non-space character(s) found in SpaceCharacters token: ")%data)
7374

74-
eliftype=="Doctype":
75-
name=token["name"]
76-
ifcontentModelFlag!="PCDATA":
77-
raiseLintError(_("Doctype not in PCDATA content model flag: %s")%name)
75+
eliftype==u"Doctype":
76+
name=token[u"name"]
77+
ifcontentModelFlag!=u"PCDATA":
78+
raiseLintError(_(u"Doctype not in PCDATA content model flag: %s")%name)
7879
ifnotisinstance(name,unicode):
7980
raiseLintError(_(u"Tag name is not a string: %r")%name)
8081
# XXX: what to do with token["data"] ?
8182

82-
eliftypein ("ParseError","SerializeError"):
83+
eliftypein (u"ParseError",u"SerializeError"):
8384
pass
8485

8586
else:
8687
raiseLintError(_(u"Unknown token type: %s")%type)
8788

8889
yieldtoken
90+
__iter__.func_annotations= {}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp