(core) Simple Python 3 compatibility changes

Summary: Changes that move towards python 3 compatibility that are easy to review without much thought

Test Plan: The tests

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2873
This commit is contained in:
Alex Hall
2021-06-22 17:12:25 +02:00
parent cc04c6481a
commit 16f297a250
66 changed files with 551 additions and 437 deletions

View File

@@ -14,6 +14,8 @@ value previously set, since the "right" dataset is "single" values), m.lookup_le
that value, and m.lookup_right(value) returns a `set` of keys that map to the value.
"""
import six
# Special sentinel value which can never be legitimately stored in TwoWayMap, to easily tell the
# difference between a present and absent value.
_NIL = object()
@@ -47,6 +49,8 @@ class TwoWayMap(object):
def __nonzero__(self):
return bool(self._fwd)
__bool__ = __nonzero__
def lookup_left(self, left, default=None):
""" Returns the value(s) on the right corresponding to the given value on the left. """
return self._fwd.get(left, default)
@@ -65,11 +69,11 @@ class TwoWayMap(object):
def left_all(self):
""" Returns an iterable over all values on the left."""
return self._fwd.iterkeys()
return six.iterkeys(self._fwd)
def right_all(self):
""" Returns an iterable over all values on the right."""
return self._bwd.iterkeys()
return six.iterkeys(self._bwd)
def insert(self, left, right):
""" Insert the (left, right) value pair. """