removed DefaultRepresentation mixin, moved code to only place (AdjustableVirtual) where it is still used for easier refactor

This commit is contained in:
2020-07-17 19:06:43 +02:00
parent b2f2ac441b
commit 02bdfe6f74
2 changed files with 18 additions and 21 deletions
-19
View File
@@ -1,5 +1,3 @@
import colorama
class SpecConvenience:
@@ -44,20 +42,3 @@ class SpecConvenience:
class DefaultRepresentation:
def _get_name(self):
if self.alias:
return self.alias.get_full_name()
elif self.name:
return self.name
else:
return self.Id
def __repr__(self):
s = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')+': '
s += f"{colorama.Style.BRIGHT}{self._get_name()}{colorama.Style.RESET_ALL} at {colorama.Style.BRIGHT}{self.get_current_value():g}{colorama.Style.RESET_ALL}"
return s
+18 -2
View File
@@ -5,7 +5,7 @@ from enum import IntEnum, auto
import colorama
import time
import datetime
from .convenience import SpecConvenience, DefaultRepresentation
from .convenience import SpecConvenience
class PvRecord:
@@ -139,7 +139,7 @@ class PvEnum(SpecConvenience):
class AdjustableVirtual(SpecConvenience, DefaultRepresentation):
class AdjustableVirtual(SpecConvenience):
def __init__(
self,
@@ -204,4 +204,20 @@ class AdjustableVirtual(SpecConvenience, DefaultRepresentation):
adj.set_current_value(val)
#TODO: below from DefaultRepresentation
def _get_name(self):
if self.alias:
return self.alias.get_full_name()
elif self.name:
return self.name
else:
return self.Id
def __repr__(self):
s = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')+': '
s += f"{colorama.Style.BRIGHT}{self._get_name()}{colorama.Style.RESET_ALL} at {colorama.Style.BRIGHT}{self.get_current_value():g}{colorama.Style.RESET_ALL}"
return s