[GRASS-SVN] r49729 - grass/branches/develbranch_6/gui/wxpython/core
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 13 17:42:29 EST 2011
Author: martinl
Date: 2011-12-13 14:42:29 -0800 (Tue, 13 Dec 2011)
New Revision: 49729
Modified:
grass/branches/develbranch_6/gui/wxpython/core/globalvar.py
Log:
wxGUI: clean up globalvar.GetGRASSCmd()
Modified: grass/branches/develbranch_6/gui/wxpython/core/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/globalvar.py 2011-12-13 22:42:02 UTC (rev 49728)
+++ grass/branches/develbranch_6/gui/wxpython/core/globalvar.py 2011-12-13 22:42:29 UTC (rev 49729)
@@ -105,67 +105,69 @@
"""!File name extension binaries/scripts"""
if sys.platform == 'win32':
EXT_BIN = '.exe'
- EXT_SCT = '.bat'
+ EXT_SCT = ''
else:
EXT_BIN = ''
EXT_SCT = ''
-def GetGRASSCmds(bin = True, scripts = True, gui_scripts = True, addons = True):
+def GetGRASSCmds(scriptsOnly = False):
"""!Create list of available GRASS commands to use when parsing
string from the command line
-
- @param bin True to include executable into list
- @param scripts True to include scripts into list
- @param gui_scripts True to include GUI scripts into list
+
+ @param scriptsOnly True to report only scripts
"""
gisbase = os.environ['GISBASE']
cmd = list()
- if bin:
- for executable in os.listdir(os.path.join(gisbase, 'bin')):
- ext = os.path.splitext(executable)[1]
- if not EXT_BIN or \
- ext in (EXT_BIN, EXT_SCT):
- cmd.append(executable)
-
- # add special call for setting vector colors
- cmd.append('vcolors')
+ # scan bin/
+ if not scriptsOnly:
+ for fname in os.listdir(os.path.join(gisbase, 'bin')):
+ name, ext = os.path.splitext(fname)
+ if not EXT_BIN:
+ cmd.append(fname)
+ elif ext == EXT_BIN:
+ cmd.append(name)
+ # scan scripts/
+ for fname in os.listdir(os.path.join(gisbase, 'scripts')):
+ name, ext = os.path.splitext(fname)
+ if not EXT_SCT:
+ cmd.append(fname)
+ elif ext == EXT_SCT:
+ cmd.append(name)
- if scripts and sys.platform != "win32":
- cmd += os.listdir(os.path.join(gisbase, 'scripts'))
+ # scan gui/scripts/
+ os.environ["PATH"] = os.getenv("PATH") + os.pathsep + os.path.join(gisbase, 'etc', 'gui', 'scripts')
+ cmd = cmd + os.listdir(os.path.join(gisbase, 'etc', 'gui', 'scripts'))
- if gui_scripts:
- os.environ["PATH"] = os.getenv("PATH") + os.pathsep + os.path.join(gisbase, 'etc', 'gui', 'scripts')
- os.environ["PATH"] = os.getenv("PATH") + os.pathsep + os.path.join(gisbase, 'etc', 'wxpython', 'scripts')
- for script in os.listdir(os.path.join(gisbase, 'etc', 'gui', 'scripts')):
- patt = "_wrapper" # ignore wrappers
- if script[-len(patt):] != patt:
- cmd.append(script)
-
- if addons and os.getenv('GRASS_ADDON_PATH'):
+ # scan addons
+ if os.getenv('GRASS_ADDON_PATH'):
path = os.getenv('GRASS_ADDON_PATH')
- for ipath in path.split(os.pathsep):
- if not os.path.exists(ipath):
- continue
- for executable in os.listdir(ipath):
- ext = os.path.splitext(executable)[1]
- if not EXT_BIN or \
- ext in (EXT_BIN, EXT_SCT):
- cmd.append(executable)
+ bpath = os.path.join(path, 'bin')
+ spath = os.path.join(path, 'scripts')
+ if not scriptsOnly and os.path.exists(bpath) and \
+ os.path.isdir(bpath):
+ for fname in os.listdir(bpath):
+ name, ext = os.path.splitext(fname)
+ if not EXT_BIN:
+ cmd.append(fname)
+ elif ext == EXT_BIN:
+ cmd.append(name)
+
+ if os.path.exists(spath) and os.path.isdir(spath):
+ for fname in os.listdir(spath):
+ name, ext = os.path.splitext(fname)
+ if not EXT_SCT:
+ cmd.append(fname)
+ elif ext == EXT_SCT:
+ cmd.append(name)
- if sys.platform == 'win32':
- for idx in range(len(cmd)):
- name, ext = os.path.splitext(cmd[idx])
- if ext in (EXT_BIN, EXT_SCT):
- cmd[idx] = name
-
return cmd
"""@brief Collected GRASS-relared binaries/scripts"""
grassCmd = {}
grassCmd['all'] = GetGRASSCmds()
-grassCmd['script'] = GetGRASSCmds(bin = False, gui_scripts = False)
+grassCmd['script'] = GetGRASSCmds(scriptsOnly = True)
"""@Toolbar icon size"""
toolbarSize = (24, 24)
More information about the grass-commit
mailing list