[GRASS-SVN] r48351 - grass-addons/grass7/gui/wxpython/wx.wms

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 18 14:37:40 EDT 2011


Author: sudeepsingh
Date: 2011-09-18 11:37:40 -0700 (Sun, 18 Sep 2011)
New Revision: 48351

Modified:
   grass-addons/grass7/gui/wxpython/wx.wms/addserver.py
   grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
Log:
Comments added

Modified: grass-addons/grass7/gui/wxpython/wx.wms/addserver.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/addserver.py	2011-09-18 17:12:39 UTC (rev 48350)
+++ grass-addons/grass7/gui/wxpython/wx.wms/addserver.py	2011-09-18 18:37:40 UTC (rev 48351)
@@ -157,6 +157,14 @@
         # end wxGlade
     
     def valueExists(self,dict, newServerName):
+        """
+     @description: to check if a value exists in the dictionary or not. 
+     @todo:None
+     @param self: reference variable
+     @param dict: dictionary.
+     @param newServerName: String, value to be checked for. 
+     @return: boolean
+        """
         try:
             for key, value in dict.items():
                 if value.servername == newServerName:
@@ -166,16 +174,15 @@
             return False
 
     def parse_WMS_URL(self, full_url):
-        '''!Strips any WMS parts from url for easy reuse.
-        
-        Strips all WMS 1.1.1 and 1.3.0 parts from URL.
-        
+        """
+     @description: Strips any WMS parts from url for easy reuse.        
+        Strips all WMS 1.1.1 and 1.3.0 parts from URL.        
         This could be moved to some separate WxS support procedure file.
-        
-        @param full_url user provided WMS URL.
-        
-        @return URL as dict suitable for storage or None if provided URL isn't a valid WMS URL.
-        '''
+     @todo:None
+     @param self: reference variable
+     @param full_url: user provided WMS URL.
+     @return: URL as dict suitable for storage or None if provided URL isn't a valid WMS URL.
+        """
         WMS_13_parameters = (
             'VERSION', 
             'SERVICE',
@@ -221,6 +228,14 @@
         return urlparse.urlunparse((final_url['scheme'], final_url['netloc'], final_url['path'], final_url['params'], final_url['query'], None))
     
     def OnSave(self, event): # wxGlade: ServerAdd.<event_handler>
+        """
+     @description: Called on Save button press. Validates the information provided.
+     Saves or updates the provided information.  
+     @todo:None
+     @param self: reference variable
+     @param event: event associated
+     @return: None
+        """
         newServerName = unicode(self.ServerNameText.GetValue())
         newUrl = self.URLText.GetValue()
         newUserName = self.UsernameText.GetValue()
@@ -350,6 +365,13 @@
             event.Skip()
 
     def OnRemove(self, event): # wxGlade: ServerAdd.<event_handler>
+        """
+     @description: Called on Remove button press. Deleted the server info selected to be deleted. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated
+     @return: None
+        """
         if self.selectedUid == None:
             message = _("No server selected. Remove unsuccessful")
             self.ShowMessage(message, _('Warning'))
@@ -410,6 +432,13 @@
         event.Skip()
 
     def OnAddNew(self, event): # wxGlade: ServerAdd.<event_handler>
+        """
+     @description: Called on AddNew button press. Clears all the fields. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated 
+     @return: None
+        """
         self.checkIfModified(event)
         self.selectedUid = None
         self.ServerNameText.Clear()
@@ -423,6 +452,14 @@
         event.Skip()
     
     def OnQuit(self, event): # wxGlade: ServerAdd.<event_handler>
+        """
+     @description: Called on Quit button press. Closes the AddServerFrame.
+     Sends   Add_Server_Frame_Closed message to wmsmenu Frame before closing. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated 
+     @return: None
+        """
         if(self.checkIfModified(event) == wx.ID_CANCEL):
             return
         if(not self.saveXMLData()):
@@ -437,6 +474,15 @@
         event.Skip()
 
     def OnServerList(self, event): # wxGlade: ServerAdd.<event_handler>
+        """
+     @description: Called on ServerList (ComboBox) select.
+     Parses the selected url and fills the corresponding fields with the information present. 
+     Sends   Add_Server_Frame_Closed message to wmsmenu Frame before closing. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated 
+     @return: None
+        """
         self.checkIfModified(event)
         info = self.ServerList.GetValue()
         if(len(info) == 0):
@@ -464,12 +510,26 @@
     #wxGlade methods ends
 
     def setModified(self, booleanValue):
+        """
+     @description: Sets SetModified function of all fields to booleanValue.  
+     @todo:None
+     @param self: reference variable
+     @param booleanValue: Boolean, boolean value to be set 
+     @return: None
+        """
         self.ServerNameText.SetModified(booleanValue)
         self.URLText.SetModified(booleanValue)
         self.UsernameText.SetModified(booleanValue)
         self.PasswordText.SetModified(booleanValue)
         
     def checkIfModified(self, event):
+        """
+     @description: To check if any field is modified and unsaved. Displays a pop-up if a field is Unsaved. 
+     @todo:None
+     @param self: reference variable
+     @param event: event associated 
+     @return: wx.ID_CANCEL or wx.ID_YES
+        """
         if(self.URLText.IsModified() or self.ServerNameText.IsModified() or self.UsernameText.IsModified() or self.PasswordText.IsModified()):
             dial = wx.MessageDialog(None, 'You have unsaved changes.\n Do you want to save them ?', 'Quit',
                                     wx.STAY_ON_TOP | wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | wx.ICON_QUESTION)        
@@ -481,9 +541,24 @@
                 return val
     
     def ShowMessage(self, message, type = 'Warning'):
+        """
+     @description: Display's the message as a pop-up. 
+     @todo:None
+     @param self: reference variable
+     @param message: String, message to be displayed. 
+     @param type: String, the type of message
+     @return: None
+        """
         wx.MessageBox(message, type)
         
     def __populate_URL_List(self, ComboBox):
+        """
+     @description: Internal function to populate ServerList(ComboBox). Used to populate ServerList for the first time in the init function. 
+     @todo:None
+     @param self: reference variable
+     @param ComboBox: ComboBox to be updated.
+     @return: None
+        """
         self.servers, self.map_servernameTouid = getAllRows(self.soup)
         ComboBox.Append("")
         for key, value in self.servers.items():
@@ -491,6 +566,13 @@
         return
     
     def __update_URL_List(self):
+        """
+     @description: Internal function to update ServerList(ComboBox).  
+     @todo:None
+     @param self: reference variable
+     @param ComboBox: ComboBox to be updated. 
+     @return: None
+        """
         self.ServerList.Clear()
         ComboBox = self.ServerList
         ComboBox.Append("")
@@ -498,6 +580,12 @@
             ComboBox.Append(value.servername+self.name_url_delimiter+value.url[0:self.urlLength])
 
     def saveXMLData(self):
+        """
+     @description: Saves the information (soup) , in the file ServersList.xml.
+     @todo:None
+     @param self: reference variable
+     @return: Boolean, True if save is successful else returns False.
+        """
         xml = self.soup.prettify()        
         try:
             TMP = grass.tempfile()
@@ -529,6 +617,16 @@
         return True
     
     def allFieldsValid(self, newServerName, newUrl, newUserName, newPassword):
+        """
+     @description: Validates all the field informations. 
+     @todo:None.
+     @param self: reference variable.
+     @param newServerName: String, name of the server.
+     @param newUrl: String, url of the server.
+     @param newUserName: String, UserName for the server.
+     @param newPassword: String, Password for the server.
+     @return: Boolean, True if all fields are valid, else False. 
+        """
         # FIXME All texts should be encoded and accept all characters!
         # Šitajam vajadzētu pazust, ja izmanto XML, kas automātiski kodē tekstus.
         if newServerName.count(self.name_url_delimiter) > 0:
@@ -577,6 +675,12 @@
         return True
     
     def validateUrl(self, url):
+        """
+     @description: Validates the url provided. Sends a getCapabilities request to the url server and checks for the response.
+     @todo:None
+     @param self: reference variable
+     @return: Boolean, True if valid, else returns False.
+        """
         message = _('Validating URL...')
         StatusBar_fields = [message]
         self.StatusBar.SetStatusText(StatusBar_fields[0], 0)
@@ -605,6 +709,13 @@
             return True, message
 
     def OnWMSMenuClose(self, msg):
+        """
+     @description: Called on receiving WMS_Menu_Close message from wmsmenu Frame.  
+     @todo:None
+     @param self: reference variable
+     @param msg: message received, not used in the function though. 
+     @return: None
+        """
         self.Close()
         self.Destroy()
         return

Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py	2011-09-18 17:12:39 UTC (rev 48350)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py	2011-09-18 18:37:40 UTC (rev 48351)
@@ -56,13 +56,13 @@
     srs = None
     
     def printLayerData(self,layerDataDict):
-     """
+        """
      @description:Function to print dictionary structure holding information of
                   layers with keys as integers and values as objects of type LayerData() 
      @todo:None
      @param1:reference variable
      @param2:Dictionary holding values of type LayerData() object with keys as integers from 0 to len(layerDataDict)
-     """
+         """
         for key, value in layerDataDict.iteritems():
             print key
             print value.name
@@ -76,7 +76,7 @@
             print '--------------------------------------------'
             
     def appendLayerTree(self, layerDataDict, LayerTree, layerTreeRoot):
-     """
+        """
      @description:Adds layers to LayerTree widget. 
      @todo:None
      @param self: reference variable
@@ -84,7 +84,7 @@
      @param LayerTree: TreeCtrl, widget used to display fetched layers. 
      @param layerTreeRoot: TreeItemId,  returned by LayerTree.AddRoot("Layers") (in the init function), used to refer root of the LayerTree.
      @return: None  
-     """
+         """
         for key, value in layerDataDict.iteritems():
             name = value.name
             title = value.title
@@ -93,13 +93,13 @@
             LayerTree.AppendItem(layerTreeRoot, string)
     
     def setKeyToEPSGCodes(self, layerDataDict):
-     """
+        """
      @description: Builds a dictionary to map keys of layers to EPSG codes
      @todo:None
      @param self: reference variable
      @param layerDataDict:{},  Dictionary holding values of type LayerData() object with keys as integers from 0 to len(layerDataDict)
      @return: Dictionary with key as an integer in the string form str(int), and value a string (EPSG code for the key).  
-     """
+         """
         keytoepsgcodes = {}
         for key, value in layerDataDict.iteritems():
             srss = value.srs
@@ -120,14 +120,14 @@
     """
     
     def getAllChild(self,LayerTree, parentId):
-     """
+        """
      @description:Returns all the children nodes of a parent node in the TreeCtrl (LayerTree). 
      @todo:None
      @param self: reference variable
      @param LayerTree: TreeCtrl, widget used to display fetched layers. 
      @param parentId: TreeItemId, reference to the parent Node in TreeCtrl.
      @return: a list of TreeItemId, the children nodes of parentId(TreeItemId)  
-     """
+        """
         children = []
         currentchild,obj = LayerTree.GetFirstChild(parentId)
         while(1):
@@ -139,14 +139,14 @@
         return children
     
     def layerTreeItemDFS(self,parent,LayerTree,nodeId):
-    """
+        """
      @description: performs a DFS(Depth first search) selection on the LayerTree(TreeCtrl), starting from the nodeId(TreeItemId) 
      @todo:None
      @param self: reference variable
      @param LayerTree: TreeCtrl, widget used to display fetched layers. 
      @param nodeId: TreeItemId, reference to the parent Node in TreeCtrl.
      @return: None
-     """
+        """
         if(not nodeId.IsOk()):
             return
         
@@ -265,13 +265,13 @@
     
 
     def OnGetCapabilities(self, event): # wxGlade: wmsFrame.<event_handler>
-     """
+        """
      @description: called on press of getCapabilities button. Performs fetching of the getCapabilties document for the selected URL. 
      @todo:None
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """            
+         """            
         if(self.selectedURL == "No server selected"):
             message = 'No Server selected'
             self.ShowMessage(message, 'Warning')
@@ -352,7 +352,7 @@
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """ 
+        """ 
         if(self.selectedURL == "No server selected"):
             message = 'No server selected'
             grass.warning(message)
@@ -452,7 +452,7 @@
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """ 
+        """ 
         info = self.epsgList.GetValue()
         if(not info.isdigit()):
             message = 'Please select an EPSG Code'
@@ -470,7 +470,7 @@
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """ 
+        """ 
         info = self.ServerList.GetValue()
         if(len(info) == 0):
             return
@@ -498,13 +498,13 @@
             
 
     def OnLayerTreeSelChanged(self, event): # wxGlade: wmsFrame.<event_handler>"
-         """
+        """
      @description: called on selection of a layer from self.LayerTree. Sets self.selectedURL variable.
      @todo:None
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """
+        """
         self.epsgList.Clear()
         self.epsgList.Append('')
         self.selectedLayerList = []
@@ -534,7 +534,7 @@
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """
+        """
         self.AddServerisClosed = False
         self.addServer.Disable()
         AddServerFrame(self)
@@ -547,31 +547,31 @@
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """
+        """
         self.AddServerisClosed = True
         self.addServer.Enable()
         
     def onUpdateServerListmessage(self, msg):
-    """
+        """
      @description: called when the updateserverlist message is received from AddServerFrame. Updates the local server list (self.ServerList) 
      @todo:None
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """
+        """
         self.servers = msg.data
         #self.printDict(self.servers)
         self.__update_Url_List(self.ServerList)
         
     def onUpdateMapListmessage(self, msg): 
-           """
+        """
      @description: called when the update.map_servernameTouid message is received from AddServerFrame. Updates the local dictionary
       self.map_servernameTouid . This dictionary translates servername to itd Uid. 
      @todo:None
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """
+        """
         self.map_servernameTouid = msg.data
         #self.printDict(self.map_servernameTouid)
         
@@ -582,7 +582,7 @@
      @param self: reference variable
      @param event: event associated. 
      @return: None
-     """
+        """
         msg = ""
 
         if(not self.AddServerisClosed):
@@ -598,7 +598,7 @@
      @param message: String, message to be displayed. 
      @param type: String, the type of message
      @return: None
-     """
+        """
         wx.MessageBox(message, type)
     
     def __update_Url_List(self, ComboBox):
@@ -608,7 +608,7 @@
      @param self: reference variable
      @param ComboBox: ComboBox to be updated. 
      @return: None
-     """
+        """
         ComboBox.Clear()
         ComboBox.Append("")
         for key, value in self.servers.items():
@@ -622,7 +622,7 @@
      @param self: reference variable
      @param ComboBox: ComboBox to be updated.
      @return: None
-     """
+        """
         self.servers, self.map_servernameTouid = getAllRows(self.soup)
         ComboBox.Append("")
         for key, value in self.servers.items():
@@ -636,7 +636,7 @@
      @todo:None
      @param self: reference variable
      @return: a string containing comma separated bounding box parameters.
-     """
+        """
         n=parseGrass_Region(None, 'north')
         s=parseGrass_Region(None, 'south')
         e=parseGrass_Region(None, 'east')



More information about the grass-commit mailing list