Skip to content

Commit 13931d1

Browse files
committed
cfpropertyname as strenum
1 parent 4e85bcb commit 13931d1

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

server/recceiver/cfstore.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def record_type(cls, owner: str, record_type: str) -> "CFProperty":
109109
owner: The owner of the property.
110110
recordType: The recordType of the property.
111111
"""
112-
return cls(CFPropertyName.recordType.name, owner, record_type)
112+
return cls(CFPropertyName.RECORD_TYPE.value, owner, record_type)
113113

114114
@classmethod
115115
def alias(cls, owner: str, alias: str) -> "CFProperty":
@@ -119,7 +119,7 @@ def alias(cls, owner: str, alias: str) -> "CFProperty":
119119
owner: The owner of the property.
120120
alias: The alias of the property.
121121
"""
122-
return cls(CFPropertyName.alias.name, owner, alias)
122+
return cls(CFPropertyName.ALIAS.value, owner, alias)
123123

124124
@classmethod
125125
def pv_status(cls, owner: str, pv_status: PVStatus) -> "CFProperty":
@@ -129,7 +129,7 @@ def pv_status(cls, owner: str, pv_status: PVStatus) -> "CFProperty":
129129
owner: The owner of the property.
130130
pvStatus: The pvStatus of the property.
131131
"""
132-
return cls(CFPropertyName.pvStatus.value, owner, pv_status.name)
132+
return cls(CFPropertyName.PV_STATUS.value, owner, pv_status.name)
133133

134134
@classmethod
135135
def active(cls, owner: str) -> "CFProperty":
@@ -157,7 +157,7 @@ def time(cls, owner: str, time: str) -> "CFProperty":
157157
owner: The owner of the property.
158158
time: The time of the property.
159159
"""
160-
return cls(CFPropertyName.time.name, owner, time)
160+
return cls(CFPropertyName.TIME.value, owner, time)
161161

162162

163163
@dataclass
@@ -170,21 +170,21 @@ class RecordInfo:
170170
aliases: List[str] = field(default_factory=list)
171171

172172

173-
class CFPropertyName(enum.Enum):
173+
class CFPropertyName(enum.StrEnum):
174174
"""Standard property names used in Channelfinder."""
175175

176-
hostName = enum.auto()
177-
iocName = enum.auto()
178-
iocid = enum.auto()
179-
iocIP = enum.auto()
180-
pvStatus = enum.auto()
181-
time = enum.auto()
182-
recceiverID = enum.auto()
183-
alias = enum.auto()
184-
recordType = enum.auto()
185-
recordDesc = enum.auto()
186-
caPort = enum.auto()
187-
pvaPort = enum.auto()
176+
HOSTNAME = "hostName"
177+
IOC_NAME = "iocName"
178+
IOC_ID = "iocid"
179+
IOC_IP = "iocIP"
180+
PV_STATUS = "pvStatus"
181+
TIME = "time"
182+
RECCEIVER_ID = "recceiverID"
183+
ALIAS = "alias"
184+
RECORD_TYPE = "recordType"
185+
RECORD_DESC = "recordDesc"
186+
CA_PORT = "caPort"
187+
PVA_PORT = "pvaPort"
188188

189189

190190
@dataclass
@@ -291,19 +291,19 @@ def _start_service_with_lock(self):
291291
try:
292292
cf_properties = {cf_property["name"] for cf_property in self.client.getAllProperties()}
293293
required_properties = {
294-
CFPropertyName.hostName.name,
295-
CFPropertyName.iocName.name,
296-
CFPropertyName.iocid.name,
297-
CFPropertyName.iocIP.name,
298-
CFPropertyName.pvStatus.name,
299-
CFPropertyName.time.name,
300-
CFPropertyName.recceiverID.name,
294+
CFPropertyName.HOSTNAME.value,
295+
CFPropertyName.IOC_NAME.value,
296+
CFPropertyName.IOC_ID.value,
297+
CFPropertyName.IOC_IP.value,
298+
CFPropertyName.PV_STATUS.value,
299+
CFPropertyName.TIME.value,
300+
CFPropertyName.RECCEIVER_ID.value,
301301
}
302302

303303
if self.cf_config.alias_enabled:
304-
required_properties.add(CFPropertyName.alias.name)
304+
required_properties.add(CFPropertyName.ALIAS.value)
305305
if self.cf_config.record_type_enabled:
306-
required_properties.add(CFPropertyName.recordType.name)
306+
required_properties.add(CFPropertyName.RECORD_TYPE.value)
307307
env_vars_setting = self.cf_config.environment_variables
308308
self.env_vars = {}
309309
if env_vars_setting != "" and env_vars_setting is not None:
@@ -317,12 +317,12 @@ def _start_service_with_lock(self):
317317
if self.cf_config.ioc_connection_info:
318318
self.env_vars["RSRV_SERVER_PORT"] = "caPort"
319319
self.env_vars["PVAS_SERVER_PORT"] = "pvaPort"
320-
required_properties.add(CFPropertyName.caPort.name)
321-
required_properties.add(CFPropertyName.pvaPort.name)
320+
required_properties.add(CFPropertyName.CA_PORT.value)
321+
required_properties.add(CFPropertyName.PVA_PORT.value)
322322

323323
record_property_names_list = [s.strip(", ") for s in self.cf_config.info_tags.split()]
324324
if self.cf_config.record_description_enabled:
325-
record_property_names_list.append(CFPropertyName.recordDesc.name)
325+
record_property_names_list.append(CFPropertyName.RECORD_DESC.value)
326326
# Are any required properties not already present on CF?
327327
properties = required_properties - cf_properties
328328
# Are any whitelisted properties not already present on CF?
@@ -627,8 +627,8 @@ def get_active_channels(self, recceiverid: str) -> List[CFChannel]:
627627
prepare_find_args(
628628
cf_config=self.cf_config,
629629
args=[
630-
(CFPropertyName.pvStatus.name, PVStatus.ACTIVE.value),
631-
(CFPropertyName.recceiverID.name, recceiverid),
630+
(CFPropertyName.PV_STATUS.value, PVStatus.ACTIVE.value),
631+
(CFPropertyName.RECCEIVER_ID.value, recceiverid),
632632
],
633633
)
634634
)
@@ -1177,13 +1177,13 @@ def create_ioc_properties(
11771177
iocid: The IOC ID of the properties.
11781178
"""
11791179
return [
1180-
CFProperty(CFPropertyName.hostName.name, owner, hostName),
1181-
CFProperty(CFPropertyName.iocName.name, owner, iocName),
1182-
CFProperty(CFPropertyName.iocid.name, owner, iocid),
1183-
CFProperty(CFPropertyName.iocIP.name, owner, iocIP),
1180+
CFProperty(CFPropertyName.HOSTNAME.value, owner, hostName),
1181+
CFProperty(CFPropertyName.IOC_NAME.value, owner, iocName),
1182+
CFProperty(CFPropertyName.IOC_ID.value, owner, iocid),
1183+
CFProperty(CFPropertyName.IOC_IP.value, owner, iocIP),
11841184
CFProperty.active(owner),
11851185
CFProperty.time(owner, iocTime),
1186-
CFProperty(CFPropertyName.recceiverID.name, owner, recceiverid),
1186+
CFProperty(CFPropertyName.RECCEIVER_ID.value, owner, recceiverid),
11871187
]
11881188

11891189

0 commit comments

Comments
 (0)