fparser Reference Guide  0.0.14
fparser.common.readfortran.Line Class Reference
Inheritance diagram for fparser.common.readfortran.Line:

Public Member Functions

def __init__ (self, line, linenospan, label, name, reader)
 
def has_map (self)
 
def apply_map (self, line)
 
def copy (self, line=None, apply_map=False)
 
def clone (self, line)
 
def __repr__ (self)
 
def __str__ (self)
 
def isempty (self, ignore_comments=False)
 
def get_line (self, apply_map=False)
 
def parse_line (self, cls, parent_cls)
 
def parse_block (self, reader, cls, parent_cls)
 

Public Attributes

 line
 
 span
 
 label
 
 name
 
 reader
 
 strline
 
 is_f2py_directive
 
 parse_cache
 
 strlinemap
 

Detailed Description

Holds a Fortran source line.

Attributes

line : str
  code line
span : 2-tuple
  starting and ending line numbers
label : {int, None}
  Specify statement label
name : {str, None}
  Specify construct name.
reader : FortranReaderBase
strline : {None, str}
is_f2py_directive : bool
  the line contains f2py directive

Definition at line 271 of file readfortran.py.

Member Function Documentation

◆ apply_map()

def fparser.common.readfortran.Line.apply_map (   self,
  line 
)
Substitutes magic strings in a line with values specified in a map.

Definition at line 314 of file readfortran.py.

References fparser.common.readfortran.Line.strlinemap.

314  def apply_map(self, line):
315  """
316  Substitutes magic strings in a line with values specified in a map.
317  """
318  if not hasattr(self, "strlinemap") or not self.strlinemap:
319  return line
320  return self.strlinemap(line)
321 
Here is the caller graph for this function:

◆ clone()

def fparser.common.readfortran.Line.clone (   self,
  line 
)
This Line has its contents overwitten by the passed string. The
incoming string has substitution applied.

Definition at line 336 of file readfortran.py.

References fparser.one.statements.GeneralAssignment.__class__, fparser.one.statements.Read.__class__, fparser.common.readfortran.Line.apply_map(), fparser.common.readfortran.Line.get_line(), fparser.common.readfortran.Line.label, fparser.common.readfortran.Line.line, fparser.common.base_classes.Variable.name, fparser.common.readfortran.Line.name, fparser.common.base_classes.BeginStatement.name, fparser.common.base_classes.EndStatement.name, fparser.common.readfortran.Line.parse_cache, fparser.common.readfortran.Line.reader, fparser.common.base_classes.Statement.reader, fparser.common.readfortran.Line.span, fparser.common.readfortran.Line.strline, and fparser.common.readfortran.Line.strlinemap.

336  def clone(self, line):
337  """
338  This Line has its contents overwitten by the passed string. The
339  incoming string has substitution applied.
340  """
341  self.line = self.apply_map(line)
342  self.strline = None
343 
Here is the call graph for this function:

◆ copy()

def fparser.common.readfortran.Line.copy (   self,
  line = None,
  apply_map = False 
)
Creates a Line object from a string.

If no line argument is specified a copy is made of this Line.

If a substitution map is provided it is used while making the copy.

Definition at line 322 of file readfortran.py.

References fparser.common.readfortran.Line.apply_map(), fparser.common.readfortran.Line.label, fparser.common.readfortran.Line.line, fparser.common.base_classes.Variable.name, fparser.common.readfortran.Line.name, fparser.common.base_classes.BeginStatement.name, fparser.common.base_classes.EndStatement.name, fparser.common.readfortran.Line.reader, fparser.common.base_classes.Statement.reader, and fparser.common.readfortran.Line.span.

322  def copy(self, line=None, apply_map=False):
323  """
324  Creates a Line object from a string.
325 
326  If no line argument is specified a copy is made of this Line.
327 
328  If a substitution map is provided it is used while making the copy.
329  """
330  if line is None:
331  line = self.line
332  if apply_map:
333  line = self.apply_map(line)
334  return Line(line, self.span, self.label, self.name, self.reader)
335 
Here is the call graph for this function:

◆ has_map()

def fparser.common.readfortran.Line.has_map (   self)
Returns true when a substitution map has been registered.

Definition at line 308 of file readfortran.py.

References fparser.common.readfortran.Line.strlinemap.

308  def has_map(self):
309  """
310  Returns true when a substitution map has been registered.
311  """
312  return hasattr(self, "strlinemap") and self.strlinemap
313 

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