pyaml.yellow_pages#
Dynamic discovery service for accelerator objects.
Fully dynamic YellowPages service attached to Accelerator.
- Key points:
Auto-discovery only: arrays, tools and diagnostics are discovered at runtime by scanning all modes.
No caching: every call reflects current runtime state.
- Simple query syntax for identifiers:
- wildcard / fnmatch:
yp[“OH4*”]
- regular expression:
yp[“re:^SH1A-C0[12]-H$”]
Accelerator interface#
controls() -> dict[str, ElementHolder]
simulators() -> dict[str, ElementHolder]
modes() -> dict[str, ElementHolder]
Classes
|
Dynamic discovery service for accelerator objects. |
|
Kind of object a YellowPages entry refers to. |
Exceptions
|
YellowPages-specific error with clear user-facing messages. |
|
Raised when a YellowPages query string cannot be evaluated. |
- exception pyaml.yellow_pages.YellowPagesError(message)#
Bases:
PyAMLExceptionYellowPages-specific error with clear user-facing messages.
- exception pyaml.yellow_pages.YellowPagesQueryError(message)#
Bases:
YellowPagesErrorRaised when a YellowPages query string cannot be evaluated.
- class pyaml.yellow_pages.YellowPages(accelerator)#
Bases:
objectDynamic discovery service for accelerator objects.
YellowPagesprovides a unified access layer to arrays, tuning tools and diagnostics available in anAccelerator.Entries are discovered dynamically by scanning all
ElementHolderinstances associated with theAcceleratorcontrol and simulation modes.- Parameters:
accelerator ('Accelerator') – Accelerator whose modes are scanned on every query.
Methods
Check whether a YellowPages key exists.
Return the list of available categories.
Return available YellowPages keys.
Return the set of modes where a key is available.
Search identifiers using a wildcard or regular expression.
Notes
The
Acceleratormust provide:controls() -> dict[str, ElementHolder]simulators() -> dict[str, ElementHolder]modes() -> dict[str, ElementHolder]
Examples
Print the global overview:
>>> print(sr.yellow_pages)
Resolve an entry across all modes:
>>> sr.yellow_pages.get("BPM")
Resolve in a specific mode:
>>> sr.yellow_pages.get("BPM", mode="live")
Search identifiers using wildcards:
>>> sr.yellow_pages["OH4*"]
Search identifiers using a regular expression:
>>> sr.yellow_pages["re:^SH1A-C0[12]-H$"]
- availability(key)#
Return the set of modes where a key is available.
- Parameters:
key (str) – Entry name.
- Returns:
set[str]
- Return type:
set[str]
Examples
>>> sr.yellow_pages.availability("BPM") >>> sr.yellow_pages.availability("DEFAULT_ORBIT_CORRECTION")
- categories()#
Return the list of available categories.
Only categories that contain entries are returned.
- Returns:
list[str]
- Return type:
list[str]
Examples
>>> sr.yellow_pages.categories() ['Arrays', 'Tools', 'Diagnostics']
- get(query, mode=None)#
Search identifiers using a wildcard or regular expression.
- Parameters:
query (str) – Search expression.
mode (str, optional) – Restrict the search to a specific
Acceleratormode.
- Returns:
list[str]
- Return type:
list[str]
Examples
>>> sr.yellow_pages.get("OH4*") >>> sr.yellow_pages.get("OH4*", mode="live") >>> sr.yellow_pages.get("re:^SH1A-C0[12]-H$")
- has(key)#
Check whether a YellowPages key exists.
- Parameters:
key (str) – Entry name.
- Returns:
bool –
Trueif the key exists.- Return type:
bool
Examples
>>> sr.yellow_pages.has("BPM") True
>>> sr.yellow_pages.has("UNKNOWN") False
- keys(category=None)#
Return available YellowPages keys.
- Parameters:
category (str or YellowPagesCategory, optional) – Restrict the result to a specific category.
- Returns:
list[str]
- Return type:
list[str]
Examples
All entries:
>>> sr.yellow_pages.keys()
Only arrays:
>>> sr.yellow_pages.keys("Arrays")
Using enum:
>>> sr.yellow_pages.keys(YellowPagesCategory.ARRAYS)
- class pyaml.yellow_pages.YellowPagesCategory(*values)#
Bases:
str,EnumKind of object a YellowPages entry refers to.
Attributes
ARRAYSNamed element families declared in the
arraysconfiguration section.TOOLSTuning and measurement tools attached to a mode.
DIAGNOSTICSMonitors such as betatron tune and chromaticity monitors.