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

Commite80a7a1

Browse files
committed
unaccent: Remove Python 2 support from Python script
This is a maintainer-only script, but since we're removing Python 2support elsewhere, we might as well clean this one up as well.
1 parente3df32b commite80a7a1

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

‎contrib/unaccent/generate_unaccent_rules.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,13 @@
2626
# [1] https://www.unicode.org/Public/${UNICODE_VERSION}/ucd/UnicodeData.txt
2727
# [2] https://raw.githubusercontent.com/unicode-org/cldr/${TAG}/common/transforms/Latin-ASCII.xml
2828

29-
# BEGIN: Python 2/3 compatibility - remove when Python 2 compatibility dropped
30-
# The approach is to be Python3 compatible with Python2 "backports".
31-
from __future__importprint_function
32-
from __future__importunicode_literals
33-
# END: Python 2/3 compatibility - remove when Python 2 compatibility dropped
34-
3529
importargparse
3630
importcodecs
3731
importre
3832
importsys
3933
importxml.etree.ElementTreeasET
4034

41-
# BEGIN: Python 2/3 compatibility - remove when Python 2 compatibility dropped
42-
ifsys.version_info[0]<=2:
43-
# Encode stdout as UTF-8, so we can just print to it
44-
sys.stdout=codecs.getwriter('utf8')(sys.stdout)
45-
46-
# Map Python 2's chr to unichr
47-
chr=unichr
48-
49-
# Python 2 and 3 compatible bytes call
50-
defbytes(source,encoding='ascii',errors='strict'):
51-
returnsource.encode(encoding=encoding,errors=errors)
52-
else:
53-
# END: Python 2/3 compatibility - remove when Python 2 compatibility dropped
54-
sys.stdout=codecs.getwriter('utf8')(sys.stdout.buffer)
35+
sys.stdout=codecs.getwriter('utf8')(sys.stdout.buffer)
5536

5637
# The ranges of Unicode characters that we consider to be "plain letters".
5738
# For now we are being conservative by including only Latin and Greek. This
@@ -213,12 +194,12 @@ def special_cases():
213194
charactersSet=set()
214195

215196
# Cyrillic
216-
charactersSet.add((0x0401,u"\u0415"))# CYRILLIC CAPITAL LETTER IO
217-
charactersSet.add((0x0451,u"\u0435"))# CYRILLIC SMALL LETTER IO
197+
charactersSet.add((0x0401,"\u0415"))# CYRILLIC CAPITAL LETTER IO
198+
charactersSet.add((0x0451,"\u0435"))# CYRILLIC SMALL LETTER IO
218199

219200
# Symbols of "Letterlike Symbols" Unicode Block (U+2100 to U+214F)
220-
charactersSet.add((0x2103,u"\xb0C"))# DEGREE CELSIUS
221-
charactersSet.add((0x2109,u"\xb0F"))# DEGREE FAHRENHEIT
201+
charactersSet.add((0x2103,"\xb0C"))# DEGREE CELSIUS
202+
charactersSet.add((0x2109,"\xb0F"))# DEGREE FAHRENHEIT
222203
charactersSet.add((0x2117,"(P)"))# SOUND RECORDING COPYRIGHT
223204

224205
returncharactersSet

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp