[GRASS-SVN] r53475 - grass/branches/develbranch_6/gui/scripts

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 18 10:13:55 PDT 2012


Author: martinl
Date: 2012-10-18 10:13:55 -0700 (Thu, 18 Oct 2012)
New Revision: 53475

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


Modified: grass/branches/develbranch_6/gui/scripts/g.extension.py
===================================================================
--- grass/branches/develbranch_6/gui/scripts/g.extension.py	2012-10-18 17:08:51 UTC (rev 53474)
+++ grass/branches/develbranch_6/gui/scripts/g.extension.py	2012-10-18 17:13:55 UTC (rev 53475)
@@ -188,12 +188,7 @@
         for mnode in tree.findall('task'):
             name = mnode.get('name')
             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
@@ -208,6 +203,22 @@
     
     return mlist
 
+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
+
 # list extensions (scan SVN repo)
 def list_available_extensions_svn():
     mlist = list()
@@ -351,12 +362,7 @@
                             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'  : name,
                      'desc'  : desc,



More information about the grass-commit mailing list