本文整理匯總了Python中pyasn1.type.univ.Set方法的典型用法代碼示例。如果您正苦於以下問題:Python univ.Set方法的具體用法?Python univ.Set怎麽用?Python univ.Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyasn1.type.univ
的用法示例。
在下文中一共展示了univ.Set方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _setXmlAttribute
# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import Set [as 別名]
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)))
示例2: _setAttribute
# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import Set [as 別名]
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))
示例3: setDefaultValue
# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import Set [as 別名]
def setDefaultValue(self, value):
"""
Set the default value for this data element.
"""
self.defaultValue = value
示例4: setValue
# 需要導入模塊: from pyasn1.type import univ [as 別名]
# 或者: from pyasn1.type.univ import Set [as 別名]
def setValue(self, value):
"""
Set the current value for this data element
"""
self.currentValue = value
self.getValue()