UniqueObject

create a class to be used for unique objects.
better for debugging and documentation than just using object()

+ remove unused unique objects

Change-Id: I32f65960ea2fbee4fccbeb49a4e11176b7185aa0
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27455
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
zolliker 2022-01-17 10:44:41 +01:00
parent f3450375ce
commit 0909f92e12
5 changed files with 18 additions and 10 deletions

View File

@ -4,6 +4,8 @@ Reference
Module Base Classes
...................
.. autodata:: secop.modules.Done
.. autoclass:: secop.modules.Module
:members: earlyInit, initModule, startModule, pollerClass

View File

@ -31,9 +31,6 @@ from configparser import ConfigParser
from os import environ, path
unset_value = object()
class GeneralConfig:
def __init__(self):
self._config = None
@ -319,3 +316,11 @@ def formatStatusBits(sword, labels, start=0):
if sword & (1 << i) and lbl:
result.append(lbl)
return result
class UniqueObject:
def __init__(self, name):
self.name = name
def __repr__(self):
return 'UniqueObject(%r)' % self.name

View File

@ -31,14 +31,17 @@ from secop.datatypes import ArrayOf, BoolType, EnumType, FloatRange, \
IntRange, StatusType, StringType, TextType, TupleOf
from secop.errors import BadValueError, ConfigError, \
ProgrammingError, SECoPError, SilentError, secop_error
from secop.lib import formatException, mkthread
from secop.lib import formatException, mkthread, UniqueObject
from secop.lib.enum import Enum
from secop.params import Accessible, Command, Parameter
from secop.poller import BasicPoller, Poller
from secop.properties import HasProperties, Property
from secop.logging import RemoteLogHandler, HasComlog
Done = object() #: a special return value for a read/write function indicating that the setter is triggered already
Done = UniqueObject('already set')
"""a special return value for a read/write function
indicating that the setter is triggered already"""
class HasAccessibles(HasProperties):

View File

@ -31,8 +31,6 @@ from secop.datatypes import BoolType, CommandType, DataType, \
from secop.errors import BadValueError, ProgrammingError
from secop.properties import HasProperties, Property
UNSET = object() # an argument not given, not even None
class Accessible(HasProperties):
"""base class for Parameter and Command

View File

@ -26,8 +26,11 @@
import inspect
from secop.errors import BadValueError, ConfigError, ProgrammingError
from secop.lib import UniqueObject
from secop.lib.py35compat import Object
UNSET = UniqueObject('undefined value') #: an unset value, not even None
class HasDescriptors(Object):
@classmethod
@ -39,9 +42,6 @@ class HasDescriptors(Object):
raise ProgrammingError('misplaced trailing comma after %s.%s' % (cls.__name__, '/'.join(bad)))
UNSET = object() # an unset value, not even None
# storage for 'properties of a property'
class Property:
"""base class holding info about a property