PSCF v1.1
Public Member Functions | List of all members
pscfpp.command.Script Class Reference

Class to parse a PSCF command script. More...

Public Member Functions

def __init__ (self, filename=None)
 Constructor. More...
 
def read (self, filename)
 Read and parse a command script. More...
 
def __str__ (self)
 Return a string containing the command script. More...
 
def __getitem__ (self, key)
 Get a Command by integer index or command name. More...
 
def __len__ (self)
 Get the number of commands in the script. More...
 

Detailed Description

Class to parse a PSCF command script.

The Script class can read a command script file and store its contents in a form that allows particular commands to be accessed and modified.

**Construction and Parsing:**a

The constructor can take the name of a command file or an open file object as a parameter, and will read, parse and store the contents of the specified file.

Example: To parse a command file named 'command', one could enter

s = Script('command')

Accessing individual commands:

A Script object is a container for a list of child Command objects. Each command corresponds to one line in the command script, in which the first field is the label. Individual Command objects within a Script object can be accessed in either of two ways:

String representation of individual Commands objects can be printed using the str() or print functions. Values of arguments of individual Command objects may then be accessed or modified using the param and setParam methods of class Command (see below).

Definition at line 44 of file command.py.

Constructor & Destructor Documentation

◆ __init__()

def pscfpp.command.Script.__init__ (   self,
  filename = None 
)

Member Function Documentation

◆ read()

def pscfpp.command.Script.read (   self,
  filename 
)

Read and parse a command script.

Parameters
filenamefile name string or open file for command file

Definition at line 69 of file command.py.

References pscfpp.command.Script._commands, and pscfpp.command.Script._indices.

Referenced by pscfpp.param.Composite.__init__(), pscfpp.field.Field.__init__(), pscfpp.command.Script.__init__(), pscfpp.output.Thermo.__init__(), pscfpp.param.Matrix.__init__(), and pscfpp.param.Array.__init__().

◆ __str__()

def pscfpp.command.Script.__str__ (   self)

Return a string containing the command script.

Definition at line 113 of file command.py.

References pscfpp.command.Script._commands.

Referenced by pscfpp.field.Field.write(), pscfpp.output.Thermo.write(), and pscfpp.output.State.write().

◆ __getitem__()

def pscfpp.command.Script.__getitem__ (   self,
  key 
)

Get a Command by integer index or command name.

Parameters
keyinteger index or command name string

Definition at line 124 of file command.py.

References pscfpp.command.Script._commands, and pscfpp.command.Script._indices.

◆ __len__()

def pscfpp.command.Script.__len__ (   self)

Get the number of commands in the script.

Definition at line 143 of file command.py.

References pscfpp.command.Script._commands.


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