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:
parent
f3450375ce
commit
0909f92e12
@ -4,6 +4,8 @@ Reference
|
|||||||
Module Base Classes
|
Module Base Classes
|
||||||
...................
|
...................
|
||||||
|
|
||||||
|
.. autodata:: secop.modules.Done
|
||||||
|
|
||||||
.. autoclass:: secop.modules.Module
|
.. autoclass:: secop.modules.Module
|
||||||
:members: earlyInit, initModule, startModule, pollerClass
|
:members: earlyInit, initModule, startModule, pollerClass
|
||||||
|
|
||||||
|
@ -31,9 +31,6 @@ from configparser import ConfigParser
|
|||||||
from os import environ, path
|
from os import environ, path
|
||||||
|
|
||||||
|
|
||||||
unset_value = object()
|
|
||||||
|
|
||||||
|
|
||||||
class GeneralConfig:
|
class GeneralConfig:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._config = None
|
self._config = None
|
||||||
@ -319,3 +316,11 @@ def formatStatusBits(sword, labels, start=0):
|
|||||||
if sword & (1 << i) and lbl:
|
if sword & (1 << i) and lbl:
|
||||||
result.append(lbl)
|
result.append(lbl)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class UniqueObject:
|
||||||
|
def __init__(self, name):
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'UniqueObject(%r)' % self.name
|
||||||
|
@ -31,14 +31,17 @@ from secop.datatypes import ArrayOf, BoolType, EnumType, FloatRange, \
|
|||||||
IntRange, StatusType, StringType, TextType, TupleOf
|
IntRange, StatusType, StringType, TextType, TupleOf
|
||||||
from secop.errors import BadValueError, ConfigError, \
|
from secop.errors import BadValueError, ConfigError, \
|
||||||
ProgrammingError, SECoPError, SilentError, secop_error
|
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.lib.enum import Enum
|
||||||
from secop.params import Accessible, Command, Parameter
|
from secop.params import Accessible, Command, Parameter
|
||||||
from secop.poller import BasicPoller, Poller
|
from secop.poller import BasicPoller, Poller
|
||||||
from secop.properties import HasProperties, Property
|
from secop.properties import HasProperties, Property
|
||||||
from secop.logging import RemoteLogHandler, HasComlog
|
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):
|
class HasAccessibles(HasProperties):
|
||||||
|
@ -31,8 +31,6 @@ from secop.datatypes import BoolType, CommandType, DataType, \
|
|||||||
from secop.errors import BadValueError, ProgrammingError
|
from secop.errors import BadValueError, ProgrammingError
|
||||||
from secop.properties import HasProperties, Property
|
from secop.properties import HasProperties, Property
|
||||||
|
|
||||||
UNSET = object() # an argument not given, not even None
|
|
||||||
|
|
||||||
|
|
||||||
class Accessible(HasProperties):
|
class Accessible(HasProperties):
|
||||||
"""base class for Parameter and Command
|
"""base class for Parameter and Command
|
||||||
|
@ -26,8 +26,11 @@
|
|||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from secop.errors import BadValueError, ConfigError, ProgrammingError
|
from secop.errors import BadValueError, ConfigError, ProgrammingError
|
||||||
|
from secop.lib import UniqueObject
|
||||||
from secop.lib.py35compat import Object
|
from secop.lib.py35compat import Object
|
||||||
|
|
||||||
|
UNSET = UniqueObject('undefined value') #: an unset value, not even None
|
||||||
|
|
||||||
|
|
||||||
class HasDescriptors(Object):
|
class HasDescriptors(Object):
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -39,9 +42,6 @@ class HasDescriptors(Object):
|
|||||||
raise ProgrammingError('misplaced trailing comma after %s.%s' % (cls.__name__, '/'.join(bad)))
|
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'
|
# storage for 'properties of a property'
|
||||||
class Property:
|
class Property:
|
||||||
"""base class holding info about a property
|
"""base class holding info about a property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user