Skip to content

[2.7] bpo-31920: Fixed handling directories as arguments in the pygettext script. (GH-6259) #6436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ Jerzy Kozera
Maksim Kozyarchuk
Stefan Krah
Bob Kras
Oleg Krasnikov
Sebastian Kreft
Holger Krekel
Michael Kremer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed handling directories as arguments in the ``pygettext`` script. Based
on patch by Oleg Krasnikov.
34 changes: 14 additions & 20 deletions Tools/i18n/pygettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,25 +261,6 @@ def containsAny(str, set):
return 1 in [c in str for c in set]


def _visit_pyfiles(list, dirname, names):
"""Helper for getFilesForName()."""
# get extension for python source files
if not globals().has_key('_py_ext'):
global _py_ext
_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:
names.remove('CVS')

# 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]
)


def _get_modpkg_path(dotted_name, pathlist=None):
"""Get the filesystem path for a module or a package.

Expand Down Expand Up @@ -340,7 +321,20 @@ def getFilesForName(name):
if os.path.isdir(name):
# find all python files in directory
list = []
os.path.walk(name, _visit_pyfiles, list)
# get extension for python source files
if '_py_ext' not in globals():
global _py_ext
_py_ext = [triple[0] for triple in imp.get_suffixes()
if triple[2] == imp.PY_SOURCE][0]
for root, dirs, files in os.walk(name):
# don't recurse into CVS directories
if 'CVS' in dirs:
dirs.remove('CVS')
# add all *.py files to list
list.extend(
[os.path.join(root, file) for file in files
if os.path.splitext(file)[1] == _py_ext]
)
return list
elif os.path.exists(name):
# a single file
Expand Down