PSCF v1.1
Classes | Functions
pscfpp.text Namespace Reference

Utilities for manipulating and searching text strings. More...

Classes

class  FileEditor
 Class to substitute text in one or more files. More...
 
class  Grep
 Class to search for text in a file. More...
 
class  Record
 A Record represents a string of fields separated by whitespace. More...
 
class  RecordEditor
 Class to modify selected Records in a file of records. More...
 
class  Wrapper
 Class to wrap line breaks. More...
 

Functions

def readLabelledLine (file, label)
 Read a line of the form "label = string", return string. More...
 
def readLabelledList (file, label)
 Read line of form "label = string", in which string may contains spaces. More...
 

Detailed Description

Utilities for manipulating and searching text strings.

Function Documentation

◆ readLabelledLine()

def pscfpp.text.readLabelledLine (   file,
  label 
)

Read a line of the form "label = string", return string.

This function reads a line of the form "label = <string>" containing a known label, an equal sign, and a string following the label. The must match a known label that is passed as a parameter. If the label does not match (failure), this function prints an error and returns. If the label does match (success), this function returns the remaining string verbatim, stripped of any preceding and trailing white space.

Parameters
fileopen for reading, with cursor at beginning of a line
labelexpected label (must match)
Returns
string after label

Definition at line 232 of file text.py.

Referenced by pscfpp.text.readLabelledList().

◆ readLabelledList()

def pscfpp.text.readLabelledList (   file,
  label 
)

Read line of form "label = string", in which string may contains spaces.

This function reads a line of the form "label = <string>" containing a known label, an equal sign, and a string following the label, in which the string may contain sub-strings spaces. The label must match a known label that is passed as a function parameter. If the label function does not match, this function prints an error and exits. If the label matches (success), this function returns a list of sub-strings separated by spaces. For example, if the string after the equal sign is 'a b c', the function returns a list ['a', 'b', 'c'].

Parameters
fileopen for reading, with cursor at beginning of a line
labelexpected label (must match)
Returns
list of space-delimited sub-strings that follow label

Definition at line 263 of file text.py.

References pscfpp.text.readLabelledLine().

Referenced by pscfpp.make.MakeMaker.__init__().