[jhbuild] sanitycheck: extract try block into a function



commit a3bf111340f4f5fc04caaee2215806f7e525981d
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Sun Dec 15 14:36:43 2013 +0100

    sanitycheck: extract try block into a function
    
    This is more readable and will be useful for the fix in the
    subsequent commit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720486

 jhbuild/commands/sanitycheck.py |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/jhbuild/commands/sanitycheck.py b/jhbuild/commands/sanitycheck.py
index 427facd..d85bc46 100644
--- a/jhbuild/commands/sanitycheck.py
+++ b/jhbuild/commands/sanitycheck.py
@@ -77,23 +77,8 @@ class cmd_sanitycheck(Command):
                              r'automake \([^)]*\) ([\d.]+)', '1.10'):
             uprint(_('%s not found') % 'automake >= 1.10')
 
-        try:
-            not_in_path = []
-            path = get_aclocal_path()
 
-            macros = ['libtool.m4', 'gettext.m4', 'pkg.m4']
-            for macro in macros:
-                if not inpath (macro, path):
-                    uprint(_("aclocal can't see %s macros") % (macro.split('.m4')[0]))
-                    if not_in_path.count(macro) == 0:
-                        not_in_path.append(macro)
-
-            if len(not_in_path) > 0:
-                uprint(_("Please copy the lacking macros (%(macros)s) in one of the following paths: 
%(path)s") % \
-                       {'macros': ', '.join(not_in_path), 'path': ', '.join(path)})
-
-        except CommandError, exc:
-            uprint(str(exc))
+        self.check_m4()
 
         # XML catalog sanity checks
         if not os.access('/etc/xml/catalog', os.R_OK):
@@ -150,4 +135,23 @@ class cmd_sanitycheck(Command):
         if not inpath('xzcat', os.environ['PATH'].split(os.pathsep)):
             uprint(_('%s not found') % 'xzcat')
 
+    def check_m4(self):
+        try:
+            not_in_path = []
+            path = get_aclocal_path()
+
+            macros = ['libtool.m4', 'gettext.m4', 'pkg.m4']
+            for macro in macros:
+                if not inpath (macro, path):
+                    uprint(_("aclocal can't see %s macros") % (macro.split('.m4')[0]))
+                    if not_in_path.count(macro) == 0:
+                        not_in_path.append(macro)
+
+            if len(not_in_path) > 0:
+                uprint(_("Please copy the lacking macros (%(macros)s) in one of the following paths: 
%(path)s") % \
+                       {'macros': ', '.join(not_in_path), 'path': ', '.join(path)})
+
+        except CommandError, exc:
+            uprint(str(exc))
+
 register_command(cmd_sanitycheck)


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