mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 04:29:22 +01:00
generalized make_ for python
This commit is contained in:
@@ -1107,6 +1107,7 @@ class Detector(CppDetectorApi):
|
||||
ut.set_using_dict(self.setDestinationUDPMAC2, mac)
|
||||
|
||||
@property
|
||||
@element
|
||||
def udp_srcmac(self):
|
||||
"""
|
||||
Mac address of the receiver (source) udp interface.
|
||||
@@ -1120,7 +1121,7 @@ class Detector(CppDetectorApi):
|
||||
d.udp_srcmac
|
||||
00:1b:31:01:8a:de
|
||||
"""
|
||||
return element_if_equal(self.getSourceUDPMAC())
|
||||
return self.getSourceUDPMAC()
|
||||
|
||||
@udp_srcmac.setter
|
||||
def udp_srcmac(self, mac):
|
||||
|
||||
@@ -117,17 +117,22 @@ def make_string_path(path):
|
||||
return _make_string_path(path)
|
||||
|
||||
def make_ip(arg):
|
||||
if isinstance(arg, dict):
|
||||
return {key:_slsdet.IpAddr(value) for key,value in arg.items()}
|
||||
else:
|
||||
return _slsdet.IpAddr(arg)
|
||||
return _make(arg, _slsdet.IpAddr)
|
||||
|
||||
def make_mac(arg):
|
||||
if isinstance(arg, dict):
|
||||
return {key:_slsdet.MacAddr(value) for key,value in arg.items()}
|
||||
else:
|
||||
return _slsdet.MacAddr(arg)
|
||||
return _make(arg, _slsdet.MacAddr)
|
||||
|
||||
def _make(arg, transform):
|
||||
"""Helper function for make_mac and make_ip special cases for
|
||||
dict, list and tuple. Otherwise just calls transform"""
|
||||
if isinstance(arg, dict):
|
||||
return {key:transform(value) for key,value in arg.items()}
|
||||
elif isinstance(arg, list):
|
||||
return [transform(a) for a in arg]
|
||||
elif isinstance(arg, tuple):
|
||||
return tuple(transform(a) for a in arg)
|
||||
else:
|
||||
return transform(arg)
|
||||
|
||||
def set_using_dict(func, args):
|
||||
if isinstance(args, dict) and all(isinstance(k, int) for k in args.keys()):
|
||||
|
||||
Reference in New Issue
Block a user