11from typing import Any
22
33import xmltodict
4- from pydantic import BaseModel , model_validator
54
65from daq_config_server .converters ._converter_utils import (
76 BEAMLINE_PARAMETER_KEYWORDS ,
109 parse_value ,
1110 remove_comments ,
1211)
12+ from daq_config_server .converters .models import DisplayConfig , DisplayConfigData
1313
1414
1515def beamline_parameters_to_dict (contents : str ) -> dict [str , Any ]:
@@ -35,33 +35,6 @@ def beamline_parameters_to_dict(contents: str) -> dict[str, Any]:
3535 return dict (config_pairs )
3636
3737
38- class DisplayConfigData (BaseModel ):
39- crosshairX : int
40- crosshairY : int
41- topLeftX : int
42- topLeftY : int
43- bottomRightX : int
44- bottomRightY : int
45-
46-
47- class DisplayConfig (BaseModel ):
48- zoom_levels : dict [float , DisplayConfigData ]
49- required_zoom_levels : set [float ] | None = None
50-
51- @model_validator (mode = "after" )
52- def check_zoom_levels_match_required (self ):
53- existing_keys = set (self .zoom_levels .keys ())
54- if (
55- self .required_zoom_levels is not None
56- and self .required_zoom_levels != existing_keys
57- ):
58- raise ValueError (
59- f"Zoom levels { existing_keys } "
60- f"do not match required zoom levels: { self .required_zoom_levels } "
61- )
62- return self
63-
64-
6538def display_config_to_dict (contents : str ) -> DisplayConfig :
6639 """Converts a display config file into a dict. Every zoom level entry in the
6740 configuration file forms a key in the dict, with value being another dict. This
0 commit comments