mxcubecore 1.385.0__py3-none-any.whl → 1.386.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mxcubecore might be problematic. Click here for more details.

@@ -312,6 +312,98 @@ class SampleChanger(Container, HardwareObject):
312
312
  """
313
313
  return self.status
314
314
 
315
+ def get_contents_as_dict(self) -> dict:
316
+ """
317
+ Build and return the hierarchical structure of the sample changer contents.
318
+
319
+ Returns:
320
+ dict: A nested dictionary describing the sample changer contents.
321
+ {
322
+ "name": <str>, # root sample changer address
323
+ "room_temperature_mode": <bool> (optional),
324
+ "children": [
325
+ {
326
+ "name": <str>, # element address
327
+ "status": <str>, # "Loaded", "Used", "Present", or ""
328
+ "id": <str>, # element ID
329
+ "selected": <bool>, # whether element is selected
330
+ "children": [ ... ] # nested elements, same structure
331
+ },
332
+ ...
333
+ ]
334
+ }
335
+ """
336
+ contents = {"name": self.get_address()}
337
+
338
+ if hasattr(self, "get_room_temperature_mode"):
339
+ contents["room_temperature_mode"] = self.get_room_temperature_mode()
340
+
341
+ for element in self.get_components():
342
+ if element.is_present():
343
+ self._add_element(contents, element)
344
+
345
+ return contents
346
+
347
+ def _get_status(self, element) -> str:
348
+ """
349
+ Determine the status string for a sample changer element.
350
+
351
+ Args:
352
+ element: The element object to check.
353
+
354
+ Returns:
355
+ str: One of:
356
+ - "Loaded": element is a leaf and currently loaded
357
+ - "Used": element is a leaf and has been loaded before
358
+ - "Present": element is present in the changer
359
+ - "": element is not present
360
+ """
361
+ if element.is_leaf():
362
+ if element.is_loaded():
363
+ return "Loaded"
364
+ if element.has_been_loaded():
365
+ return "Used"
366
+ return ""
367
+ return "Present" if element.is_present() else ""
368
+
369
+ def _get_id(self, element) -> str:
370
+ """
371
+ Get the unique identifier (ID or token) for a sample changer element.
372
+
373
+ Args:
374
+ element: The element to get the ID for.
375
+
376
+ Returns:
377
+ str: The token (if root sample changer and available),
378
+ the element ID (if available), or an empty string.
379
+ """
380
+ if element == self:
381
+ token = element.get_token()
382
+ return token if token else ""
383
+
384
+ return element.get_id() or ""
385
+
386
+ def _add_element(self, parent, element) -> dict:
387
+ """
388
+ Recursively add an element and its children into the contents dictionary.
389
+
390
+ Args:
391
+ parent (dict): The parent dictionary to append the element to.
392
+ element: The element object to add.
393
+ """
394
+ new_element = {
395
+ "name": element.get_address(),
396
+ "status": self._get_status(element),
397
+ "id": self._get_id(element),
398
+ "selected": element.is_selected(),
399
+ }
400
+
401
+ parent.setdefault("children", []).append(new_element)
402
+
403
+ if not element.is_leaf():
404
+ for child in element.get_components():
405
+ self._add_element(new_element, child)
406
+
315
407
  @property
316
408
  def progress_message(self) -> str:
317
409
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mxcubecore
3
- Version: 1.385.0
3
+ Version: 1.386.0
4
4
  Summary: Core libraries for the MXCuBE application
5
5
  License: LGPL-3.0-or-later
6
6
  Keywords: mxcube,mxcube3,mxcubecore
@@ -359,7 +359,7 @@ mxcubecore/HardwareObjects/abstract/AbstractNState.py,sha256=JZvD_ZpQu5U8ycaWFii
359
359
  mxcubecore/HardwareObjects/abstract/AbstractOnlineProcessing.py,sha256=vs_fJsDDLwivu1kYHA7RKJXj1aTH5V6G2tEy7MYGw4c,34104
360
360
  mxcubecore/HardwareObjects/abstract/AbstractProcedure.py,sha256=kW2SzN5kYYCeOS2IzpzQ9VAjYAoRU7ZtyDxqrOb8Pbg,7849
361
361
  mxcubecore/HardwareObjects/abstract/AbstractResolution.py,sha256=eLoymf-i637FbwfZwOtTmKOeSqCQjE2OnpSMdl8oIEg,8524
362
- mxcubecore/HardwareObjects/abstract/AbstractSampleChanger.py,sha256=h9j7XF8KrRtVQpthF_424fsEIR2LqsEZLNPrLaQB4TI,26718
362
+ mxcubecore/HardwareObjects/abstract/AbstractSampleChanger.py,sha256=f_D8YSoHPHkVLtGBobKEw79oMDf4rBL1y4Io3bqYnIw,29968
363
363
  mxcubecore/HardwareObjects/abstract/AbstractSampleView.py,sha256=-E9cTMW-gw2vY91OeL2V5wg1icduLeYFOX50vo2_NEA,7774
364
364
  mxcubecore/HardwareObjects/abstract/AbstractShutter.py,sha256=OeHSr3N9x-a9QmGdQEu3usN23TYspJGDnZjAkShqk3w,2798
365
365
  mxcubecore/HardwareObjects/abstract/AbstractSlits.py,sha256=1fymQFlxJ9naOVT9A8THszEkHm7VxQSGJJWPQV0v3Hs,3839
@@ -467,8 +467,8 @@ mxcubecore/utils/conversion.py,sha256=G1bk2Mi2ZwGbZa5pEeiFaKWxhSVXVGqu1L9_SioyUO
467
467
  mxcubecore/utils/qt_import.py,sha256=0lPmqok_oYQZ059kJCq7RWdg490T8YKyRvoZGyWDy4M,14486
468
468
  mxcubecore/utils/tango.py,sha256=vwEVrIrWKEFaeaJUz3xbaC7XWHY8ZeJ-pfcSrTfZPIE,2114
469
469
  mxcubecore/utils/units.py,sha256=Gh7ovTUN00XBMUoyDG5W7akCx1pROL-M6pK2z1ouemg,1361
470
- mxcubecore-1.385.0.dist-info/COPYING,sha256=u-Mc8zCecwyo4YoP8UulmzCiZZ_MmCLROd_NBtOcRj0,35148
471
- mxcubecore-1.385.0.dist-info/COPYING.LESSER,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
472
- mxcubecore-1.385.0.dist-info/METADATA,sha256=d6DL9ewkJo3Af0JVnsNJYSP8M-IgUZCAlne5d-1Pjsw,4259
473
- mxcubecore-1.385.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
474
- mxcubecore-1.385.0.dist-info/RECORD,,
470
+ mxcubecore-1.386.0.dist-info/COPYING,sha256=u-Mc8zCecwyo4YoP8UulmzCiZZ_MmCLROd_NBtOcRj0,35148
471
+ mxcubecore-1.386.0.dist-info/COPYING.LESSER,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
472
+ mxcubecore-1.386.0.dist-info/METADATA,sha256=oh50leeNzHaCAdv4fg8O96k0ewFL-ijez3eQW0QsbLw,4259
473
+ mxcubecore-1.386.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
474
+ mxcubecore-1.386.0.dist-info/RECORD,,