treecleaner: 'in [...]' replaced by 'in (...)' where appropriate

This commit is contained in:
Jérôme Carretero 2014-01-05 16:27:06 -05:00
parent d01f7f36e0
commit 33a60e79e7
24 changed files with 41 additions and 41 deletions

View File

@ -72,7 +72,7 @@ def init(ctx):
def buildall(ctx):
import waflib.Options
for x in ['build_debug', 'build_release']:
for x in ('build_debug', 'build_release'):
waflib.Options.commands.insert(0, x)
## if you work on "debug" 99% of the time, here is how to re-enable "waf build":

View File

@ -23,7 +23,7 @@ def build(bld):
if ret != 0:
raise Exception("command failed in %s: %s" % (task.generator.cwd, cmd))
waf_dirs = [ os.path.join(bld.path.abspath(), "snippets", d) for d in ["waf-1", "waf-2"] ]
waf_dirs = [ os.path.join(bld.path.abspath(), "snippets", d) for d in ("waf-1", "waf-2") ]
for d in waf_dirs:
bld(
rule=waf_cmd,
@ -32,7 +32,7 @@ def build(bld):
name=d,
)
make_dirs = [ os.path.join(bld.path.abspath(), "snippets", d) for d in ["make-1", "make-2"] ]
make_dirs = [ os.path.join(bld.path.abspath(), "snippets", d) for d in ("make-1", "make-2") ]
for d in make_dirs:
bld(
rule="make -B > output",

View File

@ -66,7 +66,7 @@ class package_cls(Build.InstallContext):
# for variants, add command subclasses "package_release", "package_debug", etc
def init(ctx):
for x in ['release', 'debug']:
for x in ('release', 'debug'):
class tmp(package_cls):
cmd = 'package_' + x
variant = x

View File

@ -73,7 +73,7 @@ def unpack_wafdir(dir):
try: shutil.rmtree(dir)
except OSError: pass
try:
for x in ['Tools', 'extras']:
for x in ('Tools', 'extras'):
os.makedirs(join(dir, 'waflib', x))
except OSError:
err("Cannot unpack waf lib into %s\nMove waf in a writable directory" % dir)
@ -102,7 +102,7 @@ def unpack_wafdir(dir):
finally:
t.close()
for x in ['Tools', 'extras']:
for x in ('Tools', 'extras'):
os.chmod(join('waflib',x), 493)
if sys.hexversion<0x300000f:
@ -143,7 +143,7 @@ def find_lib():
err('waf-light requires waflib -> export WAFDIR=/folder')
dirname = '%s-%s-%s' % (WAF, VERSION, REVISION)
for i in [INSTALL,'/usr','/usr/local','/opt']:
for i in (INSTALL,'/usr','/usr/local','/opt'):
w = test(i + '/lib/' + dirname)
if w: return w

View File

@ -107,7 +107,7 @@ class opt_parser(optparse.OptionParser):
if Context.g_module:
for (k, v) in Context.g_module.__dict__.items():
if k in ['options', 'init', 'shutdown']:
if k in ('options', 'init', 'shutdown'):
continue
if type(v) is type(Context.create_context):

View File

@ -63,7 +63,7 @@ def waf_entry_point(current_directory, version, wafdir):
pass
else:
# check if the folder was not moved
for x in [env.run_dir, env.top_dir, env.out_dir]:
for x in (env.run_dir, env.top_dir, env.out_dir):
if Utils.is_win32:
if cur == x:
load = True
@ -170,7 +170,7 @@ def set_main_module(file_path):
name = obj.__name__
if not name in Context.g_module.__dict__:
setattr(Context.g_module, name, obj)
for k in [update, dist, distclean, distcheck, update]:
for k in (update, dist, distclean, distcheck, update):
set_def(k)
# add dummy init and shutdown functions if they're not defined
if not 'init' in Context.g_module.__dict__:
@ -260,7 +260,7 @@ def distclean_dir(dirname):
except OSError:
Logs.warn('Could not remove %r' % fname)
for x in [Context.DBFILE, 'config.log']:
for x in (Context.DBFILE, 'config.log'):
try:
os.remove(x)
except OSError:

View File

@ -108,7 +108,7 @@ class task_gen(object):
"""for debugging purposes"""
lst = []
for x in self.__dict__.keys():
if x not in ['env', 'bld', 'compiled_tasks', 'tasks']:
if x not in ('env', 'bld', 'compiled_tasks', 'tasks'):
lst.append("%s=%s" % (x, repr(getattr(self, x))))
return "bld(%s) in %s" % (", ".join(lst), self.path.abspath())
@ -284,9 +284,9 @@ class task_gen(object):
"""
newobj = self.bld()
for x in self.__dict__:
if x in ['env', 'bld']:
if x in ('env', 'bld'):
continue
elif x in ['path', 'features']:
elif x in ('path', 'features'):
setattr(newobj, x, getattr(self, x))
else:
setattr(newobj, x, copy.copy(getattr(self, x)))
@ -585,7 +585,7 @@ def process_rule(self):
if getattr(self, 'always', None):
Task.always_run(cls)
for x in ['after', 'before', 'ext_in', 'ext_out']:
for x in ('after', 'before', 'ext_in', 'ext_out'):
setattr(cls, x, getattr(self, x, []))
if getattr(self, 'cache_rule', 'True'):

View File

@ -59,9 +59,9 @@ def sniff_features(**kw):
if 'java' in exts:
return 'java'
if type in ['program', 'shlib', 'stlib']:
if type in ('program', 'shlib', 'stlib'):
for x in feats:
if x in ['cxx', 'd', 'c']:
if x in ('cxx', 'd', 'c'):
feats.append(x + type)
return feats

View File

@ -540,7 +540,7 @@ def validate_c(self, kw):
if not 'errmsg' in kw:
kw['errmsg'] = 'no'
for (flagsname,flagstype) in [('cxxflags','compiler'), ('cflags','compiler'), ('linkflags','linker')]:
for (flagsname,flagstype) in (('cxxflags','compiler'), ('cflags','compiler'), ('linkflags','linker')):
if flagsname in kw:
if not 'msg' in kw:
kw['msg'] = 'Checking for %s flags %s' % (flagstype, kw[flagsname])

View File

@ -54,6 +54,6 @@ def options(opt):
d_compiler_opts = opt.add_option_group('D Compiler Options')
d_compiler_opts.add_option('--check-d-compiler', default='gdc,dmd,ldc2', action='store',
help='check for the compiler [Default:gdc,dmd,ldc2]', dest='dcheck')
for d_compiler in ['gdc', 'dmd', 'ldc2']:
for d_compiler in ('gdc', 'dmd', 'ldc2'):
opt.load('%s' % d_compiler)

View File

@ -92,7 +92,7 @@ def debug_cs(self):
def build(bld):
bld(features='cs', source='My.cs', bintype='library', gen='my.dll', csdebug='full')
# csdebug is a value in [True, 'full', 'pdbonly']
# csdebug is a value in (True, 'full', 'pdbonly')
"""
csdebug = getattr(self, 'csdebug', self.env.CSDEBUG)
if not csdebug:

View File

@ -197,7 +197,7 @@ def check_fortran_verbose_flag(self, *k, **kw):
Check what kind of verbose (-v) flag works, then set it to env.FC_VERBOSE_FLAG
"""
self.start_msg('fortran link verbose flag')
for x in ['-v', '--verbose', '-verbose', '-V']:
for x in ('-v', '--verbose', '-verbose', '-V'):
try:
self.check_cc(
features = 'fc fcprogram_test',
@ -395,9 +395,9 @@ def mangling_schemes():
(used in check_fortran_mangling)
the order is tuned for gfortan
"""
for u in ['_', '']:
for du in ['', '_']:
for c in ["lower", "upper"]:
for u in ('_', ''):
for du in ('', '_'):
for c in ("lower", "upper"):
yield (u, du, c)
def mangle_name(u, du, c, name):
@ -451,7 +451,7 @@ def set_lib_pat(self):
@conf
def detect_openmp(self):
for x in ['-fopenmp','-openmp','-mp','-xopenmp','-omp','-qsmp=omp']:
for x in ('-fopenmp','-openmp','-mp','-xopenmp','-omp','-qsmp=omp'):
try:
self.check_fc(
msg='Checking for OpenMP flag %s' % x,

View File

@ -269,7 +269,7 @@ def gather_msvc_detected_versions():
#Detected MSVC versions!
version_pattern = re.compile('^(\d\d?\.\d\d?)(Exp)?$')
detected_versions = []
for vcver,vcvar in [('VCExpress','Exp'), ('VisualStudio','')]:
for vcver,vcvar in (('VCExpress','Exp'), ('VisualStudio','')):
try:
prefix = 'SOFTWARE\\Wow6432node\\Microsoft\\'+vcver
all_versions = Utils.winreg.OpenKey(Utils.winreg.HKEY_LOCAL_MACHINE, prefix)
@ -495,7 +495,7 @@ def gather_intel_composer_versions(conf, versions):
setattr(conf, compilervars_warning_attr, False)
patch_url = 'http://software.intel.com/en-us/forums/topic/328487'
compilervars_arch = os.path.join(path, 'bin', 'compilervars_arch.bat')
for vscomntool in ['VS110COMNTOOLS', 'VS100COMNTOOLS']:
for vscomntool in ('VS110COMNTOOLS', 'VS100COMNTOOLS'):
if vscomntool in os.environ:
vs_express_path = os.environ[vscomntool] + r'..\IDE\VSWinExpress.exe'
dev_env_path = os.environ[vscomntool] + r'..\IDE\devenv.exe'

View File

@ -82,7 +82,7 @@ def feature_py(self):
else:
pyd = y.abspath ()
for ext in ["pyc", "pyo"]:
for ext in ("pyc", "pyo"):
if install_from:
pyobj = self.path.get_bld ().make_node (y
.change_ext (".%s" % ext)

View File

@ -361,7 +361,7 @@ def apply_qt4(self):
for flag in self.to_list(self.env['CXXFLAGS']):
if len(flag) < 2: continue
f = flag[0:2]
if f in ['-D', '-I', '/D', '/I']:
if f in ('-D', '-I', '/D', '/I'):
if (f[0] == '/'):
lst.append('-' + flag[1:])
else:
@ -504,7 +504,7 @@ def find_qt4_binaries(self):
# keep the one with the highest version
cand = None
prev_ver = ['4', '0', '0']
for qmk in ['qmake-qt4', 'qmake4', 'qmake']:
for qmk in ('qmake-qt4', 'qmake4', 'qmake'):
try:
qmake = self.find_program(qmk, path_list=paths)
except self.errors.ConfigurationError:

View File

@ -361,7 +361,7 @@ def apply_qt5(self):
for flag in self.to_list(self.env['CXXFLAGS']):
if len(flag) < 2: continue
f = flag[0:2]
if f in ['-D', '-I', '/D', '/I']:
if f in ('-D', '-I', '/D', '/I'):
if (f[0] == '/'):
lst.append('-' + flag[1:])
else:
@ -504,7 +504,7 @@ def find_qt5_binaries(self):
# keep the one with the highest version
cand = None
prev_ver = ['5', '0', '0']
for qmk in ['qmake-qt5', 'qmake5', 'qmake']:
for qmk in ('qmake-qt5', 'qmake5', 'qmake'):
try:
qmake = self.find_program(qmk, path_list=paths)
except self.errors.ConfigurationError:

View File

@ -56,7 +56,7 @@ def bibunitscan(self):
for match in re_bibunit.finditer(code):
path = match.group('file')
if path:
for k in ['', '.bib']:
for k in ('', '.bib'):
# add another loop for the tex include paths?
Logs.debug('tex: trying %s%s' % (path, k))
fi = node.parent.find_resource(path + k)
@ -418,7 +418,7 @@ def apply_tex(self):
"""
Create :py:class:`waflib.Tools.tex.tex` objects, and dvips/dvipdf/pdf2ps tasks if necessary (outs='ps', etc).
"""
if not getattr(self, 'type', None) in ['latex', 'pdflatex', 'xelatex']:
if not getattr(self, 'type', None) in ('latex', 'pdflatex', 'xelatex'):
self.type = 'pdflatex'
tree = self.bld

View File

@ -134,7 +134,7 @@ def link_after_masters(self):
# Modify the c and cxx task classes - in theory it would be better to
# create subclasses and to re-map the c/c++ extensions
#
for x in ['c', 'cxx']:
for x in ('c', 'cxx'):
t = Task.classes[x]
def run(self):
pass

View File

@ -118,7 +118,7 @@ class bjam_installer(Task):
def run(self):
gen = self.generator
path = gen.path
for idir, pat in [('${LIBDIR}', 'lib/*'), ('${BINDIR}', 'bin/*')]:
for idir, pat in (('${LIBDIR}', 'lib/*'), ('${BINDIR}', 'bin/*')):
files = []
for n in path.get_bld().ant_glob(pat):
try:

View File

@ -324,7 +324,7 @@ def check_boost(self, *k, **kw):
if params.get('linkage_autodetect', False):
self.start_msg("Attempting to detect boost linkage flags")
toolset = self.boost_get_toolset(kw.get('toolset', ''))
if toolset in ['vc']:
if toolset in ('vc',):
# disable auto-linking feature, causing error LNK1181
# because the code wants to be linked against
self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']

View File

@ -230,7 +230,7 @@ def configure(conf):
if conf.env.GO_PLATFORM == 'x86_64':
set_def('GO_COMPILER', '6g')
set_def('GO_LINKER', '6l')
elif conf.env.GO_PLATFORM in ['i386', 'i486', 'i586', 'i686']:
elif conf.env.GO_PLATFORM in ('i386', 'i486', 'i586', 'i686'):
set_def('GO_COMPILER', '8g')
set_def('GO_LINKER', '8l')
elif conf.env.GO_PLATFORM == 'arm':

View File

@ -44,7 +44,7 @@ class sas(Task.Task):
@feature('sas')
@before_method('process_source')
def apply_sas(self):
if not getattr(self, 'type', None) in ['sas']:
if not getattr(self, 'type', None) in ('sas',):
self.type = 'sas'
self.env['logdir'] = getattr(self, 'logdir', 'log')

View File

@ -155,7 +155,7 @@ def ti_dsplink_set_platform_flags(cfg, splat, dsp, dspbios_ver, board):
cfg.env.LINKFLAGS_DSPLINK += [
opj(cfg.env.TI_DSPLINK_DIR, 'dsplink', 'dsp', 'export', 'BIN', 'DspBios', splat, board+'_0', 'RELEASE', 'dsplink%s.lib' % x)
for x in ['', 'pool', 'mpcs', 'mplist', 'msg', 'data', 'notify', 'ringio']
for x in ('', 'pool', 'mpcs', 'mplist', 'msg', 'data', 'notify', 'ringio')
]

View File

@ -121,7 +121,7 @@ def compute_revision():
def visit(arg, dirname, names):
for pos, name in enumerate(names):
if name[0] == '.' or name in ['_build_', 'build']:
if name[0] == '.' or name in ('_build_', 'build'):
del names[pos]
elif name.endswith('.py'):
arg.append(os.path.join(dirname, name))