This class allows reading a text file token by token (where tokens are separated by whitespace), while still allowing to skip complete lines where needed. More...
Public Member Functions | |
| __init__ (self, file) | |
| The constructor accepts an open file object. | |
| next (self) | |
| This function returns the next token in the file, skipping white space (including line endings) as needed. | |
| skipHeaderLines (self) | |
| This function skips any lines that start with a '#' character. | |
| skipLine (self) | |
| This function skips tokens as follows. | |
| skipToEndOfLine (self) | |
| This function skips any remaining tokens on the current line (without advancing to the next line). | |
Public Attributes | |
| file | |
| list | line |
This class allows reading a text file token by token (where tokens are separated by whitespace), while still allowing to skip complete lines where needed.
| pts.storedtable.tokenizedfile.TokenizedFile.__init__ | ( | self, | |
| file ) |
The constructor accepts an open file object.
The file must be opened in text mode.
| pts.storedtable.tokenizedfile.TokenizedFile.next | ( | self | ) |
This function returns the next token in the file, skipping white space (including line endings) as needed.
| pts.storedtable.tokenizedfile.TokenizedFile.skipHeaderLines | ( | self | ) |
This function skips any lines that start with a '#' character.
If the current line has remaining tokens, it is skipped only if the first remaining token starts with a '#'.
| pts.storedtable.tokenizedfile.TokenizedFile.skipLine | ( | self | ) |
This function skips tokens as follows.
If the current line has one or more remaining tokens, these tokens are skipped. Otherwise, all tokens on the next line are skipped.
| pts.storedtable.tokenizedfile.TokenizedFile.skipToEndOfLine | ( | self | ) |
This function skips any remaining tokens on the current line (without advancing to the next line).