source: TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/conditionreader.py @ 6746

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/conditionreader.py@6746
Revision 6746, 1.3 KB checked in by pjkersha, 10 years ago (diff)

Added more !ETree readers for the different types.

Line 
1"""NDG XACML ElementTree based Target Element reader
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "16/03/10"
7__copyright__ = "(C) 2010 Science and Technology Facilities Council"
8__contact__ = "Philip.Kershaw@stfc.ac.uk"
9__license__ = "BSD - see LICENSE file in top-level directory"
10__contact__ = "Philip.Kershaw@stfc.ac.uk"
11__revision__ = "$Id: $"
12from ndg.xacml.core.condition import Condition
13from ndg.xacml.parsers import XMLParseError
14from ndg.xacml.parsers.etree.reader import ETreeAbstractReader
15
16
17class ConditionReader(ETreeAbstractReader):
18    '''ElementTree based XACML Rule parser
19    '''
20    def __call__(self, obj):
21        """Parse policy object"""
22        elem = super(CondtionReader, self)._parse(obj)
23       
24        condition = Condition()
25        cls = Condition
26       
27        localName = QName.getLocalPart(elem.tag)
28        if localName != cls.ELEMENT_LOCAL_NAME:
29            raise XMLParseError("No \"%s\" element found" % 
30                                cls.ELEMENT_LOCAL_NAME)
31           
32        # Parse expression sub-element
33        if len(elem) != 1:
34            raise XMLParseError("No expression sub element found in "
35                                "Condition element")
36           
37        condition = ExpressionReader.parse(elem[0])
38   
39        return condition
Note: See TracBrowser for help on using the repository browser.