[Python-checkins] r87459 - python/branches/py3k/Lib/gettext.py

benjamin.peterson python-checkins at python.org
Thu Dec 23 23:53:42 CET 2010


Author: benjamin.peterson
Date: Thu Dec 23 23:53:42 2010
New Revision: 87459
Log:
kill some function imports
Modified:
 python/branches/py3k/Lib/gettext.py
Modified: python/branches/py3k/Lib/gettext.py
==============================================================================
--- python/branches/py3k/Lib/gettext.py	(original)
+++ python/branches/py3k/Lib/gettext.py	Thu Dec 23 23:53:42 2010
@@ -46,7 +46,7 @@
 # find this format documented anywhere.
 
 
-import locale, copy, os, re, struct, sys
+import locale, copy, io, os, re, struct, sys
 from errno import ENOENT
 
 
@@ -63,9 +63,8 @@
 Python lambda function that implements an equivalent expression.
 """
 # Security check, allow only the "n" identifier
- from io import StringIO
 import token, tokenize
- tokens = tokenize.generate_tokens(StringIO(plural).readline)
+ tokens = tokenize.generate_tokens(io.StringIO(plural).readline)
 try:
 danger = [x for x in tokens if x[0] == token.NAME and x[1] != 'n']
 except tokenize.TokenError:
@@ -109,36 +108,35 @@
 
 
 
-def _expand_lang(locale):
- from locale import normalize
- locale = normalize(locale)
+def _expand_lang(loc):
+ loc = locale.normalize(loc)
 COMPONENT_CODESET = 1 << 0
 COMPONENT_TERRITORY = 1 << 1
 COMPONENT_MODIFIER = 1 << 2
 # split up the locale into its base components
 mask = 0
- pos = locale.find('@')
+ pos = loc.find('@')
 if pos >= 0:
- modifier = locale[pos:]
- locale = locale[:pos]
+ modifier = loc[pos:]
+ loc = loc[:pos]
 mask |= COMPONENT_MODIFIER
 else:
 modifier = ''
- pos = locale.find('.')
+ pos = loc.find('.')
 if pos >= 0:
- codeset = locale[pos:]
- locale = locale[:pos]
+ codeset = loc[pos:]
+ loc = loc[:pos]
 mask |= COMPONENT_CODESET
 else:
 codeset = ''
- pos = locale.find('_')
+ pos = loc.find('_')
 if pos >= 0:
- territory = locale[pos:]
- locale = locale[:pos]
+ territory = loc[pos:]
+ loc = loc[:pos]
 mask |= COMPONENT_TERRITORY
 else:
 territory = ''
- language = locale
+ language = loc
 ret = []
 for i in range(mask+1):
 if not (i & ~mask): # if all components for this combo exist ...


More information about the Python-checkins mailing list

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