[GRASS-SVN] r47341 - grass-addons/grass7/gui/wxpython/wx.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 1 16:22:42 EDT 2011
Author: sudeepsingh
Date: 2011-08-01 13:22:42 -0700 (Mon, 01 Aug 2011)
New Revision: 47341
Modified:
grass-addons/grass7/gui/wxpython/wx.wms/parse.py
grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
Log:
Code for displaying layers as a hierarchy, not working well currently
Modified: grass-addons/grass7/gui/wxpython/wx.wms/parse.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/parse.py 2011-08-01 16:29:06 UTC (rev 47340)
+++ grass-addons/grass7/gui/wxpython/wx.wms/parse.py 2011-08-01 20:22:42 UTC (rev 47341)
@@ -1,4 +1,4 @@
-from BeautifulSoup import BeautifulSoup
+from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup
import re
from urllib2 import Request, urlopen, URLError, HTTPError
@@ -38,3 +38,28 @@
else:
return False
print 'done'
+
+
+
+def getLayers(xml):
+ soup = BeautifulStoneSoup(xml)
+ print 'dfs starting'
+ #print soup
+ dfs(soup," ")
+ print 'dfs ending'
+
+def dfs(root, indent):
+ if not hasattr(root, 'contents'):
+ #print root.string
+ return
+ else:
+ #print root.name
+ if(root.name == 'layer'):
+ print indent + root.name
+ children = root.contents
+ for child in children:
+ dfs(child,indent+" ")
+ return
+
+
+
Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-01 16:29:06 UTC (rev 47340)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py 2011-08-01 20:22:42 UTC (rev 47341)
@@ -5,7 +5,7 @@
import wx
from wxPython.wx import *
from urllib2 import Request, urlopen, URLError, HTTPError
-from parse import parsexml, isServiceException
+from parse import parsexml, isServiceException, getLayers
from WMSMapDisplay import NewImageFrame
from addserver import AddServerFrame
from passwordPopUp import PasswordPopUpFrame, check
@@ -118,10 +118,9 @@
response = urlopen(req)
xml = response.read()
#self.statusbar.SetStatusText(xml)
+ getLayers(xml)
reslist = parsexml(xml)
- st = ''
for res in reslist:
- st = st + res + '\n'
self.LayerTree.AppendItem(self.layerTreeRoot, res)
#self.Layers.SetValue(st)
#print xml
More information about the grass-commit
mailing list