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


Python octets.str2octs函数代码示例

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


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

示例1: testCount

 def testCount(self):
     self.s1.clear()
     for x in ['abc', 'def', 'abc']:
         self.s1.append(x)
     assert self.s1.count(str2octs('abc')) == 2
     assert self.s1.count(str2octs('def')) == 1
     assert self.s1.count(str2octs('ghi')) == 0
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:test_univ.py

示例2: testSort

 def testSort(self):
     self.s1.clear()
     self.s1[0] = 'b'
     self.s1[1] = 'a'
     assert list(self.s1) == [str2octs('b'), str2octs('a')]
     self.s1.sort()
     assert list(self.s1) == [str2octs('a'), str2octs('b')]
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:test_univ.py

示例3: testIndex

 def testIndex(self):
     self.s1.clear()
     for x in ['abc', 'def', 'abc']:
         self.s1.append(x)
     assert self.s1.index(str2octs('abc')) == 0
     assert self.s1.index(str2octs('def')) == 1
     assert self.s1.index(str2octs('abc'), 1) == 2
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:test_univ.py

示例4: testUpdate

 def testUpdate(self):
     self.s1.clear()
     assert list(self.s1.values()) == [str2octs(''), str2octs(''), 34]
     self.s1.update(**{'name': 'abc', 'nick': 'def', 'age': 123})
     assert list(self.s1.items()) == [(x[0], str2octs(x[1])) for x in [('name', 'abc'), ('nick', 'def')]] + [('age', 123)]
     self.s1.update(('name', 'ABC'))
     assert list(self.s1.items()) == [(x[0], str2octs(x[1])) for x in [('name', 'ABC'), ('nick', 'def')]] + [('age', 123)]
     self.s1.update(name='CBA')
     assert list(self.s1.items()) == [(x[0], str2octs(x[1])) for x in [('name', 'CBA'), ('nick', 'def')]] + [('age', 123)]
开发者ID:luke-chang,项目名称:gecko-1,代码行数:9,代码来源:test_univ.py

示例5: testExtend

 def testExtend(self):
     self.s1.clear()
     self.s1.setComponentByPosition(0, univ.OctetString('abc'))
     assert len(self.s1) == 1
     self.s1.extend(['def', 'ghi'])
     assert len(self.s1) == 3
     assert list(self.s1) == [str2octs(x) for x in ['abc', 'def', 'ghi']]
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:test_univ.py

示例6: testOuterByTypeWithInstanceValue

 def testOuterByTypeWithInstanceValue(self):
     self.s1.setComponentByType(
         univ.OctetString.tagSet, univ.OctetString('abc')
     )
     assert self.s1.getComponentByType(
         univ.OctetString.tagSet
     ) == str2octs('abc')
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:test_univ.py

示例7: searchRecordByOid

def searchRecordByOid(oid, fileObj, textParser, eol=str2octs('\n')):
    lo = mid = 0; prev_mid = -1
    fileObj.seek(0, 2)
    hi = sz = fileObj.tell()
    while lo < hi:
        mid = (lo+hi)//2
        fileObj.seek(mid)
        while mid:
            c = fileObj.read(1)
            if c == eol:
                mid = mid + 1
                break
            mid = mid - 1    # pivot stepping back in search for full line
            fileObj.seek(mid)
        if mid == prev_mid:  # loop condition due to stepping back pivot
            break
        if mid >= sz:
            return sz
        line, _, skippedOffset = getRecord(fileObj)
        if not line:
            return hi
        midval, _ = textParser.evaluate(line, oidOnly=True)
        if midval < oid:
            lo = mid + skippedOffset + len(line)
        elif midval > oid:
            hi = mid
        else:
            return mid
        prev_mid = mid
    if lo == mid:
        return lo
    else:
        return hi
开发者ID:woodyle,项目名称:snmpsim,代码行数:33,代码来源:file.py

示例8: 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

示例9: testIndefModeChunked

 def testIndefModeChunked(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,
             )
         )
     ) == (str2octs("Quick brown fox"), null)
开发者ID:shobull,项目名称:hue,代码行数:34,代码来源:test_decoder.py

示例10: __searchOid

 def __searchOid(self, oid, eol=str2octs('\n')):
     lo = mid = 0; prev_mid = -1;
     self.__text.seek(0, 2)
     hi = sz = self.__text.tell()
     while lo < hi:
         mid = (lo+hi)//2
         self.__text.seek(mid)
         while mid:
             c = self.__text.read(1)
             if c == eol:
                 mid = mid + 1
                 break
             mid = mid - 1    # pivot stepping back in search for full line
             self.__text.seek(mid)
         if mid == prev_mid:  # loop condition due to stepping back pivot
             break
         if mid >= sz:
             return sz
         line = self.__text.readline()
         midval, _ = self.__textParser.evaluate(line, oidOnly=True)
         if midval < oid:
             lo = mid + len(line)
         elif midval > oid:
             hi = mid
         else:
             return mid
         prev_mid = mid
     if lo == mid:
         return lo
     else:
         return hi
开发者ID:richb-hanover,项目名称:websnmpsim,代码行数:31,代码来源:snmpsimd.py

示例11: testAppend

 def testAppend(self):
     self.s1.clear()
     self.s1.setComponentByPosition(0, univ.OctetString('abc'))
     assert len(self.s1) == 1
     self.s1.append('def')
     assert len(self.s1) == 2
     assert list(self.s1) == [str2octs(x) for x in ['abc', 'def']]
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:test_univ.py

示例12: testWithoutSchema

 def testWithoutSchema(self):
     s = univ.SequenceOf().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))
     s2, r = decoder.decode(
         ints2octs((163, 15, 48, 13, 4, 11, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110))
     )
     assert not r
     assert s2 == [str2octs('quick brown')]
     assert s.tagSet == s2.tagSet
开发者ID:luke-chang,项目名称:gecko-1,代码行数:8,代码来源:test_decoder.py

示例13: testTypeCheckOnAssignment

    def testTypeCheckOnAssignment(self):

        self.s.clear()

        self.s['blob'] = univ.Any(str2octs('xxx'))

        # this should succeed because Any is untagged and unconstrained
        self.s['blob'] = univ.Integer(123)
开发者ID:etingof,项目名称:pyasn1,代码行数:8,代码来源:test_opentype.py

示例14: testStaticDef

    def testStaticDef(self):

        class SequenceOf(univ.SequenceOf):
            componentType = univ.OctetString('')

        s = SequenceOf()
        s[0] = 'abc'
        assert len(s) == 1
        assert s == [str2octs('abc')]
开发者ID:luke-chang,项目名称:gecko-1,代码行数:9,代码来源:test_univ.py

示例15: getRecord

def getRecord(fileObj, lineNo=None, offset=0):
    line = fileObj.readline()
    if lineNo is not None and line: lineNo += 1
    while line:
        tline = line.strip()
        # skip comment or blank line
        if not tline or tline.startswith(str2octs('#')):
            offset += len(line)
            line = fileObj.readline()
            if lineNo is not None and line: lineNo += 1
        else:
            break
    return line, lineNo, offset
开发者ID:woodyle,项目名称:snmpsim,代码行数:13,代码来源:file.py


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