Parsers
PyLabware utility functions for reply parsing
- PyLabware.parsers.researcher(reply, *args)[source]
This is a wrapper function for reply parsing to provide consistent arguments order.
- Parameters:
reply – Reply to parse with regular expression.
- Returns:
Regular expression match object.
- Return type:
(re.Match)
- PyLabware.parsers.slicer(reply, *args)[source]
This is a wrapper function for reply parsing to provide consistent arguments order.
- Parameters:
reply (
str
) – Sequence object to slice.- Returns:
Slice of the original object.
- Return type:
(any)
- PyLabware.parsers.splitter(reply, separator, *slice_positions)[source]
- This is a combination of str.split() followed by slicing.
Allows to avoid using RegExes for simple cases.
- Parameters:
reply (str) – String to process
separator (str) – Sparator for str.split().
- PyLabware.parsers.stripper(reply, prefix=None, suffix=None)[source]
This is a helper function used to strip off reply prefix and terminator. Standard Python str.strip() doesn’t work reliably because it operates on character-by-character basis, while prefix/terminator is usually a group of characters.
- Parameters:
reply (
str
) – String to be stripped.prefix – Substring to remove from the beginning of the line.
suffix – Substring to remove from the end of the line.
- Returns:
Naked reply.
- Return type:
(str)