Quellcode durchsuchen

g.extension: allow register add-on if makefile PGM var is 'PGM=module_name' ('=' char without space around) (#1142)

Tomas Zigo vor 4 Jahren
Ursprung
Commit
85122036b3
1 geänderte Dateien mit 11 neuen und 3 gelöschten Zeilen
  1. 11 3
      scripts/g.extension/g.extension.py

+ 11 - 3
scripts/g.extension/g.extension.py

@@ -1525,6 +1525,8 @@ def install_extension_std_platforms(name, source, url, branch):
                          branch=branch)
     os.chdir(srcdir)
 
+    pgm_not_found_message = _('Module name not found.'
+                              ' Check module Makefile syntax (PGM variable).')
     # collect module names
     module_list = list()
     for r, d, f in os.walk(srcdir):
@@ -1533,9 +1535,15 @@ def install_extension_std_platforms(name, source, url, branch):
                 # get the module name: PGM = <module name>
                 with open(os.path.join(r, 'Makefile')) as fp:
                     for line in fp.readlines():
-                        if "PGM =" in line:
-                            modulename = line.split('=')[1].strip()
-                            module_list.append(modulename)
+                        if "PGM" in line:
+                            try:
+                                modulename = line.split('=')[1].strip()
+                                if modulename:
+                                    module_list.append(modulename)
+                                else:
+                                    grass.error(pgm_not_found_message)
+                            except IndexError:
+                                grass.error(pgm_not_found_message)
 
     # change shebang from python to python3
     pyfiles = []