(self, key, location)
Change location of an existing item.
Change location of an existing item.
Change location of an existing item .
def link(self, key, location):
        """ Change location of an existing item. """
        n = self.keyOrder.index(key)
        del self.keyOrder[n]
        try:
            i = self.index_for_location(location)
            if i is not None:
                self.keyOrder.insert(i, key)
            else:
                self.keyOrder.append(key)
        except Exception as e:
            # restore to prevent data loss and reraise
            self.keyOrder.insert(n, key)
            raise e
def link ( self , key , location ) : n = self . keyOrder . index ( key ) del self . keyOrder [ n ] try : i = self . index_for_location ( location ) if i is not None : self . keyOrder . insert ( i , key ) else : self . keyOrder . append ( key ) except Exception as e : # restore to prevent data loss and reraise self . keyOrder . insert ( n , key ) raise e