iplutil¶
Scanco IPL.
This module implements utilities for running IPL scripts.
- class iplutil.IPLParameterParser(prefixes: List[Optional[str]] = ['!>', '!%', None], separators: List[Optional[str]] = ['=', ':'])¶
Parses output parameters from IPL stdout.
- get_regex_pattern_full_line() str ¶
Get a regex pattern that matches a full line based on the configured parts.
- get_regex_pattern_one_of(options: List[Optional[str]]) str ¶
Get a regex pattern that matches one of the given options.
- parse(ipl_output: str) Iterator[iplutil.ParsedIPLParameter] ¶
Parse all parameters in the output matching the configured pattern.
- class iplutil.IplStdoutChecker(*, error_re: typing.Pattern[str] = re.compile("(\\berror\\b)|(\\bunsupported\\b)|(Couldn't\\ allocate)", re.IGNORECASE|re.VERBOSE), ignore_re: typing.Pattern[str] = re.compile('\n # When external data is converted (back) to AIM format\n # sometimes these external converters set Index Patient 0 / Index Measurement 0.\n # IPL prints this error, but use, re.VERBOSE))¶
Checks IPL stdout for errors.
- class iplutil.ParsedIPLParameter(full_line: str, prefix: str, name: str, separator: str, value: str, unit: str)¶
Parsed IPL output parameter
- get_float() float ¶
Get a float value.
- iplutil.checked_aim_image(image_path: pathlib.Path) str ¶
Raise if the image is not an AIM file. Returns a quoted path for IPL.
- iplutil.convert_ipl_syntax(ipl_script_content: str, *, from_major_version: Optional[int] = None, to_major_version: Optional[int] = None) str ¶
Convert IPL script content. E.g. from V6-style “symbol qualifiers to #symbol.
- iplutil.detect_major_ipl_version() Optional[int] ¶
Detect the major version of the installed IPL.
- iplutil.get_ipl_exe_path() pathlib.Path ¶
Get path of IPL executable using environment variable SCANCO_IPL_EVAL_EXE set in installer.
- iplutil.ipl_args(*args, **kwargs)¶
Create a IPL environment variable dict including DCL-like positional parameters P1 etc. and named parameters.
- iplutil.parse_ipl_parameter(ipl_output: str, name: str, parser: iplutil.IPLParameterParser = <iplutil.IPLParameterParser object>) iplutil.ParsedIPLParameter ¶
Parse a parameter from the IPL output. Raises an exception if the parameter is missing or can not be converted to a float.
- iplutil.parse_ipl_whitespace_parameter(ipl_output: str, name: str) iplutil.ParsedIPLParameter ¶
Parse IPL parameter where the parameter name contains whitespace
- iplutil.quoted_path(p: pathlib.Path) str ¶
Get quoted path for IPL.
- iplutil.run_ipl(ipl_script: str, parameters: Dict[str, str], **kwargs) subprocess.CompletedProcess ¶
Run IPL as a subprocess. Read the IPL script content from a file.
- iplutil.run_ipl_content(ipl_script_content: str, parameters: typing.Dict[str, str], check_ipl_stdout: bool = True, ipl_stdout_checker: iplutil.IplStdoutChecker = <iplutil.IplStdoutChecker object>, auto_convert_ipl_syntax: bool = True, **kwargs) subprocess.CompletedProcess ¶
Run IPL as a subprocess. Assume IPL uses codepage Windows-1252 as encoding for stdin / stdout / stderr.