mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-22 09:57:15 +01:00
Code simplifications - use enumerate
This commit is contained in:
parent
7541929609
commit
d23490287a
@ -622,8 +622,8 @@ class BuildContext(Context.Context):
|
||||
:type tg: :py:class:`waflib.TaskGen.task_gen`
|
||||
"""
|
||||
se = id(tg)
|
||||
for i in range(len(self.groups)):
|
||||
for t in self.groups[i]:
|
||||
for i, tmp in enumerate(self.groups):
|
||||
for t in tmp:
|
||||
if id(t) == se:
|
||||
return i
|
||||
return None
|
||||
@ -663,8 +663,8 @@ class BuildContext(Context.Context):
|
||||
"""
|
||||
if isinstance(idx, str):
|
||||
g = self.group_names[idx]
|
||||
for i in range(len(self.groups)):
|
||||
if id(g) == id(self.groups[i]):
|
||||
for i, tmp in enumerate(self.groups):
|
||||
if id(g) == id(tmp):
|
||||
self.current_group = i
|
||||
break
|
||||
else:
|
||||
|
@ -1008,11 +1008,10 @@ def compile_fun_noshell(line):
|
||||
buf = []
|
||||
dvars = []
|
||||
app = buf.append
|
||||
for x in range(len(extr)):
|
||||
for x, (var, meth) in enumerate(extr):
|
||||
params[x] = params[x].strip()
|
||||
if params[x]:
|
||||
app("lst.extend(%r)" % params[x].split())
|
||||
(var, meth) = extr[x]
|
||||
if var == 'SRC':
|
||||
if meth: app('lst.append(tsk.inputs%s)' % meth)
|
||||
else: app("lst.extend([a.path_from(cwdx) for a in tsk.inputs])")
|
||||
|
@ -165,8 +165,7 @@ Operator precendence rules required for parsing expressions of the form::
|
||||
#if 1 && 2 != 0
|
||||
"""
|
||||
ops = ['* / %', '+ -', '<< >>', '< <= >= >', '== !=', '& | ^', '&& ||', ',']
|
||||
for x in range(len(ops)):
|
||||
syms = ops[x]
|
||||
for x, syms in enumerate(ops):
|
||||
for u in syms.split():
|
||||
prec[u] = x
|
||||
|
||||
@ -447,8 +446,8 @@ def reduce_tokens(lst, defs, ban=[]):
|
||||
del lst[i]
|
||||
accu = to_add[:]
|
||||
reduce_tokens(accu, defs, ban+[v])
|
||||
for x in range(len(accu)):
|
||||
lst.insert(i, accu[x])
|
||||
for tmp in accu:
|
||||
lst.insert(i, tmp)
|
||||
i += 1
|
||||
else:
|
||||
# collect the arguments for the funcall
|
||||
|
Loading…
Reference in New Issue
Block a user