[Python-checkins] python/dist/src/Lib/encodings __init__.py,1.18,1.19

lemburg@users.sourceforge.net lemburg@users.sourceforge.net
2003年5月16日 10:07:54 -0700


Update of /cvsroot/python/python/dist/src/Lib/encodings
In directory sc8-pr-cvs1:/tmp/cvs-serv29749/Lib/encodings
Modified Files:
	__init__.py 
Log Message:
Remove usage of re module from encodings package search function.
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/encodings/__init__.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** __init__.py	24 Apr 2003 16:02:49 -0000	1.18
--- __init__.py	16 May 2003 17:07:51 -0000	1.19
***************
*** 28,37 ****
 """#"
 
! import codecs, exceptions, re
 
 _cache = {}
 _unknown = '--unknown--'
 _import_tail = ['*']
! _norm_encoding_RE = re.compile('[^a-zA-Z0-9.]')
 
 class CodecRegistryError(exceptions.LookupError,
--- 28,42 ----
 """#"
 
! import codecs, exceptions, types
 
 _cache = {}
 _unknown = '--unknown--'
 _import_tail = ['*']
! _norm_encoding_map = (' . '
! '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ '
! ' abcdefghijklmnopqrstuvwxyz '
! ' '
! ' '
! ' ')
 
 class CodecRegistryError(exceptions.LookupError,
***************
*** 46,53 ****
 characters except the dot used for Python package names are
 collapsed and replaced with a single underscore, e.g. ' -;#'
! becomes '_'.
 
 """
! return '_'.join(_norm_encoding_RE.split(encoding))
 
 def search_function(encoding):
--- 51,68 ----
 characters except the dot used for Python package names are
 collapsed and replaced with a single underscore, e.g. ' -;#'
! 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.
 
 """
! # 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):

AltStyle によって変換されたページ (->オリジナル) /