[GRASS-SVN] r53530 - grass/trunk/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Oct 23 11:31:04 PDT 2012


Author: martinl
Date: 2012-10-23 11:31:03 -0700 (Tue, 23 Oct 2012)
New Revision: 53530

Modified:
   grass/trunk/gui/wxpython/gui_core/forms.py
   grass/trunk/gui/wxpython/gui_core/ghelp.py
Log:
bugfix #1769 + variables in CamelCase 


Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2012-10-23 18:13:43 UTC (rev 53529)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2012-10-23 18:31:03 UTC (rev 53530)
@@ -1626,8 +1626,8 @@
         else:
             self.goutput = None
         
-        self.manualTab = HelpPanel(parent = self.notebook, grass_command = self.task.name)
-        if not self.manualTab.IsFile():
+        self.manualTab = HelpPanel(parent = self.notebook, command = self.task.name)
+        if not self.manualTab.GetFile():
             self.manualTab.Hide()
         else:
             self.notebook.AddPage(page = self.manualTab, text = _("Manual"), name = 'manual')

Modified: grass/trunk/gui/wxpython/gui_core/ghelp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/ghelp.py	2012-10-23 18:13:43 UTC (rev 53529)
+++ grass/trunk/gui/wxpython/gui_core/ghelp.py	2012-10-23 18:31:03 UTC (rev 53530)
@@ -733,13 +733,13 @@
     The SYNOPSIS section is skipped, since this Panel is supposed to
     be integrated into the cmdPanel and options are obvious there.
     """
-    def __init__(self, parent, grass_command, text, skip_description,
+    def __init__(self, parent, command, text, skipDescription,
                  **kwargs):
-        """!If grass_command is given, the corresponding HTML help
+        """!If command is given, the corresponding HTML help
         file will be presented, with all links pointing to absolute
         paths of local files.
 
-        If 'skip_description' is True, the HTML corresponding to
+        If 'skipDescription' is True, the HTML corresponding to
         SYNOPSIS will be skipped, thus only presenting the help file
         from the DESCRIPTION section onwards.
 
@@ -750,25 +750,24 @@
         wx.InitAllImageHandlers()
         HtmlWindow.__init__(self, parent = parent, **kwargs)
         
-        gisbase = os.getenv("GISBASE")
         self.loaded = False
         self.history = list()
         self.historyIdx = 0
-        self.fspath = os.path.join(gisbase, "docs", "html")
+        self.fspath = os.path.join(os.getenv("GISBASE"), "docs", "html")
         
         self.SetStandardFonts (size = 10)
         self.SetBorders(10)
         
         if text is None:
-            if skip_description:
-                url = os.path.join(self.fspath, grass_command + ".html")
+            if skipDescription:
+                url = os.path.join(self.fspath, command + ".html")
                 self.fillContentsFromFile(url,
-                                          skip_description = skip_description)
+                                          skipDescription = skipDescription)
                 self.history.append(url)
                 self.loaded = True
             else:
                 ### FIXME: calling LoadPage() is strangely time-consuming (only first call)
-                # self.LoadPage(self.fspath + grass_command + ".html")
+                # self.LoadPage(self.fspath + command + ".html")
                 self.loaded = False
         else:
             self.SetPage(text)
@@ -784,7 +783,7 @@
         
         super(HelpWindow, self).OnLinkClicked(linkinfo)
         
-    def fillContentsFromFile(self, htmlFile, skip_description = True):
+    def fillContentsFromFile(self, htmlFile, skipDescription = True):
         """!Load content from file"""
         aLink = re.compile(r'(<a href="?)(.+\.html?["\s]*>)', re.IGNORECASE)
         imgLink = re.compile(r'(<img src="?)(.+\.[png|gif])', re.IGNORECASE)
@@ -797,7 +796,7 @@
                 if not skip:
                     # do skip the options description if requested
                     if "SYNOPSIS" in l:
-                        skip = skip_description
+                        skip = skipDescription
                     else:
                         # FIXME: find only first item
                         findALink = aLink.search(l)
@@ -817,13 +816,12 @@
             self.loaded = False
         
 class HelpPanel(wx.Panel):
-    def __init__(self, parent, grass_command = "index", text = None,
-                 skip_description = False, **kwargs):
-        self.grass_command = grass_command
+    def __init__(self, parent, command = "index", text = None,
+                 skipDescription = False, **kwargs):
+        self.command = command
         wx.Panel.__init__(self, parent = parent, id = wx.ID_ANY)
         
-        self.content = HelpWindow(self, grass_command, text,
-                                  skip_description)
+        self.content = HelpWindow(self, command, text, skipDescription)
         
         self.btnNext = wx.Button(parent = self, id = wx.ID_ANY,
                                  label = _("&Next"))
@@ -859,14 +857,25 @@
     def LoadPage(self, path = None):
         """!Load page"""
         if not path:
-            path = os.path.join(self.content.fspath, self.grass_command + ".html")
+            path = self.GetFile()
         self.content.history.append(path)
         self.content.LoadPage(path)
         
-    def IsFile(self):
-        """!Check if file exists"""
-        return os.path.isfile(os.path.join(self.content.fspath, self.grass_command + ".html"))
-
+    def GetFile(self):
+        """!Get HTML file"""
+        fMan = os.path.join(self.content.fspath, self.command + ".html")
+        if os.path.isfile(fMan):
+            return fMan
+        
+        # check also addons
+        faMan = os.path.join(os.getenv('GRASS_ADDON_BASE'), "docs", "html",
+                             self.command + ".html")
+        if os.getenv('GRASS_ADDON_BASE') and \
+                os.path.isfile(faMan):
+            return faMan
+        
+        return None
+    
     def IsLoaded(self):
         return self.content.loaded
 



More information about the grass-commit mailing list