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


Python base.Asn1Item方法代码示例

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


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

示例1: setComponentByPosition

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import Asn1Item [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 self._currentIdx is not None:
            self._componentValues[self._currentIdx] = None
        if value is None:
            if self._componentValues[idx] is None:
                self._componentValues[idx] = self._componentType.getTypeByPosition(idx).clone()
                self._componentValuesSet = 1
                self._currentIdx = idx
            return self
        elif not isinstance(value, base.Asn1Item):
            value = self._componentType.getTypeByPosition(idx).clone(
                value=value
                )
        if verifyConstraints:
            if self._componentTypeLen:
                self._verifyComponent(idx, value)
            self._verifySubtypeSpec(value, idx)            
        self._componentValues[idx] = value
        self._currentIdx = idx
        self._componentValuesSet = 1
        return self 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:26,代码来源:univ.py

示例2: extended_operation

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import Asn1Item [as 别名]
def extended_operation(request_name,
                       request_value=None,
                       no_encode=None):
    request = ExtendedRequest()
    request['requestName'] = RequestName(request_name)
    if request_value and isinstance(request_value, Asn1Item):
        request['requestValue'] = RequestValue(encode(request_value))
    elif str is not bytes and isinstance(request_value, (bytes, bytearray)):  # in Python 3 doesn't try to encode a byte value
        request['requestValue'] = request_value
    elif request_value and no_encode:  # doesn't encode the value
        request['requestValue'] = request_value
    elif request_value:  # tries to encode as a octet string
        request['requestValue'] = RequestValue(encode(OctetString(str(request_value))))

    # elif request_value is not None:
    #     raise LDAPExtensionError('unable to encode value for extended operation')
    return request 
开发者ID:tp4a,项目名称:teleport,代码行数:19,代码来源:extended.py

示例3: setComponentByPosition

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import Asn1Item [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

示例4: setComponentByPosition

# 需要导入模块: from pyasn1.type import base [as 别名]
# 或者: from pyasn1.type.base import Asn1Item [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:taxigps,项目名称:xbmc-addons-chinese,代码行数:28,代码来源:univ.py


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