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


Python octets.ints2octs函数代码示例

本文整理汇总了Python中pyasn1.compat.octets.ints2octs函数的典型用法代码示例。如果您正苦于以下问题:Python ints2octs函数的具体用法?Python ints2octs怎么用?Python ints2octs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testIndefModeChunkedSubst

 def testIndefModeChunkedSubst(self):
     assert decoder.decode(
         ints2octs((36, 128, 4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111,
                    120, 0, 0)),
         substrateFun=lambda a, b, c: (b, str2octs(''))
     ) == (ints2octs(
         (4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111, 120, 0, 0)), str2octs(''))
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:test_decoder.py

示例2: encode

    def encode(self, encodeFun, value, defMode, maxChunkSize, ifNotEmpty=False):
        substrate, isConstructed, isOctets = self.encodeValue(
            encodeFun, value, defMode, maxChunkSize, ifNotEmpty=ifNotEmpty
        )

        if ifNotEmpty and not substrate:
            return substrate

        tagSet = value.tagSet

        # tagged value?
        if tagSet:
            if not isConstructed:  # primitive form implies definite mode
                defMode = True
            header = self.encodeTag(tagSet[-1], isConstructed)
            header += self.encodeLength(len(substrate), defMode)

            if isOctets:
                substrate = ints2octs(header) + substrate
            else:
                substrate = ints2octs(header + substrate)

            eoo =  self._encodeEndOfOctets(encodeFun, defMode)
            if eoo:
                substrate += eoo

        return substrate
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:27,代码来源:encoder.py

示例3: testSpec

 def testSpec(self):
     try:
         decoder.decode(ints2octs((2, 1, 12)), asn1Spec=univ.Null()) == (12, null)
     except PyAsn1Error:
         pass
     else:
         assert 0, "wrong asn1Spec worked out"
     assert decoder.decode(ints2octs((2, 1, 12)), asn1Spec=univ.Integer()) == (12, null)
开发者ID:shobull,项目名称:hue,代码行数:8,代码来源:test_decoder.py

示例4: _bitsFilter

    def _bitsFilter(value):
        # rfc1902.Bits does not really initialize from sequences
        # Clean bits values
        # .1.3.6.1.2.1.17.6.1.1.1.0 = BITS: 5B 00 00 00   [[...]1 3 4 6 7
        match = re.match(r'^([0-9a-fA-F]{2}(\s+[0-9a-fA-F]{2})*)\s+\[', value)
        if match:
            return ints2octs([int(y, 16) for y in match.group(1).split(' ')])

        return ints2octs([int(y, 16) for y in value.split(' ')])
开发者ID:etingof,项目名称:snmpsim,代码行数:9,代码来源:walk.py

示例5: testDefModeChunkedSubst

 def testDefModeChunkedSubst(self):
     assert decoder.decode(
         ints2octs(
             (36, 23, 4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111, 120)
         ),
         substrateFun=lambda a, b, c: (b, c),
     ) == (
         ints2octs((4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111, 120)),
         23,
     )
开发者ID:shobull,项目名称:hue,代码行数:10,代码来源:test_decoder.py

示例6: testWithOptionalAndDefaultedIndefModeSubst

 def testWithOptionalAndDefaultedIndefModeSubst(self):
     assert decoder.decode(
         ints2octs(
             (48, 128, 5, 0, 36, 128, 4, 11, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 0, 0, 2, 1, 1, 0, 0)
         ),
         substrateFun=lambda a, b, c: (b, c),
     ) == (
         ints2octs((5, 0, 36, 128, 4, 11, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 0, 0, 2, 1, 1, 0, 0)),
         -1,
     )
开发者ID:shobull,项目名称:hue,代码行数:10,代码来源:test_decoder.py

示例7: encode

    def encode(self, value, asn1Spec=None, encodeFun=None, **options):

        if asn1Spec is None:
            tagSet = value.tagSet
        else:
            tagSet = asn1Spec.tagSet

        # untagged item?
        if not tagSet:
            substrate, isConstructed, isOctets = self.encodeValue(
                value, asn1Spec, encodeFun, **options
            )
            return substrate

        defMode = options.get('defMode', True)

        for idx, singleTag in enumerate(tagSet.superTags):

            defModeOverride = defMode

            # base tag?
            if not idx:
                substrate, isConstructed, isOctets = self.encodeValue(
                    value, asn1Spec, encodeFun, **options
                )

                if not substrate and isConstructed and options.get('ifNotEmpty', False):
                    return substrate

                # primitive form implies definite mode
                if not isConstructed:
                    defModeOverride = True

            header = self.encodeTag(singleTag, isConstructed)
            header += self.encodeLength(len(substrate), defModeOverride)

            if isOctets:
                substrate = ints2octs(header) + substrate

                if not defModeOverride:
                    substrate += self.eooOctetsSubstrate

            else:
                substrate = header + substrate

                if not defModeOverride:
                    substrate += self.eooIntegerSubstrate

        if not isOctets:
            substrate = ints2octs(substrate)

        return substrate
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:52,代码来源:encoder.py

示例8: testReservedLength

 def testReservedLength(self):
     try:
         decoder.decode(ints2octs((6, 255, 0)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'reserved length tolarated'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例9: testIndefiniteLength

 def testIndefiniteLength(self):
     try:
         decoder.decode(ints2octs((6, 128, 0)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'indefinite length tolarated'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例10: __init__

 def __init__(self, tagMap, typeMap={}):
     self.__tagMap = tagMap
     self.__typeMap = typeMap
     # Tag & TagSet objects caches
     self.__tagCache = {}
     self.__tagSetCache = {}
     self.__eooSentinel = ints2octs((0, 0))
开发者ID:0-vortex,项目名称:ZeroNet,代码行数:7,代码来源:decoder.py

示例11: testTagFormat

 def testTagFormat(self):
     try:
         decoder.decode(ints2octs((33, 1, 1)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'wrong tagFormat worked out'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例12: testNoConstructedEoo

 def testNoConstructedEoo(self):
     try:
         decoder.decode(ints2octs((0x23, 0x80, 0x20, 0x00)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'end-of-contents octets accepted with invalid constructed encoding'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例13: testDefiniteNoEoo

 def testDefiniteNoEoo(self):
     try:
         decoder.decode(ints2octs((0x23, 0x02, 0x00, 0x00)))
     except PyAsn1Error:
         pass
     else:
         assert 0, 'end-of-contents octets accepted inside definite-length encoding'
开发者ID:mmattice,项目名称:pyasn1,代码行数:7,代码来源:test_decoder.py

示例14: testBin3

 def testBin3(self):
     # change binEncBase in the RealEncoder instance => for all further Real
     binEncBase, encoder.typeMap[univ.Real.typeId].binEncBase = encoder.typeMap[univ.Real.typeId].binEncBase, 16
     assert encoder.encode(
         univ.Real((0.00390625, 2, 0))  # check encbase = 16
     ) == ints2octs((9, 3, 160, 254, 1))
     encoder.typeMap[univ.Real.typeId].binEncBase = binEncBase
开发者ID:catapult-project,项目名称:catapult,代码行数:7,代码来源:test_encoder.py

示例15: testLarge2

 def testLarge2(self):
     assert decoder.decode(
         ints2octs(
             (
                 0x06,
                 0x13,
                 0x88,
                 0x37,
                 0x83,
                 0xC6,
                 0xDF,
                 0xD4,
                 0xCC,
                 0xB3,
                 0xFF,
                 0xFF,
                 0xFE,
                 0xF0,
                 0xB8,
                 0xD6,
                 0xB8,
                 0xCB,
                 0xE2,
                 0xB6,
                 0x47,
             )
         )
     ) == ((2, 999, 18446744073709551535184467440737095), null)
开发者ID:shobull,项目名称:hue,代码行数:28,代码来源:test_decoder.py


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