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

Commita8b40b2

Browse files
committed
(Almost) comply with PEP 8.
The two violations: - We don't in general comply with the 79 character per line limit. - constants.py violates (at least according to pep8) the hanging indent rule. On the whole, I disagree with the tool and have filed <PyCQA/pycodestyle#189> with regards to this.
1 parent7a06a5a commita8b40b2

Some content is hidden

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

44 files changed

+1530
-1317
lines changed

‎.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ install:
3131

3232
script:
3333
-nosetests
34-
-if [[ $FLAKE == "true" ]]; then flake8 --exclude=E,W html5lib; fi
34+
-if [[ $FLAKE == "true" ]]; then find html5lib/ -name '*.py' -and -not -name 'constants.py' -print0 | xargs -0 flake8 --ignore=E501; fi
35+
-if [[ $FLAKE == "true" ]]; then flake8 --max-line-length=99 --ignore=E126 html5lib/constants.py; fi
3536

3637
after_script:
3738
-python debug-info.py

‎html5lib/constants.py

Lines changed: 234 additions & 231 deletions
Large diffs are not rendered by default.

‎html5lib/filters/inject_meta_charset.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from .import_base
44

5+
56
classFilter(_base.Filter):
67
def__init__(self,source,encoding):
78
_base.Filter.__init__(self,source)
@@ -20,21 +21,21 @@ def __iter__(self):
2021

2122
eliftype=="EmptyTag":
2223
iftoken["name"].lower()=="meta":
23-
# replace charset with actual encoding
24-
has_http_equiv_content_type=False
25-
for (namespace,name),valueintoken["data"].items():
26-
ifnamespace!=None:
27-
continue
28-
elifname.lower()=='charset':
29-
token["data"][(namespace,name)]=self.encoding
30-
meta_found=True
31-
break
32-
elifname=='http-equiv'andvalue.lower()=='content-type':
33-
has_http_equiv_content_type=True
34-
else:
35-
ifhas_http_equiv_content_typeand (None,"content")intoken["data"]:
36-
token["data"][(None,"content")]='text/html; charset=%s'%self.encoding
37-
meta_found=True
24+
# replace charset with actual encoding
25+
has_http_equiv_content_type=False
26+
for (namespace,name),valueintoken["data"].items():
27+
ifnamespaceisnotNone:
28+
continue
29+
elifname.lower()=='charset':
30+
token["data"][(namespace,name)]=self.encoding
31+
meta_found=True
32+
break
33+
elifname=='http-equiv'andvalue.lower()=='content-type':
34+
has_http_equiv_content_type=True
35+
else:
36+
ifhas_http_equiv_content_typeand (None,"content")intoken["data"]:
37+
token["data"][(None,"content")]='text/html; charset=%s'%self.encoding
38+
meta_found=True
3839

3940
eliftoken["name"].lower()=="head"andnotmeta_found:
4041
# insert meta into empty head

‎html5lib/filters/lint.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
fromhtml5lib.constantsimportspaceCharacters
1010
spaceCharacters="".join(spaceCharacters)
1111

12-
classLintError(Exception):pass
12+
13+
classLintError(Exception):
14+
pass
15+
1316

1417
classFilter(_base.Filter):
1518
def__iter__(self):

‎html5lib/filters/optionaltags.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from .import_base
44

5+
56
classFilter(_base.Filter):
67
defslider(self):
78
previous1=previous2=None
@@ -17,7 +18,7 @@ def __iter__(self):
1718
type=token["type"]
1819
iftype=="StartTag":
1920
if (token["data"]or
20-
notself.is_optional_start(token["name"],previous,next)):
21+
notself.is_optional_start(token["name"],previous,next)):
2122
yieldtoken
2223
eliftype=="EndTag":
2324
ifnotself.is_optional_end(token["name"],next):
@@ -75,7 +76,7 @@ def is_optional_start(self, tagname, previous, next):
7576
# omit the thead and tfoot elements' end tag when they are
7677
# immediately followed by a tbody element. See is_optional_end.
7778
ifpreviousandprevious['type']=='EndTag'and \
78-
previous['name']in ('tbody','thead','tfoot'):
79+
previous['name']in ('tbody','thead','tfoot'):
7980
returnFalse
8081
returnnext["name"]=='tr'
8182
else:

‎html5lib/filters/sanitizer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
from .import_base
44
fromhtml5lib.sanitizerimportHTMLSanitizerMixin
55

6+
67
classFilter(_base.Filter,HTMLSanitizerMixin):
78
def__iter__(self):
89
fortokenin_base.Filter.__iter__(self):
910
token=self.sanitize_token(token)
10-
iftoken:yieldtoken
11+
iftoken:
12+
yieldtoken

‎html5lib/filters/whitespace.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
SPACES_REGEX=re.compile("[%s]+"%spaceCharacters)
1010

11+
1112
classFilter(_base.Filter):
1213

1314
spacePreserveElements=frozenset(["pre","textarea"]+list(rcdataElements))
@@ -17,7 +18,7 @@ def __iter__(self):
1718
fortokenin_base.Filter.__iter__(self):
1819
type=token["type"]
1920
iftype=="StartTag" \
20-
and (preserveortoken["name"]inself.spacePreserveElements):
21+
and (preserveortoken["name"]inself.spacePreserveElements):
2122
preserve+=1
2223

2324
eliftype=="EndTag"andpreserve:
@@ -32,6 +33,6 @@ def __iter__(self):
3233

3334
yieldtoken
3435

36+
3537
defcollapse_spaces(text):
3638
returnSPACES_REGEX.sub(' ',text)
37-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp