Making sure we're ready for python3

Stops making use of the builtin cmp function, and replaces
it with the recommended (a > b) - (a < b).

Switches pep8 python to python3

Change-Id: If4a45108fe93080f9967e2ac26d681b8dd5c7fc2
This commit is contained in:
Miguel Angel Ajo 2018-10-01 10:54:49 +02:00
parent 352a5ab8f2
commit 637fa32ced
2 changed files with 8 additions and 3 deletions

View File

@ -110,7 +110,8 @@ class LogEntry(object):
self.data += EXTRALINES_PADDING + line
def __cmp__(self, other):
return cmp(self.dt, other.dt) * 2 + cmp(self.alias, other.alias)
return (self._cmp(self.dt, other.dt) * 2 +
self._cmp(self.alias, other.alias))
def __lt__(self, other):
return self.dt < other.dt or (self.dt == other.dt and
@ -119,6 +120,10 @@ class LogEntry(object):
def __str__(self):
return '%s [%s] %s' % (self.dt_str, self.alias, self.data.rstrip('\n'))
@staticmethod
def _cmp(a, b):
return (a > b) - (a < b)
class LogParser(object):
def __init__(self, filename, cfg):

View File

@ -1,5 +1,5 @@
[tox]
envlist = py35,py36,py27,pep8
envlist = py35,py36,py37,py27,pep8
minversion = 2.3.2
skipsdist = True
@ -24,7 +24,7 @@ setenv = OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:180}
commands = false
[testenv:pep8]
basepython = python2.7
basepython = python3
deps =
{[testenv]deps}
commands=