[GRASS-SVN] r53474 - grass/trunk/scripts/g.extension

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 18 10:08:51 PDT 2012


Author: martinl
Date: 2012-10-18 10:08:51 -0700 (Thu, 18 Oct 2012)
New Revision: 53474

Modified:
   grass/trunk/scripts/g.extension/g.extension.py
Log:
g.extension: don't fail when desc or keyw is not defined


Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py	2012-10-18 16:55:33 UTC (rev 53473)
+++ grass/trunk/scripts/g.extension/g.extension.py	2012-10-18 17:08:51 UTC (rev 53474)
@@ -268,6 +268,21 @@
 
     return tlist
 
+def get_optional_params(mnode):
+    try:
+        desc = mnode.find('description').text
+    except AttributeError:
+        desc = ''
+    if desc is None:
+        desc = ''
+    try:
+        keyw = mnode.find('keywords').text
+    except AttributeError:
+        keyw = ''
+    if keyw is None:
+        keyw = ''
+        
+    return desc, keyw
 
 def list_available_modules(url, mlist = None):
     # try to download XML metadata file first
@@ -285,13 +300,8 @@
             if mlist and name not in mlist:
                 continue
             if flags['c'] or flags['g']:
-                desc = mnode.find('description').text
-                if not desc:
-                    desc = ''
-                keyw = mnode.find('keywords').text
-                if not keyw:
-                    keyw = ''
-
+                desc, keyw = get_optional_params(mnode)
+            
             if flags['g']:
                 print 'name=' + name
                 print 'description=' + desc
@@ -577,14 +587,9 @@
                         if path[0] == 'scripts':
                             path[-1] += '.py'
                     fList.append(os.path.sep.join(path))
-
-            desc = mnode.find('description').text
-            if not desc:
-                desc = ''
-            keyw = mnode.find('keywords').text
-            if not keyw:
-                keyw = ''
-
+            
+            desc, keyw = get_optional_params(mnode)
+            
             data[name] = {
                 'desc'  : desc,
                 'keyw'  : keyw,



More information about the grass-commit mailing list