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)
def test_str2int_with_alphabet(): assert str2int('baa', alphabet='abcdefghijklm') == 100
def test_str2int_with_radix_and_alphabet(): assert str2int('foo', 4, 'rofl') == 37
def test_str2int(num, radix, expected): assert str2int(num, radix) == expected
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)