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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 28 22:20:47 EDT 2011


Author: sudeepsingh
Date: 2011-07-28 19:20:47 -0700 (Thu, 28 Jul 2011)
New Revision: 47302

Modified:
   grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py
   grass-addons/grass7/gui/wxpython/wx.wms/bgenerateDOM.py
Log:
files updated with getallrows function

Modified: grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py	2011-07-28 20:58:15 UTC (rev 47301)
+++ grass-addons/grass7/gui/wxpython/wx.wms/ServerInfoAPIs.py	2011-07-29 02:20:47 UTC (rev 47302)
@@ -1,5 +1,27 @@
 from BeautifulSoup import BeautifulSoup, Tag, BeautifulStoneSoup
 
+class ServerData():
+    pass
+
+def initServerInfoBase(fileName):
+    try:
+        f = open(fileName,'r+')
+        xml = f.read()   
+        soup = BeautifulStoneSoup(xml)
+        serverinfolist = soup.findAll('serverinfo')
+        print len(serverinfolist)    
+    except:
+        f = open(fileName,'w')
+        serverinfolist = []
+        soup = BeautifulSoup()
+    
+    if(len(serverinfolist) == 0):
+            serverinfo = Tag(soup, "serverinfo")
+            soup.insert(0, serverinfo)
+            
+    return soup, f
+
+
 def addServerInfo(soup, serverinfo, snamevalue, urlvalue, unamevalue, passwordvalue):
     elements = soup.findAll(id = snamevalue)
     if(len(elements)!=0):
@@ -48,3 +70,21 @@
             return False
     else:
         return False
+
+def getAllRows(soup):
+    elements = soup.findAll('server')
+    servers = []
+    for element in elements:
+        servername = element.findAll('servername')[0]
+        serverurl = element.findAll('serverurl')[0]
+        username = element.findAll('username')[0]
+        password = element.findAll('password')[0]
+        serverdata = ServerData()
+        serverdata.servername = servername
+        serverdata.url = serverurl
+        serverdata.username = username
+        serverdata.password = password
+        print servername
+        #servers[servername] = serverdata
+        
+    return servers
\ No newline at end of file

Modified: grass-addons/grass7/gui/wxpython/wx.wms/bgenerateDOM.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/bgenerateDOM.py	2011-07-28 20:58:15 UTC (rev 47301)
+++ grass-addons/grass7/gui/wxpython/wx.wms/bgenerateDOM.py	2011-07-29 02:20:47 UTC (rev 47302)
@@ -1,29 +1,15 @@
 from BeautifulSoup import BeautifulSoup, Tag, NavigableString, BeautifulStoneSoup
-from ServerInfoAPIs import addServerInfo, removeServerInfo, updateServerInfo
+from ServerInfoAPIs import addServerInfo, removeServerInfo, updateServerInfo, initServerInfoBase, getAllRows
 
-try:
-    f = open('out.xml','r+')
-    xml = f.read()   
-    soup = BeautifulStoneSoup(xml)
-    serverinfolist = soup.findAll('serverinfo')
-    print len(serverinfolist)    
-except:
-    f = open('out.xml','w')
-    serverinfolist = []
-    soup = BeautifulSoup()
 
-if(len(serverinfolist) == 0):
-        serverinfo = Tag(soup, "serverinfo")
-        soup.insert(0, serverinfo)
-        
-        
+soup, f = initServerInfoBase('out.xml')
 print addServerInfo(soup, soup.serverinfo, 'a1', 'b1', 'c1', 'd1')
 print addServerInfo(soup, soup.serverinfo, 'a2', 'b2', 'c2', 'd2')
 print addServerInfo(soup, soup.serverinfo, 'a1', 'b1', 'c1', 'd1')              
 print updateServerInfo(soup, soup.serverinfo, 'a1', 'b112', 'c112', 'd112')
 print removeServerInfo(soup, "a2")
 
-
+print getAllRows(soup)
 xml = soup.prettify()
 f.write(xml)
 f.close()



More information about the grass-commit mailing list