Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
31e87203
Commit
31e87203
authored
Dec 23, 2010
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kill some function imports
parent
a91dd1e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
Lib/gettext.py
Lib/gettext.py
+14
-16
No files found.
Lib/gettext.py
View file @
31e87203
...
...
@@ -46,7 +46,7 @@ internationalized, to the local language and cultural habits.
# 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 @@ def c2py(plural):
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 c2py(plural):
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 = loc
ale
.find('
@
')
pos = loc.find('
@
')
if pos >= 0:
modifier = loc
ale
[pos:]
loc
ale = locale
[:pos]
modifier = loc[pos:]
loc
= loc
[:pos]
mask |= COMPONENT_MODIFIER
else:
modifier = ''
pos = loc
ale
.find('
.
')
pos = loc.find('
.
')
if pos >= 0:
codeset = loc
ale
[pos:]
loc
ale = locale
[:pos]
codeset = loc[pos:]
loc
= loc
[:pos]
mask |= COMPONENT_CODESET
else:
codeset = ''
pos = loc
ale
.find('
_
')
pos = loc.find('
_
')
if pos >= 0:
territory = loc
ale
[pos:]
loc
ale = locale
[:pos]
territory = loc[pos:]
loc
= loc
[:pos]
mask |= COMPONENT_TERRITORY
else:
territory = ''
language = loc
ale
language = loc
ret = []
for i in range(mask+1):
if not (i & ~mask): # if all components for this combo exist ...
...
...
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