Tuples in startswith/endswith (Python 2.5 feature)

This commit is contained in:
Thomas Nagy 2016-04-21 22:30:35 +02:00
parent d2ba87b296
commit b87a761ead
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
9 changed files with 25 additions and 25 deletions

View File

@ -20,7 +20,7 @@ def build(bld):
for x in txt.splitlines():
if not x:
continue
elif x.startswith('\t') or x.startswith(' '):
elif x.startswith(('\t', ' ')):
tg.rule = x.lstrip()
else:
line = x.split(':')

View File

@ -52,7 +52,7 @@ def distclean(ctx):
from waflib import Context
for fn in os.listdir('.'):
if fn.startswith('.conf_check_') or fn.startswith(".lock-w") \
if fn.startswith(('.conf_check_', ".lock-w")) \
or fn in (Context.DBFILE, 'config.log') \
or fn == 'c4che':
if os.path.isdir(fn):

View File

@ -234,7 +234,7 @@ run
for tgen in bld.get_all_task_gen():
tgen.update_outputs=True
if bld.cmd == 'clean':
for tgen in bld.get_all_task_gen():
for tgt in waflib.Utils.to_list(tgen.target):
@ -259,13 +259,13 @@ run
shutil.rmtree(x)
except:
pass
def distclean(ctx):
import os, shutil
from waflib import Context
for fn in os.listdir('.'):
if fn.startswith('.conf_check_') or fn.startswith(".lock-w") \
if fn.startswith(('.conf_check_', ".lock-w")) \
or fn in (Context.DBFILE, 'config.log') \
or fn == 'c4che':
if os.path.isdir(fn):

View File

@ -426,7 +426,7 @@ class Task(TaskBase):
"string to display to the user"
name = self.__class__.__name__
if self.outputs:
if (name.endswith('lib') or name.endswith('program')) or not self.inputs:
if name.endswith(('lib', 'program')) or not self.inputs:
node = self.outputs[0]
return node.path_from(node.ctx.launch_node())
if not (self.inputs or self.outputs):
@ -443,7 +443,7 @@ class Task(TaskBase):
def keyword(self):
name = self.__class__.__name__
if name.endswith('lib') or name.endswith('program'):
if name.endswith(('lib', 'program')):
return 'Linking'
if len(self.inputs) == 1 and len(self.outputs) == 1:
return 'Compiling'

View File

@ -199,20 +199,20 @@ def parse_flags(self, line, uselib_store, env=None, force_static=False, posix=No
static = False
elif x.startswith('-Wl'):
app('LINKFLAGS', x)
elif x.startswith('-m') or x.startswith('-f') or x.startswith('-dynamic'):
elif x.startswith(('-m', '-f', '-dynamic')):
app('CFLAGS', x)
app('CXXFLAGS', x)
elif x.startswith('-bundle'):
app('LINKFLAGS', x)
elif x.startswith('-undefined') or x.startswith('-Xlinker'):
elif x.startswith(('-undefined', '-Xlinker')):
arg = lst.pop(0)
app('LINKFLAGS', [x, arg])
elif x.startswith('-arch') or x.startswith('-isysroot'):
elif x.startswith(('-arch', '-isysroot')):
tmp = [x, lst.pop(0)]
app('CFLAGS', tmp)
app('CXXFLAGS', tmp)
app('LINKFLAGS', tmp)
elif x.endswith('.a') or x.endswith('.so') or x.endswith('.dylib') or x.endswith('.lib'):
elif x.endswith(('.a', '.so', '.dylib', '.lib')):
appu('LINKFLAGS', x) # not cool, #762
@conf

View File

@ -435,7 +435,7 @@ def split_path_win32(path):
msysroot = None
def split_path_msys(path):
if (path.startswith('/') or path.startswith('\\')) and not path.startswith('//') and not path.startswith('\\\\'):
if path.startswith(('/', '\\')) and not path.startswith(('\\', '\\\\')):
# msys paths can be in the form /usr/bin
global msysroot
if not msysroot:

View File

@ -269,14 +269,14 @@ def compile_template(line):
app("lst.append(%r)" % params[x])
f = extr[x]
if f.startswith('if') or f.startswith('for'):
if f.startswith(('if', 'for')):
app(f + ':')
indent += 1
elif f.startswith('py:'):
app(f[3:])
elif f.startswith('endif') or f.startswith('endfor'):
elif f.startswith(('endif', 'endfor')):
indent -= 1
elif f.startswith('else') or f.startswith('elif'):
elif f.startswith(('else', 'elif')):
indent -= 1
app(f + ':')
indent += 1
@ -491,7 +491,7 @@ class vsnode_project(vsnode):
required for writing the source files
"""
name = node.name
if name.endswith('.cpp') or name.endswith('.c'):
if name.endswith(('.cpp', '.c')):
return 'sourcefile'
return 'headerfile'
@ -511,7 +511,7 @@ class vsnode_project(vsnode):
x.preprocessor_definitions = ''
x.includes_search_path = ''
# can specify "deploy_dir" too
# can specify "deploy_dir" too
ret.append(x)
self.build_properties = ret

View File

@ -318,14 +318,14 @@ def compile_template(line):
app("lst.append(%r)" % params[x])
f = extr[x]
if f.startswith('if') or f.startswith('for'):
if f.startswith(('if', 'for')):
app(f + ':')
indent += 1
elif f.startswith('py:'):
app(f[3:])
elif f.startswith('endif') or f.startswith('endfor'):
elif f.startswith(('endif', 'endfor')):
indent -= 1
elif f.startswith('else') or f.startswith('elif'):
elif f.startswith(('else', 'elif')):
indent -= 1
app(f + ':')
indent += 1
@ -364,7 +364,7 @@ def stealth_write(self, data, flags='wb'):
data = data.decode(sys.getfilesystemencoding(), 'replace')
data = data.encode('utf-8')
if self.name.endswith('.vcproj') or self.name.endswith('.vcxproj'):
if self.name.endswith(('.vcproj', '.vcxproj')):
data = BOM + data
try:
@ -549,7 +549,7 @@ class vsnode_project(vsnode):
required for writing the source files
"""
name = node.name
if name.endswith('.cpp') or name.endswith('.c'):
if name.endswith(('.cpp', '.c')):
return 'ClCompile'
return 'ClInclude'

View File

@ -150,14 +150,14 @@ def compile_template(line):
app("lst.append(%r)" % params[x])
f = extr[x]
if f.startswith('if') or f.startswith('for'):
if f.startswith(('if', 'for')):
app(f + ':')
indent += 1
elif f.startswith('py:'):
app(f[3:])
elif f.startswith('endif') or f.startswith('endfor'):
elif f.startswith(('endif', 'endfor')):
indent -= 1
elif f.startswith('else') or f.startswith('elif'):
elif f.startswith(('else', 'elif')):
indent -= 1
app(f + ':')
indent += 1