The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Public Attributes | List of all members
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

def __init__ (self, file)
 The constructor accepts an open file object. More...
 
def next (self)
 This function returns the next token in the file, skipping white space (including line endings) as needed. More...
 
def skipHeaderLines (self)
 This function skips any lines that start with a '#' character. More...
 
def skipLine (self)
 This function skips tokens as follows. More...
 
def skipToEndOfLine (self)
 This function skips any remaining tokens on the current line (without advancing to the next line). More...
 

Public Attributes

 file
 
 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__()

def 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()

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

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

◆ skipHeaderLines()

def 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()

def 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()

def 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: