[jhbuild] run: Deduplicate the code handling --in-builddir and --in-checkoutdir



commit 7a71be6cc4280a5113afce03d1d43534e182ff27
Author: Emanuele Aina <emanuele aina collabora com>
Date:   Wed Jul 10 16:51:04 2013 +0200

    run: Deduplicate the code handling --in-builddir and --in-checkoutdir
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703954

 jhbuild/commands/base.py |   28 ++++++++--------------------
 1 files changed, 8 insertions(+), 20 deletions(-)
---
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index b7dfdbf..665093b 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -374,33 +374,21 @@ class cmd_run(Command):
                     'command':args[0], 'err':str(exc)})
 
     def run(self, config, options, args, help=None):
-        if options.in_builddir:
+        module_name = options.in_builddir or options.in_checkoutdir
+        if module_name:
             module_set = jhbuild.moduleset.load(config)
             try:
-                module_list = [module_set.get_module(options.in_builddir, ignore_case = True)]
+                module_list = [module_set.get_module(module_name, ignore_case = True)]
             except KeyError, e:
                 raise FatalError(_("A module called '%s' could not be found.") % e)
 
             build = jhbuild.frontends.get_buildscript(config, module_list, module_set=module_set)
-            builddir = module_list[0].get_builddir(build)
-            try:
-                build.execute(args, cwd=builddir)
-            except CommandError, exc:
-                if args:
-                    raise FatalError(_("Unable to execute the command '%s'") % args[0])
-                else:
-                    raise FatalError(str(exc))
-        elif options.in_checkoutdir:
-            module_set = jhbuild.moduleset.load(config)
-            try:
-                module_list = [module_set.get_module(options.in_checkoutdir, ignore_case = True)]
-            except KeyError, e:
-                raise FatalError(_("A module called '%s' could not be found.") % e)
-
-            build = jhbuild.frontends.get_buildscript(config, module_list, module_set=module_set)
-            checkoutdir = module_list[0].get_srcdir(build)
+            if options.in_builddir:
+                workingdir = module_list[0].get_builddir(build)
+            else:
+                workingdir = module_list[0].get_srcdir(build)
             try:
-                build.execute(args, cwd=checkoutdir)
+                build.execute(args, cwd=workingdir)
             except CommandError, exc:
                 if args:
                     raise FatalError(_("Unable to execute the command '%s'") % args[0])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]