commit:     cc5128c7066d712a8f532ce33b6917a265f7c7e0
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Wed Jul  1 12:25:57 2015 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Wed Jul  1 12:25:57 2015 +0000
URL:        https://gitweb.gentoo.org/proj/grss.git/commit/?id=cc5128c7

grs/Interpret.py: remove excessive try-except block.

 grs/Interpret.py | 160 +++++++++++++++++++++++++++----------------------------
 1 file changed, 78 insertions(+), 82 deletions(-)

diff --git a/grs/Interpret.py b/grs/Interpret.py
index 8cef40e..6525c9e 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -109,92 +109,88 @@ class Interpret(Daemon):
             stampit(progress)
 
         build_script = os.path.join(libdir, 'build')
-        try:
-            with open(build_script, 'r') as s:
-                line_number = 0
-                for l in s.readlines():
-                    line_number += 1
-
-                    # For a release run, execute every line of the build 
script.
-                    # For an update run, exexute only lines with a leading +.
-                    ignore_stamp = False
-                    m = re.search('^(\+)(.*)$', l)
-                    if m:
-                        # There is a leading +, so remove it and skip if doing 
an update run
-                        ignore_stamp = self.update_run
-                        l = m.group(2)
-                    else:
-                        # There is no leading +, so skip if this is an update 
run
-                        if self.update_run:
-                            continue
-
-                    progress = os.path.join(tmpdir, '.completed_%02d' % 
line_number)
-                    if os.path.exists(progress) and not ignore_stamp:
+        with open(build_script, 'r') as s:
+            line_number = 0
+            for l in s.readlines():
+                line_number += 1
+
+                # For a release run, execute every line of the build script.
+                # For an update run, exexute only lines with a leading +.
+                ignore_stamp = False
+                m = re.search('^(\+)(.*)$', l)
+                if m:
+                    # There is a leading +, so remove it and skip if doing an 
update run
+                    ignore_stamp = self.update_run
+                    l = m.group(2)
+                else:
+                    # There is no leading +, so skip if this is an update run
+                    if self.update_run:
                         continue
 
-                    try:
-                        m = re.search('(\S+)\s+(\S+)', l)
-                        verb = m.group(1)
-                        obj  = m.group(2)
-                    except AttributeError:
-                        verb = l.strip()
-                        obj = None
+                progress = os.path.join(tmpdir, '.completed_%02d' % 
line_number)
+                if os.path.exists(progress) and not ignore_stamp:
+                    continue
+
+                try:
+                    m = re.search('(\S+)\s+(\S+)', l)
+                    verb = m.group(1)
+                    obj  = m.group(2)
+                except AttributeError:
+                    verb = l.strip()
+                    obj = None
 
-                    if verb == '':
+                if verb == '':
+                    stampit(progress)
+                    continue
+                if verb == 'log':
+                    if smartlog(l, obj):
                         stampit(progress)
                         continue
-                    if verb == 'log':
-                        if smartlog(l, obj):
-                            stampit(progress)
-                            continue
-                        if obj == 'stamp':
-                            lo.log('='*80)
-                        else:
-                            lo.log(obj)
-                    elif verb == 'mount':
-                        if smartlog(l, obj, False):
-                            stampit(progress)
-                            continue
-                        md.mount_all()
-                    elif verb == 'unmount':
-                        if smartlog(l, obj, False):
-                            stampit(progress)
-                            continue
-                        md.umount_all()
-                    elif verb == 'populate':
-                        if smartlog(l, obj):
-                            stampit(progress)
-                            continue
-                        po.populate(cycle=int(obj))
-                    elif verb == 'runscript':
-                        if smartlog(l, obj):
-                            stampit(progress)
-                            continue
-                        ru.runscript(obj)
-                    elif verb == 'clean':
-                        if smartlog(l, obj, False):
-                            stampit(progress)
-                            continue
-                        po.clean()
-                    elif verb == 'kernel':
-                        if smartlog(l, obj, False):
-                            stampit(progress)
-                            continue
-                        ke.kernel()
-                    elif verb == 'tarit':
-                        if smartlog(l, obj, False):
-                            stampit(progress)
-                            continue
-                        bi.tarit()
-                    elif verb == 'hashit':
-                        if smartlog(l, obj, False):
-                            stampit(progress)
-                            continue
-                        bi.hashit()
+                    if obj == 'stamp':
+                        lo.log('='*80)
                     else:
-                        lo.log('Bad command: %s' % l)
-
-                    stampit(progress)
+                        lo.log(obj)
+                elif verb == 'mount':
+                    if smartlog(l, obj, False):
+                        stampit(progress)
+                        continue
+                    md.mount_all()
+                elif verb == 'unmount':
+                    if smartlog(l, obj, False):
+                        stampit(progress)
+                        continue
+                    md.umount_all()
+                elif verb == 'populate':
+                    if smartlog(l, obj):
+                        stampit(progress)
+                        continue
+                    po.populate(cycle=int(obj))
+                elif verb == 'runscript':
+                    if smartlog(l, obj):
+                        stampit(progress)
+                        continue
+                    ru.runscript(obj)
+                elif verb == 'clean':
+                    if smartlog(l, obj, False):
+                        stampit(progress)
+                        continue
+                    po.clean()
+                elif verb == 'kernel':
+                    if smartlog(l, obj, False):
+                        stampit(progress)
+                        continue
+                    ke.kernel()
+                elif verb == 'tarit':
+                    if smartlog(l, obj, False):
+                        stampit(progress)
+                        continue
+                    bi.tarit()
+                elif verb == 'hashit':
+                    if smartlog(l, obj, False):
+                        stampit(progress)
+                        continue
+                    bi.hashit()
+                else:
+                    lo.log('Bad command: %s' % l)
 
-        except FileNotFoundError:
-            lo.log('Failed to open build script: %s' % build_script)
+                stampit(progress)

Reply via email to