pestifer.logparsers.logparser module¶
Defines the LogParser class and its subclasses for parsing log files from various applications used by Pestifer, such as NAMD and Packmol.
- class pestifer.logparsers.logparser.LogParser[source]¶
Bases:
ByteCollectorA base class for parsing log files from various applications used by Pestifer. This class is a subclass of
ByteCollectorand provides methods for reading, updating, and dumping log data.- dump(basename: str = 'logparser')[source]¶
Dump the collected log data to a file with the specified basename. The file will be named <basename>.log and will contain the collected log data.
- Parameters:
basename (str) – The base name for the log file. The final file will be named <basename>.log.
- enable_progress_bar(PS: PestiferProgress = None)[source]¶
Enable a progress bar for the log parser. If a progress bar instance is provided, it will be used to track the progress of the log parsing.
- Parameters:
PS (PestiferProgress) – An instance of a progress bar to track the progress of the log parsing.
- follow(filename: str, sleep_interval: float = 0.5, timeout_intervals: int = 120)[source]¶
Follow a log file, reading new lines as they are added.
- measure_progress()[source]¶
Measure the progress of the log parsing. This method is intended to be overridden by subclasses to provide specific progress measurement logic.
- class pestifer.logparsers.logparser.VMDLogParser(basename: str = 'vmd-logparser')[source]¶
Bases:
LogParserA class for parsing VMD log files. This class is a subclass of
LogParserand provides methods for reading, updating, and dumping VMD log data. It also includes methods for processing specific lines in the log file, such as those containing information about the simulation, TCL commands, and energy calculations.- Parameters:
basename (str) – The base name for the log parser.
- classmethod from_file(filename: str | Path) VMDLogParser[source]¶
Create a VMDLogParser instance from a log file.
- pestifer.logparsers.logparser.get_single(flag: str, bytes: str)[source]¶
Get the first token that follows the first occurrence of flag in the bytes. If the flag is not found or there are no tokens, return None and log a debug message.
- pestifer.logparsers.logparser.get_toeol(flag: str, bytes: str)[source]¶
Get the substring of bytes from the first occurrence of flag to the end of the line. If the flag is not found or there is no newline character after the flag, return None and log a debug message.
- pestifer.logparsers.logparser.get_toflag(flag: str, bytes: str)[source]¶
Get the substring of bytes up to the first occurrence of flag. If the flag is not found, return None and log a debug message.
- pestifer.logparsers.logparser.get_tokens(flag: str, bytes: str)[source]¶
Get the tokens from the bytes that follow the first occurrence of flag. If the flag is not found or there are no tokens, return an empty list and log a debug message.