当前位置: 首页>>代码示例>>Python>>正文


Python base.AbstractSimpleAsn1Item方法代码示例

本文整理汇总了Python中pyasn1.type.base.AbstractSimpleAsn1Item方法的典型用法代码示例。如果您正苦于以下问题:Python base.AbstractSimpleAsn1Item方法的具体用法?Python base.AbstractSimpleAsn1Item怎么用?Python base.AbstractSimpleAsn1Item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasn1.type.base的用法示例。


在下文中一共展示了base.AbstractSimpleAsn1Item方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def __init__(self, value=None, tagSet=None, subtypeSpec=None,
                 encoding=None, binValue=None, hexValue=None):
        if encoding is None:
            self._encoding = self.encoding
        else:
            self._encoding = encoding
        if binValue is not None:
            value = self.fromBinaryString(binValue)
        if hexValue is not None:
            value = self.fromHexString(hexValue)
        if value is None or value is base.noValue:
            value = self.defaultHexValue
        if value is None or value is base.noValue:
            value = self.defaultBinValue
        self.__asNumbersCache = None
        base.AbstractSimpleAsn1Item.__init__(self, value, tagSet, subtypeSpec) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:18,代码来源:univ.py

示例2: __init__

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def __init__(self, value=noValue, tagSet=None, subtypeSpec=None,
                 namedValues=None, binValue=noValue, hexValue=noValue):
        if namedValues is None:
            self.__namedValues = self.namedValues
        else:
            self.__namedValues = namedValues
        if not self.isNoValue(binValue):
            value = self.fromBinaryString(binValue)
        if not self.isNoValue(hexValue):
            value = self.fromHexString(hexValue)
        if self.isNoValue(value):
            if self.defaultBinValue is not noValue:
                value = self.fromBinaryString(self.defaultBinValue)
            elif self.defaultHexValue is not noValue:
                value = self.fromHexString(self.defaultHexValue)
        self.__asNumbersCache = {}
        base.AbstractSimpleAsn1Item.__init__(
            self, value, tagSet, subtypeSpec
        ) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:univ.py

示例3: prettyIn

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def prettyIn(self, value):
            if isinstance(value, bytes):
                return value
            elif isinstance(value, str):
                try:
                    return value.encode(self.encoding)
                except UnicodeEncodeError:
                    raise error.PyAsn1Error(
                        "Can't encode string '%s' with '%s' codec" % (value, self.encoding)
                    )
            elif isinstance(value, OctetString):  # a shortcut, bytes() would work the same way
                return value.asOctets()
            elif isinstance(value, base.AbstractSimpleAsn1Item):  # this mostly targets Integer objects
                return self.prettyIn(str(value))
            elif isinstance(value, (tuple, list)):
                return self.prettyIn(bytes(value))
            else:
                return bytes(value) 
开发者ID:tp4a,项目名称:teleport,代码行数:20,代码来源:univ.py

示例4: __init__

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def __init__(self, value=None, tagSet=None, subtypeSpec=None,
                 encoding=None, binValue=None, hexValue=None):
        if encoding is None:
            self._encoding = self.encoding
        else:
            self._encoding = encoding
        if binValue is not None:
            value = self.fromBinaryString(binValue)
        if hexValue is not None:
            value = self.fromHexString(hexValue)
        if value is None or value is base.noValue:
            value = self.defaultHexValue
        if value is None or value is base.noValue:
            value = self.defaultBinValue
        self.__intValue = None
        base.AbstractSimpleAsn1Item.__init__(self, value, tagSet, subtypeSpec) 
开发者ID:caronc,项目名称:nzb-subliminal,代码行数:18,代码来源:univ.py

示例5: setComponentByPosition

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def setComponentByPosition(self, idx, value=None, verifyConstraints=True):
        l = len(self._componentValues)
        if idx >= l:
            self._componentValues = self._componentValues + (idx-l+1)*[None]
        if value is None:
            if self._componentValues[idx] is None:
                self._componentValues[idx] = self._componentType.getTypeByPosition(idx).clone()
                self._componentValuesSet = self._componentValuesSet + 1
            return self
        elif not isinstance(value, base.Asn1Item):
            t = self._componentType.getTypeByPosition(idx)
            if isinstance(t, base.AbstractSimpleAsn1Item):
                value = t.clone(value=value)
            else:
                raise error.PyAsn1Error('Instance value required')
        if verifyConstraints:
            if self._componentTypeLen:
                self._verifyComponent(idx, value)
            self._verifySubtypeSpec(value, idx)            
        if self._componentValues[idx] is None:
            self._componentValuesSet = self._componentValuesSet + 1
        self._componentValues[idx] = value
        return self 
开发者ID:caronc,项目名称:nzb-subliminal,代码行数:25,代码来源:univ.py

示例6: __repr__

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def __repr__(self):
        if self.__namedValues is not self.namedValues:
            return '%s, %r)' % (base.AbstractSimpleAsn1Item.__repr__(self)[:-1], self.__namedValues)
        else:
            return base.AbstractSimpleAsn1Item.__repr__(self) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:7,代码来源:univ.py

示例7: setComponentByPosition

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def setComponentByPosition(self, idx, value=None, verifyConstraints=True):
        l = len(self._componentValues)
        if idx >= l:
            self._componentValues = self._componentValues + (idx-l+1)*[None]
        if value is None:
            if self._componentValues[idx] is None:
                if self._componentType is None:
                    raise error.PyAsn1Error('Component type not defined')
                self._componentValues[idx] = self._componentType.clone()
                self._componentValuesSet = self._componentValuesSet + 1
            return self
        elif not isinstance(value, base.Asn1Item):
            if self._componentType is None:
                raise error.PyAsn1Error('Component type not defined')
            if isinstance(self._componentType, base.AbstractSimpleAsn1Item):
                value = self._componentType.clone(value=value)
            else:
                raise error.PyAsn1Error('Instance value required')
        if verifyConstraints:
            if self._componentType is not None:
                self._verifyComponent(idx, value)
            self._verifySubtypeSpec(value, idx)            
        if self._componentValues[idx] is None:
            self._componentValuesSet = self._componentValuesSet + 1
        self._componentValues[idx] = value
        return self 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:28,代码来源:univ.py

示例8: clone

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def clone(self, value=noValue, tagSet=None, subtypeSpec=None):
        """Creates a copy of OBJECT IDENTIFIER object representing ASN.1 type or value.

        If additional parameters are specified, they will be used
        in resulting object instead of corresponding parameters of
        current object.

        Parameters
        ----------
        value : :class:`tuple`, :class:`str` or :py:class:`~pyasn1.type.univ.ObjectIdentifier` 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

        Returns
        -------
        : :py:class:`~pyasn1.type.univ.ObjectIdentifier`
            new instance of OBJECT IDENTIFIER type/value

        """
        return base.AbstractSimpleAsn1Item.clone(self, value, tagSet, subtypeSpec) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:28,代码来源:univ.py

示例9: subtype

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import AbstractSimpleAsn1Item [as 别名]
def subtype(self, value=noValue, implicitTag=None, explicitTag=None,
                subtypeSpec=None):
        """Creates a copy of REAL object representing ASN.1 subtype or a value.

        If additional parameters are specified, they will be merged
        with the ones of the caller, then applied to newly created object.

        Parameters
        ----------
        value : :class:`tuple`, :class:`float` or :py:class:`~pyasn1.type.univ.Real` 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`
             Object representing ASN.1 subtype constraint(s) to use in new object instead of inheriting from the caller

        Returns
        -------
        : :py:class:`~pyasn1.type.univ.Real`
            new instance of REAL type/value

        """
        return base.AbstractSimpleAsn1Item.subtype(self, value, implicitTag, explicitTag) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:35,代码来源:univ.py


注:本文中的pyasn1.type.base.AbstractSimpleAsn1Item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。