# HG changeset patch # User Denis Laxalde # Date 1435245213 -7200 # Node ID 830f1ea527892dae050b63dfd9da344abdd12d78 # Parent cb217b2b3463d7def9fd82262f051e7236ff7bd4 [utils] Drop now-unused SizeConstrainedList It's last usage in CubicWeb got removed from changeset '[views] remove breadcrumbs usage to retrieve last visited page' Related to #5456850. diff -r cb217b2b3463 -r 830f1ea52789 doc/changes/3.22.rst --- a/doc/changes/3.22.rst Wed Nov 25 18:31:48 2015 +0100 +++ b/doc/changes/3.22.rst Thu Jun 25 17:13:33 2015 +0200 @@ -67,3 +67,5 @@ * the ``cubicweb.server.hooksmanager`` module was removed * the ``Repository.pinfo()`` method was removed + +* the ``cubicweb.utils.SizeConstrainedList`` class was removed diff -r cb217b2b3463 -r 830f1ea52789 test/unittest_utils.py --- a/test/unittest_utils.py Wed Nov 25 18:31:48 2015 +0100 +++ b/test/unittest_utils.py Thu Jun 25 17:13:33 2015 +0200 @@ -26,8 +26,8 @@ from logilab.common.testlib import TestCase, DocTest, unittest_main from cubicweb.devtools.testlib import CubicWebTC -from cubicweb.utils import (make_uid, UStringIO, SizeConstrainedList, - RepeatList, HTMLHead, QueryCache, parse_repo_uri) +from cubicweb.utils import (make_uid, UStringIO, RepeatList, HTMLHead, + QueryCache, parse_repo_uri) from cubicweb.entity import Entity try: @@ -166,25 +166,6 @@ self.assertEqual(l, [(1, 3)]*2) -class SizeConstrainedListTC(TestCase): - - def test_append(self): - l = SizeConstrainedList(10) - for i in range(12): - l.append(i) - self.assertEqual(l, list(range(2, 12))) - - def test_extend(self): - testdata = [(list(range(5)), list(range(5))), - (list(range(10)), list(range(10))), - (list(range(12)), list(range(2, 12))), - ] - for extension, expected in testdata: - l = SizeConstrainedList(10) - l.extend(extension) - yield self.assertEqual, l, expected - - class JSONEncoderTC(TestCase): def setUp(self): if json is None: diff -r cb217b2b3463 -r 830f1ea52789 utils.py --- a/utils.py Wed Nov 25 18:31:48 2015 +0100 +++ b/utils.py Thu Jun 25 17:13:33 2015 +0200 @@ -139,39 +139,6 @@ yield subchild -class SizeConstrainedList(list): - """simple list that makes sure the list does not get bigger than a given - size. - - when the list is full and a new element is added, the first element of the - list is removed before appending the new one - - >>> l = SizeConstrainedList(2) - >>> l.append(1) - >>> l.append(2) - >>> l - [1, 2] - >>> l.append(3) - >>> l - [2, 3] - """ - def __init__(self, maxsize): - self.maxsize = maxsize - - def append(self, element): - if len(self) == self.maxsize: - del self[0] - super(SizeConstrainedList, self).append(element) - - def extend(self, sequence): - super(SizeConstrainedList, self).extend(sequence) - keepafter = len(self) - self.maxsize - if keepafter > 0: - del self[:keepafter] - - __iadd__ = extend - - class RepeatList(object): """fake a list with the same element in each row""" __slots__ = ('_size', '_item')