Permalink
Browse files

Merge pull request #3056 from charris/2to3-filter

2to3: Apply `filter` fixes. Closes #3053.
  • Loading branch information...
2 parents 02cfcb9 + 0e4e508 commit 3c13c0a925276130d66be490eed4ae337712cce2 @charris charris committed Mar 1, 2013
View
@@ -207,7 +207,7 @@ def __call__(self,*packages, **options):
if symbols is None:
symbols = eval('dir(%s)' % (package_name),
frame.f_globals,frame.f_locals)
- symbols = filter(lambda s:not s.startswith('_'),symbols)
+ symbols = [s for s in symbols if not s.startswith('_')]
else:
symbols = [symbol]
@@ -21,7 +21,7 @@ def find_package_modules(self, package, package_dir):
def find_modules(self):
old_py_modules = self.py_modules[:]
- new_py_modules = filter(is_string, self.py_modules)
+ new_py_modules = [_m for _m in self.py_modules if is_string(_m)]
self.py_modules[:] = new_py_modules
modules = old_build_py.find_modules(self)
self.py_modules[:] = old_py_modules
@@ -186,8 +186,8 @@ def build_data_files_sources(self):
build_dir = self.get_package_dir('.'.join(d.split(os.sep)))
else:
build_dir = os.path.join(self.build_src,d)
- funcs = filter(lambda f:hasattr(f, '__call__'), files)
- files = filter(lambda f:not hasattr(f, '__call__'), files)
+ funcs = [f for f in files if hasattr(f, '__call__')]
+ files = [f for f in files if not hasattr(f, '__call__')]
for f in funcs:
if f.__code__.co_argcount==1:
s = f(build_dir)
@@ -555,7 +555,7 @@ def general_source_directories_files(top_path):
def get_ext_source_files(ext):
# Get sources and any include files in the same directory.
filenames = []
- sources = filter(is_string, ext.sources)
+ sources = [_m for _m in ext.sources if is_string(_m)]
filenames.extend(sources)
filenames.extend(get_dependencies(sources))
for d in ext.depends:
@@ -566,13 +566,13 @@ def get_ext_source_files(ext):
return filenames
def get_script_files(scripts):
- scripts = filter(is_string, scripts)
+ scripts = [_m for _m in scripts if is_string(_m)]
return scripts
def get_lib_source_files(lib):
filenames = []
sources = lib[1].get('sources',[])
- sources = filter(is_string, sources)
+ sources = [_m for _m in sources if is_string(_m)]
filenames.extend(sources)
filenames.extend(get_dependencies(sources))
depends = lib[1].get('depends',[])
@@ -808,7 +808,7 @@ def _wildcard_get_subpackage(self, subpackage_name,
caller_level = 1):
l = subpackage_name.split('.')
subpackage_path = njoin([self.local_path]+l)
- dirs = filter(os.path.isdir,glob.glob(subpackage_path))
+ dirs = [_m for _m in glob.glob(subpackage_path) if os.path.isdir(_m)]
config_list = []
for d in dirs:
if not os.path.isfile(njoin(d,'__init__.py')):
@@ -232,9 +232,9 @@ def libpaths(paths, bits):
default_include_dirs.append(os.path.join(sys.prefix, 'include'))
default_src_dirs.append(os.path.join(sys.prefix, 'src'))
-default_lib_dirs = filter(os.path.isdir, default_lib_dirs)
-default_include_dirs = filter(os.path.isdir, default_include_dirs)
-default_src_dirs = filter(os.path.isdir, default_src_dirs)
+default_lib_dirs = [_m for _m in default_lib_dirs if os.path.isdir(_m)]
+default_include_dirs = [_m for _m in default_include_dirs if os.path.isdir(_m)]
+default_src_dirs = [_m for _m in default_src_dirs if os.path.isdir(_m)]
so_ext = get_shared_lib_extension()
View
@@ -430,13 +430,15 @@ def run_compile():
remove_build_dir = 1
build_dir = os.path.join(tempfile.mktemp())
- sysinfo_flags = filter(re.compile(r'[-][-]link[-]').match,sys.argv[1:])
- sys.argv = filter(lambda a,flags=sysinfo_flags:a not in flags,sys.argv)
+ _reg1 = re.compile(r'[-][-]link[-]')
+ sysinfo_flags = [_m for _m in sys.argv[1:] if _reg1.match(_m)]
+ sys.argv = [_m for _m in sys.argv if _m not in sysinfo_flags]
if sysinfo_flags:
sysinfo_flags = [f[7:] for f in sysinfo_flags]
- f2py_flags = filter(re.compile(r'[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include').match,sys.argv[1:])
- sys.argv = filter(lambda a,flags=f2py_flags:a not in flags,sys.argv)
+ _reg2 = re.compile(r'[-][-]((no[-]|)(wrap[-]functions|lower)|debug[-]capi|quiet)|[-]include')
+ f2py_flags = [_m for _m in sys.argv[1:] if _reg2.match(_m)]
+ sys.argv = [_m for _m in sys.argv if _m not in f2py_flags]
f2py_flags2 = []
fl = 0
for a in sys.argv[1:]:
@@ -450,12 +452,13 @@ def run_compile():
f2py_flags2.append(':')
f2py_flags.extend(f2py_flags2)
- sys.argv = filter(lambda a,flags=f2py_flags2:a not in flags,sys.argv)
-
- flib_flags = filter(re.compile(r'[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)').match,sys.argv[1:])
- sys.argv = filter(lambda a,flags=flib_flags:a not in flags,sys.argv)
- fc_flags = filter(re.compile(r'[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))').match,sys.argv[1:])
- sys.argv = filter(lambda a,flags=fc_flags:a not in flags,sys.argv)
+ sys.argv = [_m for _m in sys.argv if _m not in f2py_flags2]
+ _reg3 = re.compile(r'[-][-]((f(90)?compiler([-]exec|)|compiler)=|help[-]compiler)')
+ flib_flags = [_m for _m in sys.argv[1:] if _reg3.match(_m)]
+ sys.argv = [_m for _m in sys.argv if _m not in flib_flags]
+ _reg4 = re.compile(r'[-][-]((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help[-]fcompiler))')
+ fc_flags = [_m for _m in sys.argv[1:] if _reg4.match(_m)]
+ sys.argv = [_m for _m in sys.argv if _m not in fc_flags]
if 1:
del_list = []
@@ -481,8 +484,11 @@ def run_compile():
i = flib_flags.index(s)
del flib_flags[i]
assert len(flib_flags)<=2,`flib_flags`
- setup_flags = filter(re.compile(r'[-][-](verbose)').match,sys.argv[1:])
- sys.argv = filter(lambda a,flags=setup_flags:a not in flags,sys.argv)
+
+ _reg5 = re.compile(r'[-][-](verbose)')
+ setup_flags = [_m for _m in sys.argv[1:] if _reg5.match(_m)]
+ sys.argv = [_m for _m in sys.argv if _m not in setup_flags]
+
if '--quiet' in f2py_flags:
setup_flags.append('--quiet')
View
@@ -1050,7 +1050,7 @@ def decorate_methods(cls, decorator, testmatch=None):
# delayed import to reduce startup time
from inspect import isfunction
- methods = filter(isfunction, cls_attr.values())
+ methods = [_m for _m in cls_attr.values() if isfunction(_m)]
for function in methods:
try:
if hasattr(function, 'compat_func_name'):
View
@@ -50,7 +50,7 @@
URL = "http://www.numpy.org"
DOWNLOAD_URL = "http://sourceforge.net/projects/numpy/files/NumPy/"
LICENSE = 'BSD'
-CLASSIFIERS = filter(None, CLASSIFIERS.split('\n'))
+CLASSIFIERS = [_f for _f in CLASSIFIERS.split('\n') if _f]
AUTHOR = "Travis E. Oliphant et al."
AUTHOR_EMAIL = "oliphant@enthought.com"
PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]

0 comments on commit 3c13c0a

Please sign in to comment.