コード例 #1
0
ファイル: positioning.py プロジェクト: jameshy/libtree
def ensure_free_position(cur, node, position):
    """
    Move siblings away to have a free slot at ``position`` in the
    children of ``node``.

    :param node:
    :type node: Node or int
    :param int position:
    """
    try:
        get_node_at_position(cur, node, position)
        node_exists_at_position = True
    except ValueError:
        node_exists_at_position = False

    if node_exists_at_position:
        shift_positions(cur, node, position, +1)
コード例 #2
0
def ensure_free_position(cur, node, position):
    """
    Move siblings away to have a free slot at ``position`` in the
    children of ``node``.

    :param node:
    :type node: Node or int
    :param int position:
    """
    try:
        get_node_at_position(cur, node, position)
        node_exists_at_position = True
    except ValueError:
        node_exists_at_position = False

    if node_exists_at_position:
        shift_positions(cur, node, position, +1)
コード例 #3
0
ファイル: test_positioning.py プロジェクト: vortec/libtree
def test_get_node_at_position_non_existing(cur, root, nd3):
    with pytest.raises(ValueError):
        get_node_at_position(cur, root, -1)
    with pytest.raises(ValueError):
        get_node_at_position(cur, str(uuid.uuid4()), 1)
コード例 #4
0
ファイル: test_positioning.py プロジェクト: vortec/libtree
def test_get_node_at_position(cur, root, nd3):
    node = get_node_at_position(cur, root, nd3.position)
    assert node.position == nd3.position
コード例 #5
0
def test_get_node_at_position_non_existing(cur, root, nd3):
    with pytest.raises(ValueError):
        get_node_at_position(cur, root, -1)
    with pytest.raises(ValueError):
        get_node_at_position(cur, -1, 1)
コード例 #6
0
def test_get_node_at_position(cur, root, nd3):
    node = get_node_at_position(cur, root, nd3.position)
    assert node.position == nd3.position