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

Commit00977d6

Browse files
committed
Rename a bunch of serializer module variables to be underscore prefixed
1 parent18a7102 commit00977d6

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

‎html5lib/serializer.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,33 @@
1010
from .importtreewalkers,_utils
1111
fromxml.sax.saxutilsimportescape
1212

13-
spaceCharacters="".join(spaceCharacters)
14-
15-
quoteAttributeSpecChars=spaceCharacters+"\"'=<>`"
16-
quoteAttributeSpec=re.compile("["+quoteAttributeSpecChars+"]")
17-
quoteAttributeLegacy=re.compile("["+quoteAttributeSpecChars+
18-
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n"
19-
"\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15"
20-
"\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
21-
"\x20\x2f\x60\xa0\u1680\u180e\u180f\u2000"
22-
"\u2001\u2002\u2003\u2004\u2005\u2006\u2007"
23-
"\u2008\u2009\u200a\u2028\u2029\u202f\u205f"
24-
"\u3000]")
25-
26-
27-
encode_entity_map= {}
28-
is_ucs4=len("\U0010FFFF")==1
13+
_quoteAttributeSpecChars="".join(spaceCharacters)+"\"'=<>`"
14+
_quoteAttributeSpec=re.compile("["+_quoteAttributeSpecChars+"]")
15+
_quoteAttributeLegacy=re.compile("["+_quoteAttributeSpecChars+
16+
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n"
17+
"\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15"
18+
"\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
19+
"\x20\x2f\x60\xa0\u1680\u180e\u180f\u2000"
20+
"\u2001\u2002\u2003\u2004\u2005\u2006\u2007"
21+
"\u2008\u2009\u200a\u2028\u2029\u202f\u205f"
22+
"\u3000]")
23+
24+
25+
_encode_entity_map= {}
26+
_is_ucs4=len("\U0010FFFF")==1
2927
fork,vinlist(entities.items()):
3028
# skip multi-character entities
31-
if ((is_ucs4andlen(v)>1)or
32-
(notis_ucs4andlen(v)>2)):
29+
if ((_is_ucs4andlen(v)>1)or
30+
(not_is_ucs4andlen(v)>2)):
3331
continue
3432
ifv!="&":
3533
iflen(v)==2:
3634
v=_utils.surrogatePairToCodepoint(v)
3735
else:
3836
v=ord(v)
39-
ifvnotinencode_entity_mapork.islower():
37+
ifvnotin_encode_entity_mapork.islower():
4038
# prefer &lt; over &LT; and similarly for &amp;, &gt;, etc.
41-
encode_entity_map[v]=k
39+
_encode_entity_map[v]=k
4240

4341

4442
defhtmlentityreplace_errors(exc):
@@ -58,7 +56,7 @@ def htmlentityreplace_errors(exc):
5856
codepoint=ord(c)
5957
codepoints.append(codepoint)
6058
forcpincodepoints:
61-
e=encode_entity_map.get(cp)
59+
e=_encode_entity_map.get(cp)
6260
ife:
6361
res.append("&")
6462
res.append(e)
@@ -258,9 +256,9 @@ def serialize(self, treewalker, encoding=None):
258256
ifself.quote_attr_values=="always"orlen(v)==0:
259257
quote_attr=True
260258
elifself.quote_attr_values=="spec":
261-
quote_attr=quoteAttributeSpec.search(v)isnotNone
259+
quote_attr=_quoteAttributeSpec.search(v)isnotNone
262260
elifself.quote_attr_values=="legacy":
263-
quote_attr=quoteAttributeLegacy.search(v)isnotNone
261+
quote_attr=_quoteAttributeLegacy.search(v)isnotNone
264262
else:
265263
raiseValueError("quote_attr_values must be one of: "
266264
"'always', 'spec', or 'legacy'")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp