44
55import at
66import pytac
7- from pytac .exceptions import FieldException , HandleException , ControlSystemException
7+ from pytac .exceptions import ControlSystemException , FieldException , HandleException
88
99
1010class ATElementDataSource (pytac .data_source .DataSource ):
@@ -87,9 +87,7 @@ def __init__(self, at_element, index, atsim, fields=None):
8787 # We assume that every set field has a corresponding get field.
8888 supported_fields = set (self ._get_field_funcs .keys ())
8989 if not all (f in supported_fields for f in fields ):
90- raise FieldException (
91- "Unsupported field(s) {0}." .format (fields - supported_fields )
92- )
90+ raise FieldException (f"Unsupported field(s) { fields - supported_fields } ." )
9391 else :
9492 self ._fields = list (fields )
9593
@@ -117,11 +115,10 @@ def add_field(self, field):
117115 """
118116 if field in self ._fields :
119117 raise FieldException (
120- "Field {0} already present on element data "
121- "source {1}." .format (field , self )
118+ f"Field { field } already present on element data source { self } ."
122119 )
123120 elif field not in self ._get_field_funcs .keys ():
124- raise FieldException ("Unsupported field {0 }." . format ( field ) )
121+ raise FieldException (f "Unsupported field { field } ." )
125122 else :
126123 self ._fields .append (field )
127124
@@ -151,7 +148,7 @@ def get_value(self, field, handle=None, throw=True):
151148 # complete before a value is returned; if the wait times out then raise
152149 # an error message or log a warning according to the value of throw.
153150 if not self ._atsim .wait_for_calculations ():
154- error_msg = "Check for completion of outstanding " " calculations timed out."
151+ error_msg = "Check for completion of outstanding calculations timed out."
155152 if throw :
156153 raise ControlSystemException (error_msg )
157154 else :
@@ -160,9 +157,7 @@ def get_value(self, field, handle=None, throw=True):
160157 if field in self ._fields :
161158 return self ._get_field_funcs [field ]()
162159 else :
163- raise FieldException (
164- "No field {0} on AT element {1}." .format (field , self ._at_element )
165- )
160+ raise FieldException (f"No field { field } on AT element { self ._at_element } ." )
166161
167162 def set_value (self , field , value , throw = None ):
168163 """Set the value for a field. The field and value go onto the queue of
@@ -182,17 +177,13 @@ def set_value(self, field, value, throw=None):
182177 """
183178 if field in self ._fields :
184179 if field in self ._set_field_funcs .keys ():
185- self ._atsim .up_to_date .Reset ()
186180 self ._atsim .queue_set (self ._make_change , field , value )
187181 else :
188182 raise HandleException (
189- "Field {0} cannot be set on element data"
190- " source {1}." .format (field , self )
183+ f"Field { field } cannot be set on element data source { self } ."
191184 )
192185 else :
193- raise FieldException (
194- "No field {0} on AT element {1}." .format (field , self ._at_element )
195- )
186+ raise FieldException (f"No field { field } on AT element { self ._at_element } ." )
196187
197188 def _make_change (self , field , value ):
198189 """Calls the appropriate field setting function to actually modify the
@@ -466,7 +457,7 @@ def get_value(self, field, handle=None, throw=True):
466457 return self ._field_funcs [field ]()
467458 else :
468459 raise FieldException (
469- "Lattice data source {0 } does not have field " "{1}" . format ( self , field )
460+ f "Lattice data source { self } does not have field { field } "
470461 )
471462
472463 def set_value (self , field , value , throw = None ):
@@ -486,5 +477,5 @@ def set_value(self, field, value, throw=None):
486477 currently supported.
487478 """
488479 raise HandleException (
489- "Field {0 } cannot be set on lattice data source " "{1 }.". format ( field , self )
480+ f "Field { field } cannot be set on lattice data source { self } ."
490481 )
0 commit comments