further fixes of py3 issues

complaints by pylint are mainly related to
- remove object from base list in class definitions
- unnecessary else/elif after return/raise

Change-Id: I13d15449149cc8bba0562338d0c9c42e97163bdf
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/21325
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2019-09-26 13:17:49 +02:00
parent 70a9c42a7a
commit c1164568ae
33 changed files with 83 additions and 89 deletions

View File

@ -32,6 +32,7 @@ import subprocess
import sys
import threading
import traceback
import importlib
from os import path
repodir = path.abspath(path.join(path.dirname(__file__), '..', '..'))
@ -51,7 +52,7 @@ CONFIG = {
unset_value = object()
class lazy_property(object):
class lazy_property:
"""A property that calculates its value only once."""
def __init__(self, func):
@ -89,7 +90,6 @@ def clamp(_min, value, _max):
def get_class(spec):
"""loads a class given by string in dotted notaion (as python would do)"""
modname, classname = spec.rsplit('.', 1)
import importlib
if modname.startswith('secop'):
module = importlib.import_module(modname)
else:

View File

@ -26,7 +26,7 @@
__ALL__ = ['Enum']
class EnumMember(object):
class EnumMember:
"""represents one member of an Enum
has an int-type value and attributes 'name' and 'value'
@ -53,7 +53,7 @@ class EnumMember(object):
return -1 # XXX:!
if self.value < other:
return -1
elif self.value > other:
if self.value > other:
return 1
return 0
@ -262,7 +262,7 @@ class Enum(dict):
elif isinstance(parent, dict):
for k, v in parent.items():
add(self, k, v)
elif parent != None:
elif parent is not None:
raise TypeError('parent (if given) MUST be a dict or an Enum!')
for k, v in kwds.items():
add(self, k, v)
@ -286,7 +286,7 @@ class Enum(dict):
raise TypeError('Enum %r can not be changed!' % self.name)
def __repr__(self):
return '<Enum %r (%d values)>' % (self.name, len(self)/2)
return '<Enum %r (%d values)>' % (self.name, len(self)//2)
def __call__(self, key):
return self[key]

View File

@ -149,7 +149,7 @@ def format_args(args):
return repr(args) # for floats/ints/...
class ArgsParser(object):
class ArgsParser:
"""returns a pythonic object from the input expression
grammar:
@ -164,10 +164,8 @@ class ArgsParser(object):
name = [A-Za-z_] [A-Za-z0-9_]*
"""
DIGITS_CHARS = [c for c in '0123456789']
NAME_CHARS = [
c for c in '_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
]
DIGITS_CHARS = '0123456789'
NAME_CHARS = '_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
NAME_CHARS2 = NAME_CHARS + DIGITS_CHARS
def __init__(self, string=''):
@ -276,7 +274,7 @@ class ArgsParser(object):
def parse_record(self):
"""record_expr = '(' (name '=' expr ',')* ')' """
if self.get != '(':
if self.get() != '(':
return None
self.skip()
res = {}

View File

@ -30,11 +30,11 @@ from secop.errors import IsBusyError
from secop.lib import mkthread
class Namespace(object):
class Namespace:
pass
class Step(object):
class Step:
def __init__(self, desc, waittime, func, *args, **kwds):
self.desc = desc
@ -44,7 +44,7 @@ class Step(object):
self.kwds = kwds
class SequencerMixin(object):
class SequencerMixin:
"""Mixin for worker classes that need to execute a sequence of actions,
including waits, that exceeds the usual Tango timeout (about 3 seconds)
and should be executed asynchronously.
@ -129,11 +129,11 @@ class SequencerMixin(object):
def read_status(self):
if self.seq_is_alive():
return self.Status.BUSY, 'moving: ' + self._seq_phase
elif self._seq_error:
if self._seq_error:
if self._seq_fault_on_error:
return self.Status.ERROR, self._seq_error
return self.Status.WARN, self._seq_error
elif self._seq_stopped:
if self._seq_stopped:
if self._seq_fault_on_stop:
return self.Status.ERROR, self._seq_stopped
return self.Status.WARN, self._seq_stopped