serpentTools.engines.KeywordParser¶
-
class
serpentTools.engines.
KeywordParser
(filePath, keys, separators=None, eof='')¶ Class for parsing a file for chunks separated by various keywords.
- Parameters
filePath (str) – Object to be read. Any object with
read
andclose
methodskeys (Iterable) – List of keywords/phrases that will indicate the start of a chunk
separators (Iterable or None) – List of additional phrases that can separate two chunks. If not given, will default to empty line
'\n'
.eof (str) – String to indicate the end of the file
-
parse
()¶ Parse the file and return a list of keyword blocks.
- Returns
List of key word argument chunks.
- Return type
-
seekToTop
()¶ Reset the file pointer to the start of the file.
-
yieldChunks
()¶ Return each chunk of text as a generator.
- Yields
list – The next chunk in the file.