From 581d6747ad1d95926b0de05cb6f4052b5a4b04cd Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Wed, 9 Jan 2013 21:10:39 +0200 Subject: [PATCH] Merge branch 'nano' into 0.9 # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit. --- ChangeLog | 1 + lib/logitech/unifying_receiver/common.py | 7 +++++-- lib/solaar/cli.py | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 589b4424..a763b613 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,3 +4,4 @@ * Fix identifying available dpi values. * Fixed locating application icons when installed in a custom prefix. * Fixed some icon names for the oxygen theme. + * Python 3 fixes. diff --git a/lib/logitech/unifying_receiver/common.py b/lib/logitech/unifying_receiver/common.py index a506a5cf..a69c22aa 100644 --- a/lib/logitech/unifying_receiver/common.py +++ b/lib/logitech/unifying_receiver/common.py @@ -17,7 +17,7 @@ class NamedInt(int): def __new__(cls, value, name): assert isinstance(name, str) or isinstance(name, unicode) obj = int.__new__(cls, value) - obj.name = unicode(name) + obj.name = str(name) return obj def bytes(self, count=2): @@ -66,7 +66,8 @@ class NamedInts(object): def _readable_name(n): if not isinstance(n, str) and not isinstance(n, unicode): raise TypeError("expected string, got " + type(n)) - return n.replace('__', '/').replace('_', ' ') + n = n.replace('__', '/').replace('_', ' ') + return str(n) values = {k: NamedInt(v, _readable_name(k)) for (k, v) in kwargs.items()} self.__dict__ = values @@ -74,6 +75,8 @@ class NamedInts(object): self._indexed = {int(v): v for v in self._values} self._fallback = None + # print ('%r' % self) + @classmethod def range(cls, from_value, to_value, name_generator=lambda x: str(x), step=1): values = {name_generator(x): x for x in range(from_value, to_value + 1, step)} diff --git a/lib/solaar/cli.py b/lib/solaar/cli.py index cb8e4987..4fec12b0 100644 --- a/lib/solaar/cli.py +++ b/lib/solaar/cli.py @@ -253,7 +253,7 @@ def config_device(receiver, args): if s.choices: print ("# possible values: one of [", ', '.join(str(v) for v in s.choices), "], or higher/lower/highest/max/lowest/min") else: - print ("# possible values: true/t/yes/y/1 or false/f/no/n/0") + print ("# possible values: on/true/t/yes/y/1 or off/false/f/no/n/0") value = s.read() if value is None: print ("# %s = ? (failed to read from device)" % s.name) @@ -283,9 +283,9 @@ def config_device(receiver, args): try: value = bool(int(value)) except: - if value.lower() in ['1', 'true', 'yes', 't', 'y']: + if value.lower() in ['1', 'true', 'yes', 'on', 't', 'y']: value = True - elif value.lower() in ['0', 'false', 'no', 'f', 'n']: + elif value.lower() in ['0', 'false', 'no', 'off', 'f', 'n']: value = False else: _fail("don't know how to interpret '%s' as boolean" % value)