Python pyasn1.type.univ.Set() Examples

The following are 4 code examples of pyasn1.type.univ.Set(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyasn1.type.univ , or try the search function .
Example #1
Source File: dom.py    From peach with Mozilla Public License 2.0 6 votes vote down vote up
def _setXmlAttribute(node, key, value):
        """
        Set an XML attribute with handling for UnicodeDecodeError.
        """

        try:
            node.set(key, str(value))
            value = str(node.get(key))

        except UnicodeEncodeError:
            node.set("%s-Encoded" % key, "base64")
            node.set(key, base64.b64encode(str(value)))

        except UnicodeDecodeError:
            node.set("%s-Encoded" % key, "base64")
            node.set(key, base64.b64encode(str(value))) 
Example #2
Source File: dom.py    From peach with Mozilla Public License 2.0 6 votes vote down vote up
def _setAttribute(self, node, name, value, default = None):
        """
        Set an attribute on an XML Element.  We only set the
        attribute in the following cases:

            1. We have no attached xml node or self.ref == None
            2. We have a node, and the node has that attribute
            3. The value is not None

        """

        # Simplify the XML by not adding defaults
        if value == default or value is None:
            return

        node.set(name, str(value)) 
Example #3
Source File: dom.py    From peach with Mozilla Public License 2.0 5 votes vote down vote up
def setDefaultValue(self, value):
        """
        Set the default value for this data element.
        """
        self.defaultValue = value 
Example #4
Source File: dom.py    From peach with Mozilla Public License 2.0 5 votes vote down vote up
def setValue(self, value):
        """
        Set the current value for this data element
        """
        self.currentValue = value
        self.getValue()