Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
28201259
Kaydet (Commit)
28201259
authored
May 16, 2003
tarafından
Marc-André Lemburg
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove usage of re module from encodings package search function.
üst
813cec9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
__init__.py
Lib/encodings/__init__.py
+19
-4
No files found.
Lib/encodings/__init__.py
Dosyayı görüntüle @
28201259
...
...
@@ -27,12 +27,17 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
"""
#"
import
codecs
,
exceptions
,
re
import
codecs
,
exceptions
,
types
_cache
=
{}
_unknown
=
'--unknown--'
_import_tail
=
[
'*'
]
_norm_encoding_RE
=
re
.
compile
(
'[^a-zA-Z0-9.]'
)
_norm_encoding_map
=
(
' . '
'0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ '
' abcdefghijklmnopqrstuvwxyz '
' '
' '
' '
)
class
CodecRegistryError
(
exceptions
.
LookupError
,
exceptions
.
SystemError
):
...
...
@@ -45,10 +50,20 @@ def normalize_encoding(encoding):
Normalization works as follows: all non-alphanumeric
characters except the dot used for Python package names are
collapsed and replaced with a single underscore, e.g. ' -;#'
becomes '_'.
becomes '_'. Leading and trailing underscores are removed.
Note that encoding names should be ASCII only; if they do use
non-ASCII characters, these must be Latin-1 compatible.
"""
return
'_'
.
join
(
_norm_encoding_RE
.
split
(
encoding
))
# Make sure we have an 8-bit string, because .translate() works
# differently for Unicode strings.
if
type
(
encoding
)
is
types
.
UnicodeType
:
# Note that .encode('latin-1') does *not* use the codec
# registry, so this call doesn't recurse. (See unicodeobject.c
# PyUnicode_AsEncodedString() for details)
encoding
=
encoding
.
encode
(
'latin-1'
)
return
'_'
.
join
(
encoding
.
translate
(
_norm_encoding_map
)
.
split
())
def
search_function
(
encoding
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment