Port pagination on Python 3
Use an empty string rather None as marker for bisect. On Python 3, a comparison between None and strings now raises a TypeError. Partially implements: blueprint trove-python3 Change-Id: Iaefc20bd1cc980732e0c8a075e570958335c17e1
This commit is contained in:
parent
4512aec2d4
commit
4b6285f702
@ -1,6 +1,4 @@
|
|||||||
# Use a blacklist of tests known to fail on Python 3, until
|
# Use a blacklist of tests known to fail on Python 3, until
|
||||||
# all unit tests will pass on Python 3.
|
# all unit tests will pass on Python 3.
|
||||||
guestagent.test_cassandra_manager
|
|
||||||
guestagent.test_mongodb_manager
|
|
||||||
guestagent.test_operating_system
|
guestagent.test_operating_system
|
||||||
guestagent.test_volume
|
guestagent.test_volume
|
||||||
|
@ -37,6 +37,8 @@ def paginate_list(li, limit=None, marker=None, include_marker=False,
|
|||||||
"""
|
"""
|
||||||
sli = sorted(li, key=key)
|
sli = sorted(li, key=key)
|
||||||
index = [key(item) for item in sli]
|
index = [key(item) for item in sli]
|
||||||
|
if marker is None:
|
||||||
|
marker = ''
|
||||||
if include_marker:
|
if include_marker:
|
||||||
pos = bisect.bisect_left(index, marker)
|
pos = bisect.bisect_left(index, marker)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user