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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 18 15:42:19 EDT 2011


Author: sudeepsingh
Date: 2011-09-18 12:42:19 -0700 (Sun, 18 Sep 2011)
New Revision: 48352

Modified:
   grass-addons/grass7/gui/wxpython/wx.wms/LoadConfig.py
   grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py
   grass-addons/grass7/gui/wxpython/wx.wms/parse.py
Log:
Comments added

Modified: grass-addons/grass7/gui/wxpython/wx.wms/LoadConfig.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/LoadConfig.py	2011-09-18 18:37:40 UTC (rev 48351)
+++ grass-addons/grass7/gui/wxpython/wx.wms/LoadConfig.py	2011-09-18 19:42:19 UTC (rev 48352)
@@ -19,6 +19,13 @@
 import os
 import grass
 def loadConfigFile(self):
+    """
+     @description: Called by the init method of the class wmsFrame.
+     Loads the config file and initializes corresponding paramters.  
+     @todo:None
+     @param self: reference variable
+     @return: Boolean, True is config file is loaded successfuly, else False
+    """
     try:
         f=open('config','r')
         lines = f.readlines()

Modified: grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py	2011-09-18 18:37:40 UTC (rev 48351)
+++ grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py	2011-09-18 19:42:19 UTC (rev 48352)
@@ -29,6 +29,12 @@
     pass
 
 def initServerInfoBase(fileName):
+    """
+     @description: Intializes soup for the Beautiful soup parser. Reads the exisitng Data from the fileName paramter. 
+     @todo:None
+     @param xml: String, Name of file to be loaded in soup.  
+     @return: Boolean, True if a successful, else False
+    """
     if(os.path.exists(fileName)):
         try:
             f = open(fileName,'r')
@@ -50,6 +56,13 @@
     return soup, True
 
 def ifServerNameExists(soup,servername):
+    """
+     @description: Checks for the membership of servername in the soup
+     @todo:None
+     @param soup: soup
+     @param servername: String, name of the server to be checked for
+     @return: Boolean, True if found, else False
+    """
     servers = soup.findAll('servername')
     for server in servers:
         name = server.string.strip()
@@ -61,6 +74,18 @@
     
 
 def addServerInfo(soup, serverinfo, uid, snamevalue, urlvalue, unamevalue, passwordvalue):
+    """
+     @description: Adds server info to the soup
+     @todo:None
+     @param soup: soup
+     @param serverinfo: 
+     @param uid: Unique Id of the server
+     @param snamevalue: String, server name
+     @param urlvalue: String, url of the server
+     @param unamevalue: String, UserName for the server
+     @param passwordvalue: String, password for the server 
+     @return: Boolean, True if added successfuly, else False
+    """
     snamevalue = unicode(snamevalue)
     if(ifServerNameExists(soup, snamevalue)):
         return False
@@ -87,6 +112,13 @@
         return True
 
 def removeServerInfo(soup, serverID):
+    """
+     @description: removes server with uid = serverID
+     @todo:None
+     @param soup: soup
+     @param serverID: String, UID of the server to be removed.
+     @return: Boolean, True if successfuly removed, else False
+    """
     serverID = unicode(serverID)
     elements = soup.findAll(id = serverID)
     if(len(elements)==0):
@@ -97,6 +129,18 @@
         return True
 
 def updateServerInfo(soup, serverinfo, uid, snamevalue, urlvalue, unamevalue, passwordvalue):
+    """
+     @description: updates server with uid = uid
+     @todo:None
+     @param soup: soup
+     @param serverinfo: 
+     @param uid: Unique Id of the server
+     @param snamevalue: String, server name
+     @param urlvalue: String, url of the server
+     @param unamevalue: String, UserName for the server
+     @param passwordvalue: String, password for the server 
+     @return: Boolean, True if updated successfuly, else False
+    """
     snamevalue = unicode(snamevalue)
     if(removeServerInfo(soup, uid)):
         if(addServerInfo(soup, serverinfo, uid, snamevalue, urlvalue, unamevalue, passwordvalue)):
@@ -107,6 +151,12 @@
         return False
 
 def getAllRows(soup):
+    """
+     @description: returns all the rows in the xml file table.
+     @todo:None
+     @param soup: soup
+     @return: servers(dictionary), map_servernameTouid(dictionary) 
+    """
     elements = soup.findAll('server')
     servers = {}
     map_servernameTouid = {}

Modified: grass-addons/grass7/gui/wxpython/wx.wms/parse.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/parse.py	2011-09-18 18:37:40 UTC (rev 48351)
+++ grass-addons/grass7/gui/wxpython/wx.wms/parse.py	2011-09-18 19:42:19 UTC (rev 48352)
@@ -31,6 +31,14 @@
 key = 0
 
 class newLayerData():
+	"""
+	Data Structure to hold information about a layer.
+	name ,String - Name of the layer
+	title, String - Title for the layer
+	abstract, String - Abstract for the layer
+	srsList, List - List to hold srs values for this layer
+	queryable, int - whether a layer is queryable or not. queryable = 1 , is layer is queryable else 0. 
+	"""
 	name = None
 	title = None
 	abstract = None
@@ -65,61 +73,77 @@
 
 
 def parsexml(xml):
+	"""
+     @description: parses the xml response of the getCapabilites request. Called in getCapabilities of wmsFrame
+     @todo:None
+     @param xml: xml, xml to be parsed
+     @return: List, list of layers parsed
+    	"""
+ 	xmltext = xml
+  	soup = BeautifulSoup(xmltext)
+   	#layers = soup.findAll('layer', queryable="1")
+    	layers = soup.findAll('layer')
+ 	namelist = []
+  	for layer in layers:
+	  	soupname = BeautifulSoup(str(layer))
+		names =  soupname.findAll('name')
+		if len(names) > 0:
+			namelist += names[0]
+ 	return namelist
 
- xmltext = xml
- soup = BeautifulSoup(xmltext)
- #layers = soup.findAll('layer', queryable="1")
- layers = soup.findAll('layer')
- 
- namelist = []
- for layer in layers:
-	soupname = BeautifulSoup(str(layer))
-	names =  soupname.findAll('name')
-	if len(names) > 0:
-		namelist += names[0]
- return namelist
 
-
 def parsexml2(xml):
- layerDataDict={}
- count = -1
- xmltext = xml
- soup = BeautifulSoup(xmltext)
- layers = soup.findAll('layer')
- namelist = []
- for layer in layers:
-	soupname = BeautifulSoup(str(layer))
-	names =  soupname.findAll('name')
-	titles = soupname.findAll('title')
-	abstracts = soupname.findAll('abstract')
-	srs = soupname.findAll('srs')
-	if(len(names)>0):
-		count = count + 1
-		layerDataDict[count] = LayerData()
-		layerDataDict[count].name = unicode(names[0].string)
-	else:
-		continue
-	if(len(titles)>0):
-		layerDataDict[count].title = unicode(titles[0].string)
-	else:
-		layerDataDict[count].title = ''
+	"""
+     @description: parses the xml response of the getCapabilites request. Called in getCapabilities of wmsFrame
+     @todo:None
+     @param xml: xml, xml to be parsed
+     @return: List, list of layers parsed
+    	"""
+    	layerDataDict={}
+    	count = -1
+    	xmltext = xml
+    	soup = BeautifulSoup(xmltext)
+    	layers = soup.findAll('layer')
+    	namelist = []
+    	for layer in layers:
+		soupname = BeautifulSoup(str(layer))
+		names =  soupname.findAll('name')
+		titles = soupname.findAll('title')
+		abstracts = soupname.findAll('abstract')
+		srs = soupname.findAll('srs')
+		if(len(names)>0):
+			count = count + 1
+			layerDataDict[count] = LayerData()
+			layerDataDict[count].name = unicode(names[0].string)
+		else:
+			continue
+		if(len(titles)>0):
+			layerDataDict[count].title = unicode(titles[0].string)
+		else:
+			layerDataDict[count].title = ''
 
-	if(len(abstracts)>0):
-		layerDataDict[count].abstract = unicode(abstracts[0].string)
-	else:
-		layerDataDict[count].abstract = ''
+		if(len(abstracts)>0):
+			layerDataDict[count].abstract = unicode(abstracts[0].string)
+		else:
+			layerDataDict[count].abstract = ''
 
-	if(len(srs)>0):
-		layerDataDict[count].srs = srs
-	else:
-		layerDataDict[count].srs = ''
+		if(len(srs)>0):
+			layerDataDict[count].srs = srs
+		else:
+			layerDataDict[count].srs = ''
 	
 
- return layerDataDict
+ 	return layerDataDict
 
 
 
 def isValidResponse(xml):
+	"""
+     @description: Checks for the validity of the xml response, if it is a genuine WMS get Capabilities request.  
+     @todo:None
+     @param xml: XML, xml String to be checked. 
+     @return: Boolean, True if a valid response, else False
+    """
 	soup = BeautifulSoup(xml)
 	getCapabilities = soup.findAll('wmt_ms_capabilities')
 	if(len(getCapabilities)==0):
@@ -127,6 +151,12 @@
 	else:
 		return True
 def isServiceException(xml):
+	"""
+     @description: Checks for the service exception in the xml response 
+     @todo:None
+     @param xml: XML, xml String to be checked. 
+     @return: Boolean, True if service exception occurs response, else False
+    """
 	soup = BeautifulSoup(xml)
 	exceptions = soup.findAll('ServiceException')
 	exceptionList = []
@@ -212,6 +242,15 @@
 		return None
 	    
 def dfs1(node,LayerTree, ltr,lData):
+	"""
+     @description: DFS search for all the layers in the GetCapabilties response. 
+     @todo:None
+     @param node: TreeItem, current node
+     @param LayerTree: TreeCtrl, to display the layers in the GUI
+     @param ltr:
+     @param lData:   
+     @return: None
+    """
 	global key
 	if ( hasattr(node,'data')):
 		return
@@ -220,10 +259,8 @@
 		if(node.tagName == 'Layer' or node.tagName == 'layer'):
 			queryable = None
 			try:
-				print 'hoopla'
 				queryable = node.attributes["queryable"].value
 			except Exception,e:
-				print 'ghapla'
 				print e
 				queryable = 1
 			



More information about the grass-commit mailing list