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
e04ee70a
Commit
e04ee70a
authored
Apr 16, 2003
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mostly reformatting, splitting long lines, whitespace normalization
etc. Fixed one typo in the __main__ section.
parent
2ed6dff7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
33 deletions
+35
-33
Tools/i18n/pygettext.py
Tools/i18n/pygettext.py
+35
-33
No files found.
Tools/i18n/pygettext.py
View file @
e04ee70a
...
...
@@ -156,7 +156,9 @@ If `inputfile' is -, standard input is read.
"""
)
import
os
import
imp
import
sys
import
glob
import
time
import
getopt
import
token
...
...
@@ -256,19 +258,17 @@ def normalize(s):
def
containsAny
(
str
,
set
):
""" Check whether 'str' contains ANY of the chars in 'set'
"""
"""Check whether 'str' contains ANY of the chars in 'set'"""
return
1
in
[
c
in
str
for
c
in
set
]
def
_visit_pyfiles
(
list
,
dirname
,
names
):
""" Helper for getFilesForName().
"""
"""Helper for getFilesForName()."""
# get extension for python source files
if
not
globals
().
has_key
(
'_py_ext'
):
import
imp
global
_py_ext
_py_ext
=
[
triple
[
0
]
for
triple
in
imp
.
get_suffixes
()
if
triple
[
2
]
==
imp
.
PY_SOURCE
][
0
]
_py_ext
=
[
triple
[
0
]
for
triple
in
imp
.
get_suffixes
()
if
triple
[
2
]
==
imp
.
PY_SOURCE
][
0
]
# don't recurse into CVS directories
if
'CVS'
in
names
:
...
...
@@ -276,20 +276,18 @@ def _visit_pyfiles(list, dirname, names):
# add all *.py files to list
list
.
extend
(
[
os
.
path
.
join
(
dirname
,
file
)
for
file
in
names
if
os
.
path
.
splitext
(
file
)[
1
]
==
_py_ext
]
)
[
os
.
path
.
join
(
dirname
,
file
)
for
file
in
names
if
os
.
path
.
splitext
(
file
)[
1
]
==
_py_ext
]
)
def
_get_modpkg_path
(
dotted_name
,
pathlist
=
None
):
"""
Get the filesystem path for a module or a package.
"""Get the filesystem path for a module or a package.
Return the file system path to a file for a module,
and to a directory for a package. Return None if
the name is not found, or is a builtin or
extension module.
Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module.
"""
import
imp
# split off top-most name
parts
=
dotted_name
.
split
(
'.'
,
1
)
...
...
@@ -310,8 +308,10 @@ def _get_modpkg_path(dotted_name, pathlist=None):
else
:
# plain name
try
:
file
,
pathname
,
description
=
imp
.
find_module
(
dotted_name
,
pathlist
)
if
file
:
file
.
close
()
file
,
pathname
,
description
=
imp
.
find_module
(
dotted_name
,
pathlist
)
if
file
:
file
.
close
()
if
description
[
2
]
not
in
[
imp
.
PY_SOURCE
,
imp
.
PKG_DIRECTORY
]:
pathname
=
None
except
ImportError
:
...
...
@@ -321,15 +321,12 @@ def _get_modpkg_path(dotted_name, pathlist=None):
def
getFilesForName
(
name
):
"""
Get a list of module files for a filename, a module or package name,
"""Get a list of module files for a filename, a module or package name,
or a directory.
"""
import
imp
if
not
os
.
path
.
exists
(
name
):
# check for glob chars
if
containsAny
(
name
,
"*?[]"
):
import
glob
files
=
glob
.
glob
(
name
)
list
=
[]
for
file
in
files
:
...
...
@@ -426,8 +423,13 @@ class TokenEater:
elif
ttype
not
in
[
tokenize
.
COMMENT
,
token
.
INDENT
,
token
.
DEDENT
,
token
.
NEWLINE
,
tokenize
.
NL
]:
# warn if we see anything else than STRING or whitespace
print
>>
sys
.
stderr
,
_
(
'*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"'
)
%
{
'token'
:
tstring
,
'file'
:
self
.
__curfile
,
'lineno'
:
self
.
__lineno
}
print
>>
sys
.
stderr
,
_
(
'*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"'
)
%
{
'token'
:
tstring
,
'file'
:
self
.
__curfile
,
'lineno'
:
self
.
__lineno
}
self
.
__state
=
self
.
__waiting
def
__addentry
(
self
,
msg
,
lineno
=
None
,
isdocstring
=
0
):
...
...
@@ -662,6 +664,6 @@ if __name__ == '__main__':
main
()
# some more test strings
_
(
u'a unicode string'
)
_
(
'*** Seen unexpected token "%(token)s"'
%
{
'token'
:
'test'
})
# this one creates a warning
# this one creates a warning
_
(
'*** Seen unexpected token "%(token)s"'
)
%
{
'token'
:
'test'
}
_
(
'more'
'than'
'one'
'string'
)
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