The SKIRT project
advanced radiative transfer for astrophysics
pts.storedtable.tokenizedfile.TokenizedFile Class Reference

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

pts.storedtable.tokenizedfile.TokenizedFile.__init__ ( self,
file )

The constructor accepts an open file object.

The file must be opened in text mode.

Member Function Documentation

◆ next()

pts.storedtable.tokenizedfile.TokenizedFile.next ( self)

This function returns the next token in the file, skipping white space (including line endings) as needed.

◆ skipHeaderLines()

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 '#'.

◆ skipLine()

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.

◆ skipToEndOfLine()

pts.storedtable.tokenizedfile.TokenizedFile.skipToEndOfLine ( self)

This function skips any remaining tokens on the current line (without advancing to the next line).


The documentation for this class was generated from the following file: