CLParse
- class bapsflib._hdf.maps.controls.parsers.CLParse(command_list: str | Iterable[str])
Bases:
objectClass for parsing RE from a command list. (A command list is a list of strings where each string is a set of commands sent to a control device to define that control device’s state.)
Methods Summary
apply_patterns(patterns)Applies the regular expressions defined in
patternsto parse the command list.try_patterns(patterns)Prints to the results of applying the REs in patterns to the command list.
Methods Documentation
- apply_patterns(patterns: str | Iterable[str])
Applies the regular expressions defined in
patternsto parse the command list.- Parameters:
patterns (Union[str, Iterable[str]]) – list of raw strings defining regular expressions for parsing the command list
- Returns:
Examples
>>> # define a command list >>> cl = ["VOLT 20.0", "VOLT 25.0", "VOLT 30.0"] >>> >>> # define clparse object >>> clparse = CLParse(cl) >>> >>> # apply patterns >>> patterns = ( >>> r"(?P<FREQ>(\bFREQ\s)" >>> r"(?P<VAL>(\d+\.\d*|\.\d+|\d+\b)))" >>> ) >>> results = clparse.apply_patterns(patterns) >>> results[0] True >>> results[1] {'VOLT': {'cl str': ('VOLT 20.0', 'VOLT 25.0', 'VOLT 30.0'), 'command list': (20.0, 25.0, 30.0), 're pattern': re.compile(pattern, re.UNICODE), 'dtype': numpy.float64}}