未验证 提交 807d221d 编写于 作者: Y Yuki Okushi 提交者: GitHub

Rollup merge of #74783 - jnozsc:python_cleanup, r=Mark-Simulacrum

python codes cleanup
......@@ -125,8 +125,8 @@ except ImportError:
from htmlentitydefs import name2codepoint
# "void elements" (no closing tag) from the HTML Standard section 12.1.2
VOID_ELEMENTS = set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'])
VOID_ELEMENTS = {'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'}
# Python 2 -> 3 compatibility
try:
......@@ -146,7 +146,7 @@ class CustomHTMLParser(HTMLParser):
self.__builder = target or ET.TreeBuilder()
def handle_starttag(self, tag, attrs):
attrs = dict((k, v or '') for k, v in attrs)
attrs = {k: v or '' for k, v in attrs}
self.__builder.start(tag, attrs)
if tag in VOID_ELEMENTS:
self.__builder.end(tag)
......@@ -155,7 +155,7 @@ class CustomHTMLParser(HTMLParser):
self.__builder.end(tag)
def handle_startendtag(self, tag, attrs):
attrs = dict((k, v or '') for k, v in attrs)
attrs = {k: v or '' for k, v in attrs}
self.__builder.start(tag, attrs)
self.__builder.end(tag)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册