source: cows/trunk/cows/service/imps/layers.py @ 5424

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/service/imps/layers.py@5424
Revision 5424, 1.5 KB checked in by spascoe, 11 years ago (diff)

Removing tabs from python source

Line 
1# BSD Licence
2# Copyright (c) 2009, Science & Technology Facilities Council (STFC)
3# All rights reserved.
4#
5# See the LICENSE file in the source distribution of this software for
6# the full license text.
7
8'''
9This class reads the wms configuration XML document, extracts the layer elements specified in the xml file and stores them in a list.  This list of layer elements is used by the WMSLayerMapper class to create a StationLayer object for each layer element in the list, using the information recorded under each layer element.
10'''
11from xml.etree import cElementTree
12
13class LayerParser(object):
14
15                def __init__(self, file):
16                        self.tree = cElementTree.iterparse(file)
17                        self.indexList = []
18 
19                def getLayers (self):
20                        layerlist = []
21
22                        for event, elem in self.tree:
23                                if elem.tag == "Layer":
24                                        curId = elem.findtext("Name")
25                                        # checks for duplicate layer name
26                                        if self.indexList.count(curId) < 1:
27                                                layerlist.append(elem)
28                                                self.indexList.append(curId)
29                                        else:
30                                                raise Exception(str('Duplicate Layer ID: %s')%curId)
31                        return layerlist
Note: See TracBrowser for help on using the repository browser.