本文整理匯總了Python中pyasn1.type.base.NoValue方法的典型用法代碼示例。如果您正苦於以下問題:Python base.NoValue方法的具體用法?Python base.NoValue怎麽用?Python base.NoValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyasn1.type.base
的用法示例。
在下文中一共展示了base.NoValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getComponentByName
# 需要導入模塊: from pyasn1.type import base [as 別名]
# 或者: from pyasn1.type.base import NoValue [as 別名]
def getComponentByName(self, name, default=noValue, instantiate=True):
"""Returns |ASN.1| type component by name.
Equivalent to Python :class:`dict` subscription operation (e.g. `[]`).
Parameters
----------
name: :class:`str`
|ASN.1| type component name
Keyword Args
------------
default: :class:`object`
If set and requested component is a schema object, return the `default`
object instead of the requested component.
instantiate: :class:`bool`
If :obj:`True` (default), inner component will be automatically
instantiated.
If :obj:`False` either existing component or the :class:`NoValue`
object will be returned.
Returns
-------
: :py:class:`~pyasn1.type.base.PyAsn1Item`
Instantiate |ASN.1| component type or return existing
component value
"""
if self._componentTypeLen:
idx = self.componentType.getPositionByName(name)
else:
try:
idx = self._dynamicNames.getPositionByName(name)
except KeyError:
raise error.PyAsn1Error('Name %s not found' % (name,))
return self.getComponentByPosition(idx, default=default, instantiate=instantiate)