Ignore:
Timestamp:
01/06/10 11:25:08 (10 years ago)
Author:
pjkersha
Message:

Incomplete - task 6: Put NDG SAML package on PyPI

  • updating epydoc for 'etree' package
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/ndg_saml/ndg/saml/xml/etree.py

    r6900 r6913  
    3939 
    4040from ndg.saml.saml2.core import (SAMLObject, Attribute, AttributeStatement,  
    41                              AuthnStatement, AuthzDecisionStatement, Assertion, 
    42                              Conditions, AttributeValue, AttributeQuery,  
    43                              AuthzDecisionQuery, Subject, NameID, Issuer,  
    44                              Response, Status, StatusCode, StatusMessage,  
    45                              StatusDetail, Advice, Action, Evidence,  
    46                              DecisionType, XSStringAttributeValue)  
     41                                 AuthnStatement, AuthzDecisionStatement,  
     42                                 Assertion, Conditions, AttributeValue,  
     43                                 AttributeQuery, AuthzDecisionQuery, Subject,  
     44                                 NameID, Issuer, Response, Status, StatusCode,  
     45                                 StatusMessage, StatusDetail, Advice, Action,  
     46                                 Evidence, DecisionType, XSStringAttributeValue)  
    4747                              
    4848from ndg.saml.common import SAMLVersion 
     
    9292     
    9393    def _getPrefix(self): 
     94        """@return: NS prefix 
     95        @rtype: basestring 
     96        """ 
    9497        return self.__prefix 
    9598 
    9699    def _setPrefix(self, value): 
     100        """@param value: NS prefix 
     101        @type value: basestring 
     102        """ 
    97103        self.__prefix = value 
    98104     
     
    100106 
    101107    def _getLocalPart(self): 
     108        """@return: NS local name 
     109        @rtype: basestring 
     110        """ 
    102111        return self.__localPart 
    103112     
    104113    def _setLocalPart(self, value): 
     114        """@param value: NS local name 
     115        @type value: basestring 
     116        """ 
    105117        self.__localPart = value 
    106118         
     
    108120 
    109121    def _getNamespaceURI(self): 
     122        """@return: NS URI 
     123        @rtype: basestring 
     124        """ 
    110125        return self.__namespaceURI 
    111126 
    112127    def _setNamespaceURI(self, value): 
     128        """@param value: NS URI 
     129        @type value: basestring 
     130        """ 
    113131        self.__namespaceURI = value 
    114132   
     
    122140        @type qname: ndg.security.common.utils.etree.QName 
    123141        @param qname: Qualified Name to compare with self  
     142         
     143        @return: True if the qualified names match, False otherwise 
     144        @rtype: bool 
    124145        """ 
    125146        if not isinstance(qname, QName): 
     
    136157        @type qname: ndg.security.common.utils.etree.QName 
    137158        @param qname: Qualified Name to compare with self  
     159        @return: True if the qualified names don't match, False otherwise 
     160        @rtype: bool 
    138161        """ 
    139162        return not self.__eq__(qname) 
     
    141164    @classmethod 
    142165    def fromGeneric(cls, genericQName): 
    143         '''Cast the generic QName type in saml.common.xml to the  
    144         ElementTree specific implementation''' 
     166        '''Cast the generic QName type in ndg.saml.common.xml to this 
     167        ElementTree specific implementation 
     168         
     169        @param genericQName: SAML core qualified name type 
     170        @type genericQName: ndg.saml.common.xml.QName 
     171        @return: ElementTree specific qualified name type 
     172        @rtype: ndg.saml.xml.etree.QName 
     173        ''' 
    145174        if not isinstance(genericQName, GenericQName): 
    146175            raise TypeError("Expecting %r for QName, got %r" % (GenericQName, 
     
    154183     
    155184def prettyPrint(*arg, **kw): 
    156     '''Lightweight pretty printing of ElementTree elements''' 
     185    '''Lightweight pretty printing of ElementTree elements.  This function 
     186    wraps the PrettyPrint class 
     187     
     188    @param *arg: arguments to pretty print function 
     189    @type *arg: tuple 
     190    @param **kw: keyword arguments to pretty print function 
     191    @type **kw: dict 
     192    ''' 
    157193     
    158194    # Keep track of namespace declarations made so they're not repeated 
     
    164200 
    165201class PrettyPrint(object): 
     202    '''Class for lightweight pretty printing of ElementTree elements''' 
    166203    def __init__(self, declaredNss): 
     204        """ 
     205        @param declaredNss: declared namespaces 
     206        @type declaredNss: iterable of string elements 
     207        """ 
    167208        self.declaredNss = declaredNss 
    168209     
    169210    @staticmethod 
    170211    def estrip(elem): 
    171         ''' Just want to get rid of unwanted whitespace ''' 
     212        '''Utility to remove unwanted leading and trailing whitespace  
     213         
     214        @param elem: ElementTree element 
     215        @type elem: ElementTree.Element 
     216        @return: element content with whitespace removed 
     217        @rtype: basestring''' 
    172218        if elem is None: 
    173219            return '' 
     
    180226        '''Most of the work done in this wrapped function - wrapped so that 
    181227        state can be maintained for declared namespace declarations during 
    182         recursive calls using "declaredNss" above'''   
     228        recursive calls using "declaredNss" above 
     229         
     230        @param elem: ElementTree element 
     231        @type elem: ElementTree.Element 
     232        @param indent: set indent for output 
     233        @type indent: basestring 
     234        @param space: set output spacing 
     235        @type space: basestring  
     236        @return: pretty print format for doc 
     237        @rtype: basestring        
     238        '''   
    183239        strAttribs = [] 
    184240        for attr, attrVal in elem.attrib.items(): 
     
    247303        """Make a tree of a XML elements based on the assertion conditions 
    248304         
    249         @type assertion: saml.saml2.core.Conditions 
    250         @param assertion: Assertion conditions to be represented as an  
     305        @type conditions: saml.saml2.core.Conditions 
     306        @param conditions: Assertion conditions to be represented as an  
    251307        ElementTree Element 
    252308        @rtype: ElementTree.Element 
     
    284340        @param elem: ElementTree element containing the conditions 
    285341        @rtype: saml.saml2.core.Conditions 
    286         @return: Conditions object""" 
     342        @return: Conditions object 
     343        """ 
    287344         
    288345        if not ElementTree.iselement(elem): 
     
    393450        @param attributeValueElementTreeFactoryKw: keywords for AttributeValue 
    394451        @rtype: saml.saml2.core.Assertion 
    395         @return: Assertion object""" 
     452        @return: Assertion object 
     453        """ 
    396454        if not ElementTree.iselement(elem): 
    397455            raise TypeError("Expecting %r input type for parsing; got %r" % 
     
    513571        factory 
    514572        @rtype: saml.saml2.core.AttributeStatement 
    515         @return: Attribute Statement""" 
     573        @return: Attribute Statement 
     574        """ 
    516575         
    517576        if not ElementTree.iselement(elem): 
     
    587646        @type elem: ElementTree.Element 
    588647        @param elem: ElementTree element containing the AuthzDecisionStatement 
    589         @type authzDecisionValueElementTreeFactoryKw: dict 
    590         @param authzDecisionValueElementTreeFactoryKw: keywords for AuthzDecisionValue 
    591         factory 
    592648        @rtype: saml.saml2.core.AuthzDecisionStatement 
    593649        @return: AuthzDecision Statement""" 
     
    645701        """Make a tree of a XML elements based on the Attribute 
    646702         
    647         @type assertion: saml.saml2.core.Attribute 
    648         @param assertion: Attribute to be represented as an ElementTree Element 
     703        @type attribute: saml.saml2.core.Attribute 
     704        @param attribute: Attribute to be represented as an ElementTree Element 
    649705        @type attributeValueElementTreeFactoryKw: dict 
    650706        @param attributeValueElementTreeFactoryKw: keywords for AttributeValue 
     
    745801        """Make a tree of a XML elements based on the Attribute value 
    746802         
    747         @type assertion: saml.saml2.core.Assertion 
    748         @param assertion: Assertion to be represented as an ElementTree Element 
     803        @type attributeValue: saml.saml2.core.AttributeValue 
     804        @param attributeValue: Assertion to be represented as an ElementTree  
     805        Element 
    749806        @rtype: ElementTree.Element 
    750807        @return: ElementTree Element 
     
    770827        """Create an XML representation of the input SAML Attribute Value  
    771828         
    772         @type assertion: saml.saml2.core.XSStringAttributeValue 
    773         @param assertion: xs:string to be represented as an ElementTree Element 
     829        @type attributeValue: saml.saml2.core.XSStringAttributeValue 
     830        @param attributeValue: xs:string to be represented as an ElementTree  
     831        Element 
    774832        @rtype: ElementTree.Element 
    775833        @return: ElementTree Element 
     
    850908    ElementTree handler class 
    851909    @type toSAMLTypeMap: dict 
    852     @cvar toSAMLTypeMap: mapping between SAML AttributeValue string identifier and  
    853     its ElementTree handler class 
     910    @cvar toSAMLTypeMap: mapping between SAML AttributeValue string identifier  
     911    and its ElementTree handler class 
    854912    """ 
    855913    toXMLTypeMap = { 
     
    859917    def xsstringMatch(elem): 
    860918        """Match function for xs:string type attribute. 
     919         
    861920        @type elem: ElementTree.Element 
    862921        @param elem: Attribute Value element to be checked 
     
    885944    def __init__(self, customToXMLTypeMap={}, customToSAMLTypeMap=[]):  
    886945        """Set-up a SAML class to ElementTree mapping 
     946         
    887947        @type customToXMLTypeMap: dict 
    888948        @param customToXMLTypeMap: mapping for custom SAML AttributeValue  
     
    923983        @type input: saml.saml2.core.AttributeValue or basestring 
    924984        @param input: pass an AttributeValue derived type or a string.  If 
    925         an AttributeValue type, then self.__toXMLTypeMap is checked for a matching 
    926         AttributeValue class entry, if a string is passed, self.__toSAMLTypeMap is 
    927         checked for a matching string ID.  In both cases, if a match is  
    928         found an ElementTree class is returned which can render or parse 
    929         the relevant AttributeValue class 
     985        an AttributeValue type, then self.__toXMLTypeMap is checked for a  
     986        matching AttributeValue class entry, if a string is passed,  
     987        self.__toSAMLTypeMap is checked for a matching string ID.  In both  
     988        cases, if a match is found an ElementTree class is returned which can  
     989        render or parse the relevant AttributeValue class 
    930990        """ 
    931991        if isinstance(input, AttributeValue): 
     
    9701030    @classmethod 
    9711031    def toXML(cls, issuer): 
    972         """Create an XML representation of the input SAML issuer object""" 
     1032        """Create an XML representation of the input SAML issuer object 
     1033         
     1034        @type issuer: saml.saml2.core.Issuer 
     1035        @param issuer: Assertion object 
     1036        @rtype: ElementTree.Element 
     1037        @return: ElementTree element containing the assertion 
     1038        """ 
    9731039        if not isinstance(issuer, Issuer): 
    9741040            raise TypeError("Expecting %r class got %r" % (Issuer,  
     
    10321098        @param nameID: SAML name ID 
    10331099        @rtype: ElementTree.Element 
    1034         @return: Name ID as ElementTree XML element""" 
     1100        @return: Name ID as ElementTree XML element 
     1101        """ 
    10351102         
    10361103        if not isinstance(nameID, NameID): 
     
    11441211        @param statusCode: SAML Status Code 
    11451212        @rtype: ElementTree.Element 
    1146         @return: Status Code as ElementTree XML element""" 
     1213        @return: Status Code as ElementTree XML element 
     1214        """ 
    11471215         
    11481216        if not isinstance(statusCode, StatusCode): 
     
    12001268        @param statusMessage: SAML Status Message 
    12011269        @rtype: ElementTree.Element 
    1202         @return: Status Code as ElementTree XML element""" 
     1270        @return: Status Code as ElementTree XML element 
     1271        """ 
    12031272         
    12041273        if not isinstance(statusMessage, StatusMessage): 
     
    15791648        @param action: SAML subject 
    15801649        @rtype: ElementTree.Element 
    1581         @return: Name ID as ElementTree XML element""" 
     1650        @return: Name ID as ElementTree XML element 
     1651        """ 
    15821652         
    15831653        if not isinstance(action, Action): 
Note: See TracChangeset for help on using the changeset viewer.