1 |
commit: bc8019e52ba29b30b528d31aa46180576e7d9dcb |
2 |
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
3 |
AuthorDate: Thu Feb 24 06:38:03 2011 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Sun Mar 27 02:39:13 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=bc8019e5 |
7 |
|
8 |
clean out excessive use of try: except pairs |
9 |
|
10 |
--- |
11 |
layman/dbbase.py | 29 +++++++++-------------------- |
12 |
1 files changed, 9 insertions(+), 20 deletions(-) |
13 |
|
14 |
diff --git a/layman/dbbase.py b/layman/dbbase.py |
15 |
index 53c2946..7b0a26a 100644 |
16 |
--- a/layman/dbbase.py |
17 |
+++ b/layman/dbbase.py |
18 |
@@ -94,10 +94,7 @@ class DbBase: |
19 |
if not os.path.exists(path): |
20 |
continue |
21 |
|
22 |
- try: |
23 |
- self.read_file(path) |
24 |
- except Exception, error: |
25 |
- if not ignore_init_read_errors: raise error |
26 |
+ self.read_file(path) |
27 |
|
28 |
|
29 |
def __eq__(self, other): |
30 |
@@ -118,8 +115,10 @@ class DbBase: |
31 |
document = open(path, 'r').read() |
32 |
|
33 |
except Exception, error: |
34 |
- raise IOError('Failed to read the overlay list at ("' |
35 |
- + path + '")!\nError was:\n' + str(error)) |
36 |
+ if not ignore_init_read_errors: |
37 |
+ self.output.error('Failed to read the overlay list at ("' |
38 |
+ + path + '")') |
39 |
+ raise error |
40 |
|
41 |
self.read(document, origin=path) |
42 |
|
43 |
@@ -153,15 +152,9 @@ class DbBase: |
44 |
|
45 |
for overlay in overlays: |
46 |
self.output.debug('Parsing overlay entry', 8) |
47 |
- try: |
48 |
- ovl = Overlay(config=self.config, xml=overlay, |
49 |
+ ovl = Overlay(config=self.config, xml=overlay, |
50 |
ignore=self.ignore, quiet=self.quiet) |
51 |
- except Exception, error: |
52 |
- raise error |
53 |
- self.output.warn("DbBase(); Error creating overlay instance", 3) |
54 |
- self.output.warn("Original error was: " + str(error), 3) |
55 |
- else: |
56 |
- self.overlays[ovl.name] = ovl |
57 |
+ self.overlays[ovl.name] = ovl |
58 |
return |
59 |
|
60 |
|
61 |
@@ -186,13 +179,9 @@ class DbBase: |
62 |
self.output.info("DbBase: add_from_dict()") |
63 |
for overlay in overlays: |
64 |
self.output.debug('Parsing overlay entry', 8) |
65 |
- try: |
66 |
- ovl = Overlay(self.config, ovl_dict=overlay, |
67 |
+ ovl = Overlay(self.config, ovl_dict=overlay, |
68 |
ignore=self.ignore, quiet=self.quiet) |
69 |
- except Exception, error: |
70 |
- self.output.warn(str(error), 3) |
71 |
- else: |
72 |
- self.overlays[ovl.name] = ovl |
73 |
+ self.overlays[ovl.name] = ovl |
74 |
return |