serpentTools.engines.PatternReader

class serpentTools.engines.PatternReader(filePath)

Class that can read over a file looking for patterns.

Parameters

filePath (str) – path to the file that is to be read

line

Most recently read line

Type

str

match

Match from the most recently read line

Type

regular expression match or None

searchFor(pattern)

Return true if the pattern is found.

Parameters

pattern (str or compiled regular expression) –

Returns

bool

Return type

True if the pattern was found

seekToTop()

Reset the file pointer to the start of the file.

yieldMatches(pattern)

Generator that returns all match groups that match pattern.

Parameters

pattern (str or compiled regular expression) – Seek through the file and yield all match groups for lines that contain this patten.

Yields

sequential match groups