Skip to content

Commit 51a845a

Browse files
committed
cfpropertyname as strenum
1 parent 8113ee2 commit 51a845a

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
@@ -292,19 +292,19 @@ def _start_service_with_lock(self):
292292
try:
293293
cf_properties = {cf_property["name"] for cf_property in self.client.getAllProperties()}
294294
required_properties = {
295-
CFPropertyName.hostName.name,
296-
CFPropertyName.iocName.name,
297-
CFPropertyName.iocid.name,
298-
CFPropertyName.iocIP.name,
299-
CFPropertyName.pvStatus.name,
300-
CFPropertyName.time.name,
301-
CFPropertyName.recceiverID.name,
295+
CFPropertyName.HOSTNAME.value,
296+
CFPropertyName.IOC_NAME.value,
297+
CFPropertyName.IOC_ID.value,
298+
CFPropertyName.IOC_IP.value,
299+
CFPropertyName.PV_STATUS.value,
300+
CFPropertyName.TIME.value,
301+
CFPropertyName.RECCEIVER_ID.value,
302302
}
303303

304304
if self.cf_config.alias_enabled:
305-
required_properties.add(CFPropertyName.alias.name)
305+
required_properties.add(CFPropertyName.ALIAS.value)
306306
if self.cf_config.record_type_enabled:
307-
required_properties.add(CFPropertyName.recordType.name)
307+
required_properties.add(CFPropertyName.RECORD_TYPE.value)
308308
env_vars_setting = self.cf_config.environment_variables
309309
self.env_vars = {}
310310
if env_vars_setting != "" and env_vars_setting is not None:
@@ -318,12 +318,12 @@ def _start_service_with_lock(self):
318318
if self.cf_config.ioc_connection_info:
319319
self.env_vars["RSRV_SERVER_PORT"] = "caPort"
320320
self.env_vars["PVAS_SERVER_PORT"] = "pvaPort"
321-
required_properties.add(CFPropertyName.caPort.name)
322-
required_properties.add(CFPropertyName.pvaPort.name)
321+
required_properties.add(CFPropertyName.CA_PORT.value)
322+
required_properties.add(CFPropertyName.PVA_PORT.value)
323323

324324
record_property_names_list = [s.strip(", ") for s in self.cf_config.info_tags.split()]
325325
if self.cf_config.record_description_enabled:
326-
record_property_names_list.append(CFPropertyName.recordDesc.name)
326+
record_property_names_list.append(CFPropertyName.RECORD_DESC.value)
327327
# Are any required properties not already present on CF?
328328
properties = required_properties - cf_properties
329329
# Are any whitelisted properties not already present on CF?
@@ -629,8 +629,8 @@ def get_active_channels(self, recceiverid: str) -> List[CFChannel]:
629629
prepare_find_args(
630630
cf_config=self.cf_config,
631631
args=[
632-
(CFPropertyName.pvStatus.name, PVStatus.ACTIVE.value),
633-
(CFPropertyName.recceiverID.name, recceiverid),
632+
(CFPropertyName.PV_STATUS.value, PVStatus.ACTIVE.value),
633+
(CFPropertyName.RECCEIVER_ID.value, recceiverid),
634634
],
635635
)
636636
)
@@ -1179,13 +1179,13 @@ def create_ioc_properties(
11791179
iocid: The IOC ID of the properties.
11801180
"""
11811181
return [
1182-
CFProperty(CFPropertyName.hostName.name, owner, hostName),
1183-
CFProperty(CFPropertyName.iocName.name, owner, iocName),
1184-
CFProperty(CFPropertyName.iocid.name, owner, iocid),
1185-
CFProperty(CFPropertyName.iocIP.name, owner, iocIP),
1182+
CFProperty(CFPropertyName.HOSTNAME.value, owner, hostName),
1183+
CFProperty(CFPropertyName.IOC_NAME.value, owner, iocName),
1184+
CFProperty(CFPropertyName.IOC_ID.value, owner, iocid),
1185+
CFProperty(CFPropertyName.IOC_IP.value, owner, iocIP),
11861186
CFProperty.active(owner),
11871187
CFProperty.time(owner, iocTime),
1188-
CFProperty(CFPropertyName.recceiverID.name, owner, recceiverid),
1188+
CFProperty(CFPropertyName.RECCEIVER_ID.value, owner, recceiverid),
11891189
]
11901190

11911191

0 commit comments

Comments
 (0)