2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-12-23 09:45:13 +01:00

remove more except: lines

This commit is contained in:
Thomas Nagy 2012-02-11 14:43:07 +01:00
parent d8f192fbc2
commit 63d3442ad2
4 changed files with 49 additions and 44 deletions

View File

@ -196,12 +196,12 @@ class Node(object):
shutil.rmtree(self.abspath())
else:
os.unlink(self.abspath())
except:
except OSError:
pass
try:
delattr(self, 'children')
except:
except AttributeError:
pass
def suffix(self):
@ -234,7 +234,7 @@ class Node(object):
try:
self.parent.mkdir()
except:
except OSError:
pass
if self.name:
@ -248,7 +248,7 @@ class Node(object):
try:
self.children
except:
except AttributeError:
self.children = {}
self.cache_isdir = True
@ -271,17 +271,21 @@ class Node(object):
continue
try:
if x in cur.children:
ch = cur.children
except AttributeError:
cur.children = {}
else:
try:
cur = cur.children[x]
continue
except:
cur.children = {}
except KeyError:
pass
# optimistic: create the node first then look if it was correct to do so
cur = self.__class__(x, cur)
try:
os.stat(cur.abspath())
except:
except OSError:
del cur.parent.children[x]
return None
@ -289,7 +293,7 @@ class Node(object):
try:
os.stat(ret.abspath())
except:
except OSError:
del ret.parent.children[ret.name]
return None
@ -338,15 +342,15 @@ class Node(object):
lst = [x for x in split_path(lst) if x and x != '.']
cur = self
try:
for x in lst:
if x == '..':
cur = cur.parent or cur
else:
for x in lst:
if x == '..':
cur = cur.parent or cur
else:
try:
cur = cur.children[x]
return cur
except:
pass
except (AttributeError, KeyError):
return None
return cur
def path_from(self, node):
"""
@ -398,7 +402,7 @@ class Node(object):
"""
try:
return self.cache_abspath
except:
except AttributeError:
pass
# think twice before touching this (performance + complexity + correctness)
@ -460,11 +464,12 @@ class Node(object):
try:
lst = set(self.children.keys())
except AttributeError:
self.children = {}
else:
if remove:
for x in lst - set(dircont):
del self.children[x]
except:
self.children = {}
for name in dircont:
npats = accept(name, pats)
@ -677,12 +682,8 @@ class Node(object):
if not node:
self = self.get_src()
node = self.find_node(lst)
try:
pat = node.abspath()
if os.path.isdir(pat):
return None
except:
pass
if os.path.isdir(node.abspath()):
return None
return node
def find_or_declare(self, lst):
@ -704,7 +705,7 @@ class Node(object):
node.sig = None
try:
node.parent.mkdir()
except:
except OSError:
pass
return node
self = self.get_src()
@ -714,7 +715,7 @@ class Node(object):
node.sig = None
try:
node.parent.mkdir()
except:
except OSError:
pass
return node
node = self.get_bld().make_node(lst)

View File

@ -10,7 +10,7 @@ Runner.py: Task scheduling and execution
import random, atexit
try:
from queue import Queue
except:
except ImportError:
from Queue import Queue
from waflib import Utils, Task, Errors, Logs
@ -40,7 +40,7 @@ class TaskConsumer(Utils.threading.Thread):
"""
try:
self.loop()
except:
except Exception:
pass
def loop(self):
@ -70,7 +70,7 @@ def get_pool():
"""
try:
return pool.get(False)
except:
except Exception:
return TaskConsumer()
def put_pool(x):
@ -176,7 +176,7 @@ class Parallel(object):
elif self.frozen:
try:
cond = self.deadlock == self.processed
except:
except AttributeError:
pass
else:
if cond:
@ -268,7 +268,7 @@ class Parallel(object):
self.out.put(self)
try:
pool = self.pool
except:
except AttributeError:
pass
else:
for x in pool:

View File

@ -230,7 +230,7 @@ class TaskBase(evil):
# in case of failure the task will be executed again
try:
del self.generator.bld.task_sigs[self.uid()]
except:
except KeyError:
pass
try:
@ -707,7 +707,7 @@ class Task(TaskBase):
try:
if prev == self.compute_sig_implicit_deps():
return prev
except:
except Exception:
# when a file was renamed (IOError usually), remove the stale nodes (headers in folders without source files)
# this will break the order calculation for headers created during the build in the source directory (should be uncommon)
# the behaviour will differ when top != out
@ -715,10 +715,10 @@ class Task(TaskBase):
if x.is_child_of(bld.srcnode):
try:
os.stat(x.abspath())
except:
except OSErrror:
try:
del x.parent.children[x.name]
except:
except KeyError:
pass
del bld.task_sigs[(key, 'imp')]
raise Errors.TaskRescan('rescan')
@ -738,12 +738,12 @@ class Task(TaskBase):
# recompute the signature and return it
try:
bld.task_sigs[(key, 'imp')] = sig = self.compute_sig_implicit_deps()
except:
except Exception:
if Logs.verbose:
for k in bld.node_deps.get(self.uid(), []):
try:
k.get_bld_sig()
except:
except Exception:
Logs.warn('Missing signature for node %r (may cause rebuilds)' % k)
else:
return sig
@ -780,7 +780,7 @@ class Task(TaskBase):
bld = self.generator.bld
try:
cache = bld.dct_implicit_nodes
except:
except AttributeError:
bld.dct_implicit_nodes = cache = {}
try:
@ -878,7 +878,7 @@ class Task(TaskBase):
try:
shutil.rmtree(dname)
except:
except Exception:
pass
try:
@ -888,7 +888,7 @@ class Task(TaskBase):
except (OSError, IOError):
try:
shutil.rmtree(tmpdir)
except:
except Exception:
pass
else:
try:
@ -896,12 +896,12 @@ class Task(TaskBase):
except OSError:
try:
shutil.rmtree(tmpdir)
except:
except Exception:
pass
else:
try:
os.chmod(dname, Utils.O755)
except:
except Exception:
pass
def is_before(t1, t2):

View File

@ -1127,6 +1127,9 @@ class cfgtask(Task.TaskBase):
def runnable_status(self):
return Task.RUN_ME
def uid(self):
return Utils.SIG_NIL
def run(self):
conf = self.conf
bld = Build.BuildContext(top_dir=conf.srcnode.abspath(), out_dir=conf.bldnode.abspath())
@ -1152,6 +1155,7 @@ def multicheck(self, *k, **kw):
self.cache_global = Options.cache_global
self.nocache = Options.options.nocache
self.returned_tasks = []
self.task_sigs = {}
def total(self):
return len(tasks)
def to_log(self, *k, **kw):