Python pyasn1.type.namedval 模块,NamedValues() 实例源码
我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用pyasn1.type.namedval.NamedValues()。
def clone(self, value=novalue, **kwargs):
"""Create a copy of a |ASN.1| type or object.
Any parameters to the *clone()* method will replace corresponding
properties of the |ASN.1| object.
Parameters
----------
value: :class:`int`,:class:`str` or |ASN.1| object
Initialization value to pass to new ASN.1 object instead of
inheriting one from the caller.
tagSet: :py:class:`~pyasn1.type.tag.TagSet`
Object representing ASN.1 tag(s) to use in new object instead of inheriting from the caller
subtypespec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
Object representing ASN.1 subtype constraint(s) to use in new object instead of inheriting from the caller
namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
Object representing symbolic aliases for numbers to use instead of inheriting from caller
Returns
-------
:
new instance of |ASN.1| type/value
"""
return base.AbstractSimpleAsn1Item.clone(self, value, **kwargs)
def subtype(self, **kwargs):
"""Create a copy of a |ASN.1| type or object.
Any parameters to the *subtype()* method will be added to the corresponding
properties of the |ASN.1| object.
Parameters
----------
value: :class:`int`,:class:`str` or |ASN.1| object
Initialization value to pass to new ASN.1 object instead of
inheriting one from the caller.
implicitTag: :py:class:`~pyasn1.type.tag.Tag`
Implicitly apply given ASN.1 tag object to caller's
:py:class:`~pyasn1.type.tag.TagSet`,then use the result as
new object's ASN.1 tag(s).
explicitTag: :py:class:`~pyasn1.type.tag.Tag`
Explicitly apply given ASN.1 tag object to caller's
:py:class:`~pyasn1.type.tag.TagSet`,then use the result as
new object's ASN.1 tag(s).
subtypespec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
Add ASN.1 constraints object to one of the caller,then
use the result as new object's ASN.1 constraints.
namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
Add given object representing symbolic aliases for numbers
to one of the caller,then use the result as new object's
named numbers.
Returns
-------
:
new instance of |ASN.1| type/value
"""
return base.AbstractSimpleAsn1Item.subtype(self, **kwargs)
# backward compatibility
def clone(self, **kwargs):
"""Create a copy of a |ASN.1| type or object.
Any parameters to the *clone()* method will replace corresponding
properties of the |ASN.1| object.
Parameters
----------
value : :class:`int`,:class:`str` or |ASN.1| object
Initialization value to pass to new ASN.1 object instead of
inheriting one from the caller.
tagSet: :py:class:`~pyasn1.type.tag.TagSet`
Object representing ASN.1 tag(s) to use in new object instead of inheriting from the caller
subtypespec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
Object representing ASN.1 subtype constraint(s) to use in new object instead of inheriting from the caller
namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
Class instance representing BitString type enumerations
binValue: :py:class:`str`
Binary string initializer to use instead of the *value*.
Example: '10110011'.
hexValue: :py:class:`str`
Hexadecimal string initializer to use instead of the *value*.
Example: 'DEADBEEF'.
Returns
-------
:
new instance of |ASN.1| type/value
"""
return base.AbstractSimpleAsn1Item.clone(self, **kwargs)
def clone(self, tagSet=None, subtypespec=None, namedValues=None):
"""Create a copy of a |ASN.1| type or object.
Any parameters to the *clone()* method will replace corresponding
properties of the |ASN.1| object.
Parameters
----------
value: :class:`int`,:class:`str` or |ASN.1| object
Initialization value to pass to new ASN.1 object instead of
inheriting one from the caller.
tagSet: :py:class:`~pyasn1.type.tag.TagSet`
Object representing ASN.1 tag(s) to use in new object instead of inheriting from the caller
subtypespec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
Object representing ASN.1 subtype constraint(s) to use in new object instead of inheriting from the caller
namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
Object representing symbolic aliases for numbers to use instead of inheriting from caller
Returns
-------
:
new instance of |ASN.1| type/value
"""
if self.isNovalue(value):
if self.isNovalue(tagSet, subtypespec, namedValues):
return self
value = self._value
if tagSet is None:
tagSet = self._tagSet
if subtypespec is None:
subtypespec = self._subtypespec
if namedValues is None:
namedValues = self.__namedValues
return self.__class__(value, tagSet, namedValues)
def withNamedValues(cls, **values):
"""Creates a subclass with discreet named values constraint.
"""
class X(cls):
namedValues = cls.namedValues + namedval.NamedValues(*values.items())
subtypespec = cls.subtypespec + constraint.SingleValueConstraint(*values.values())
X.__name__ = cls.__name__
return X
def withNamedValues(cls, **values):
"""Creates a subclass with discreet named values constraint.
"""
class X(cls):
namedValues = cls.namedValues + namedval.NamedValues(*values.items())
subtypespec = cls.subtypespec + constraint.SingleValueConstraint(*values.values())
X.__name__ = cls.__name__
return X
def withNamedValues(cls, **values):
"""Creates a subclass with discreet named values constraint.
"""
class X(cls):
namedValues = cls.namedValues + namedval.NamedValues(*values.items())
subtypespec = cls.subtypespec + constraint.SingleValueConstraint(*values.values())
X.__name__ = cls.__name__
return X
def subtype(self,:class:`str` or |ASN.1| object
Initialization value to pass to new ASN.1 object instead of
inheriting one from the caller.
implicitTag: :py:class:`~pyasn1.type.tag.Tag`
Implicitly apply given ASN.1 tag object to caller's
:py:class:`~pyasn1.type.tag.TagSet`,then use the result as new object's
named numbers.
binValue: :py:class:`str`
Binary string initializer to use instead of the *value*.
Example: '10110011'.
hexValue: :py:class:`str`
Hexadecimal string initializer to use instead of the *value*.
Example: 'DEADBEEF'.
Returns
-------
:
new instance of |ASN.1| type/value
"""
return base.AbstractSimpleAsn1Item.subtype(self, **kwargs)
def subtype(self, implicitTag=None, explicitTag=None,
subtypespec=None, namedValues=None):
"""Create a copy of a |ASN.1| type or object.
Any parameters to the *subtype()* method will be added to the corresponding
properties of the |ASN.1| object.
Parameters
----------
value: :class:`int`,then use the result as new object's
named numbers.
Returns
-------
:
new instance of |ASN.1| type/value
"""
if self.isNovalue(value):
value = self._value
if implicitTag is not None:
tagSet = self._tagSet.tagImplicitly(implicitTag)
elif explicitTag is not None:
tagSet = self._tagSet.tagExplicitly(explicitTag)
else:
tagSet = self._tagSet
if subtypespec is None:
subtypespec = self._subtypespec
else:
subtypespec = self._subtypespec + subtypespec
if namedValues is None:
namedValues = self.__namedValues
else:
namedValues = namedValues + self.__namedValues
return self.__class__(value, namedValues)
def clone(self,
namedValues=None, binValue=novalue, hexValue=novalue):
"""Create a copy of a |ASN.1| type or object.
Any parameters to the *clone()* method will replace corresponding
properties of the |ASN.1| object.
Parameters
----------
value : :class:`int`,:class:`str` or |ASN.1| object
Initialization value to pass to new ASN.1 object instead of
inheriting one from the caller.
tagSet: :py:class:`~pyasn1.type.tag.TagSet`
Object representing ASN.1 tag(s) to use in new object instead of inheriting from the caller
subtypespec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
Object representing ASN.1 subtype constraint(s) to use in new object instead of inheriting from the caller
namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
Class instance representing BitString type enumerations
binValue: :py:class:`str`
Binary string initializer to use instead of the *value*.
Example: '10110011'.
hexValue: :py:class:`str`
Hexadecimal string initializer to use instead of the *value*.
Example: 'DEADBEEF'.
Returns
-------
:
new instance of |ASN.1| type/value
"""
if self.isNovalue(value, binValue, hexValue):
if self.isNovalue(tagSet, namedValues, hexValue)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。