示例#1
0
 def _inc_path(cls, path):
     """
     :returns: The path of the next sibling of a given node path.
     """
     base = len(cls.alphabet)
     newpos = numconv.str2int(path[-cls.steplen:], base, cls.alphabet) + 1
     key = numconv.int2str(newpos, base, cls.alphabet)
     if len(key) > cls.steplen:
         raise PathOverflow("Path Overflow from: '%s'" % (path, ))
     return '%s%s%s' % (path[:-cls.steplen], '0'*(cls.steplen-len(key)),
                        key)
示例#2
0
def test_str2int_with_alphabet():
    assert str2int('baa', alphabet='abcdefghijklm') == 100
示例#3
0
def test_str2int_with_radix_and_alphabet():
    assert str2int('foo', 4, 'rofl') == 37
示例#4
0
def test_str2int(num, radix, expected):
    assert str2int(num, radix) == expected
示例#5
0
 def _get_lastpos_in_path(cls, path):
     """
     :returns: The integer value of the last step in a path.
     """
     return numconv.str2int(path[-cls.steplen:], len(cls.alphabet),
                            cls.alphabet)