本文整理汇总了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)