Merge pull request #1355 from slsdetectorgroup/fix/pattern
All checks were successful
Build on local RHEL9 / build (push) Successful in 1m27s
Build on local RHEL8 / build (push) Successful in 3m32s
Build on RHEL9 / build (push) Successful in 3m35s
Build on RHEL8 / build (push) Successful in 4m57s

Allow sls::Pattern in d.pattern in python
This commit is contained in:
2026-01-21 17:29:00 +01:00
committed by GitHub
2 changed files with 11 additions and 4 deletions

View File

@@ -37,6 +37,8 @@ Experimental support for building the detector client (including python bindings
``rx_dbitlist`` keeps the order of the passed bit list ``rx_dbitlist`` keeps the order of the passed bit list
Detector.pattern (python) accepts also a pattern object, not only a pattern file
2 On-board Detector Server Compatibility 2 On-board Detector Server Compatibility
========================================== ==========================================

View File

@@ -1,5 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-other # SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package # Copyright (C) 2021 Contributors to the SLS Detector Package
import pathlib
from ._slsdet import CppDetectorApi from ._slsdet import CppDetectorApi
from ._slsdet import slsDetectorDefs from ._slsdet import slsDetectorDefs
from ._slsdet import IpAddr, MacAddr from ._slsdet import IpAddr, MacAddr
@@ -3757,7 +3758,7 @@ class Detector(CppDetectorApi):
@property @property
def pattern(self): def pattern(self):
"""[Mythen3][Ctb][Xilinx Ctb] Loads ASCII pattern file directly to server (instead of executing line by line). """[Mythen3][Ctb][Xilinx Ctb] Load a pattern (from file or memory) to the server (instead of executing line by line).
:getter: Not Implemented :getter: Not Implemented
@@ -3768,9 +3769,13 @@ class Detector(CppDetectorApi):
raise NotImplementedError("Pattern is set only") raise NotImplementedError("Pattern is set only")
@pattern.setter @pattern.setter
def pattern(self, fname): def pattern(self, name_or_pattern):
fname = ut.make_string_path(fname) # If passed a file path, convert to string representation
ut.set_using_dict(self.setPattern, fname) # with the path expanded. Otherwise it's probably a sls::Pattern
# and we can pass it directly.
if isinstance(name_or_pattern, (pathlib.Path, str)):
name_or_pattern = ut.make_string_path(name_or_pattern)
ut.set_using_dict(self.setPattern, name_or_pattern)
@property @property
def patfname(self): def patfname(self):