Revision 35554b4f lib/cmdlib.py

b/lib/cmdlib.py
11837 11837
      # Append
11838 11838
      absidx = len(container) - 1
11839 11839
    elif idx < 0:
11840
      raise IndexError("Not accepting negative indices")
11840
      raise IndexError("Not accepting negative indices other than -1")
11841
    elif idx > len(container):
11842
      raise IndexError("Got %s index %s, but there are only %s" %
11843
                       (kind, idx, len(container)))
11841 11844
    else:
11842 11845
      absidx = idx
11843 11846

  
11844 11847
    changes = None
11845 11848

  
11846 11849
    if op == constants.DDM_ADD:
11850
      # Calculate where item will be added
11851
      if idx == -1:
11852
        addidx = len(container)
11853
      else:
11854
        addidx = idx
11855

  
11847 11856
      if create_fn is None:
11848 11857
        item = params
11849 11858
      else:
11850
        (item, changes) = create_fn(absidx + 1, params, private)
11859
        (item, changes) = create_fn(addidx, params, private)
11851 11860

  
11852 11861
      if idx == -1:
11853 11862
        container.append(item)
11854 11863
      else:
11855 11864
        assert idx >= 0
11865
        assert idx <= len(container)
11856 11866
        # list.insert does so before the specified index
11857 11867
        container.insert(idx, item)
11858 11868
    else:

Also available in: Unified diff