fparser Reference Guide  0.0.14
fparser.common.sourceinfo.FortranFormat Class Reference

Public Member Functions

def __init__ (self, is_free, is_strict, enable_f2py=False)
 
def from_mode (cls, mode)
 
def __eq__ (self, other)
 
def __str__ (self)
 
def is_free (self)
 
def is_fixed (self)
 
def is_strict (self)
 
def is_f77 (self)
 
def is_fix (self)
 
def is_pyf (self)
 
def f2py_enabled (self)
 
def mode (self)
 

Public Attributes

 is_free
 
 is_strict
 
 f2py_enabled
 

Detailed Description

Describes the nature of a piece of Fortran source.

Source can be fixed or free format. It can also be "strict" or
"not strict" although it's not entirely clear what that means. It may
refer to the strictness of adherance to fixed format although what that
means in the context of free format I don't know.

:param bool is_free: True for free format, False for fixed.
:param bool is_strict: some amount of strictness.
:param bool enable_f2py: whether f2py directives are enabled or treated \
                         as comments (the default).

Definition at line 79 of file sourceinfo.py.

Member Function Documentation

◆ f2py_enabled()

def fparser.common.sourceinfo.FortranFormat.f2py_enabled (   self)
:returns: whether or not f2py directives are enabled.
:rtype: bool

Definition at line 189 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat._f2py_enabled.

189  def f2py_enabled(self):
190  """
191  :returns: whether or not f2py directives are enabled.
192  :rtype: bool
193  """
194  return self._f2py_enabled
195 

◆ from_mode()

def fparser.common.sourceinfo.FortranFormat.from_mode (   cls,
  mode 
)
Constructs a FortranFormat object from a mode string.

Arguments:
    mode - (String) One of 'free', 'fix', 'f77' or 'pyf'

Definition at line 105 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat.f2py_enabled, fparser.common.sourceinfo.FortranFormat.is_free, and fparser.common.sourceinfo.FortranFormat.is_strict.

105  def from_mode(cls, mode):
106  """
107  Constructs a FortranFormat object from a mode string.
108 
109  Arguments:
110  mode - (String) One of 'free', 'fix', 'f77' or 'pyf'
111  """
112  if mode == "free":
113  is_free, is_strict = True, False
114  elif mode == "fix":
115  is_free, is_strict = False, False
116  elif mode == "f77":
117  is_free, is_strict = False, True
118  elif mode == "pyf":
119  is_free, is_strict = True, True
120  else:
121  raise NotImplementedError(repr(mode))
122  return cls(is_free, is_strict)
123 

◆ is_f77()

def fparser.common.sourceinfo.FortranFormat.is_f77 (   self)
Returns true for strict fixed format.

Definition at line 168 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat._is_free, and fparser.common.sourceinfo.FortranFormat._is_strict.

168  def is_f77(self):
169  """
170  Returns true for strict fixed format.
171  """
172  return not self._is_free and self._is_strict
173 
Here is the caller graph for this function:

◆ is_fix()

def fparser.common.sourceinfo.FortranFormat.is_fix (   self)
Returns true for slack fixed format.

Definition at line 175 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat._is_free, and fparser.common.sourceinfo.FortranFormat._is_strict.

175  def is_fix(self):
176  """
177  Returns true for slack fixed format.
178  """
179  return not self._is_free and not self._is_strict
180 
Here is the caller graph for this function:

◆ is_fixed()

def fparser.common.sourceinfo.FortranFormat.is_fixed (   self)
Returns true for fixed format.

Definition at line 154 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat._is_free.

154  def is_fixed(self):
155  """
156  Returns true for fixed format.
157  """
158  return not self._is_free
159 

◆ is_free()

def fparser.common.sourceinfo.FortranFormat.is_free (   self)
Returns true for free format.

Definition at line 147 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat._is_free.

147  def is_free(self):
148  """
149  Returns true for free format.
150  """
151  return self._is_free
152 

◆ is_pyf()

def fparser.common.sourceinfo.FortranFormat.is_pyf (   self)
Returns true for strict free format.

Definition at line 182 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat._is_free, and fparser.common.sourceinfo.FortranFormat._is_strict.

182  def is_pyf(self):
183  """
184  Returns true for strict free format.
185  """
186  return self._is_free and self._is_strict
187 

◆ is_strict()

def fparser.common.sourceinfo.FortranFormat.is_strict (   self)
Returns true for strict format.

Definition at line 161 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat._is_strict.

161  def is_strict(self):
162  """
163  Returns true for strict format.
164  """
165  return self._is_strict
166 

◆ mode()

def fparser.common.sourceinfo.FortranFormat.mode (   self)
Returns a string representing this format.

Definition at line 197 of file sourceinfo.py.

References fparser.common.sourceinfo.FortranFormat._is_free, fparser.common.sourceinfo.FortranFormat._is_strict, fparser.common.sourceinfo.FortranFormat.is_f77(), and fparser.common.sourceinfo.FortranFormat.is_fix().

197  def mode(self):
198  """
199  Returns a string representing this format.
200  """
201  if self._is_free and self._is_strict:
202  mode = "pyf"
203  elif self._is_free:
204  mode = "free"
205  elif self.is_fix:
206  mode = "fix"
207  elif self.is_f77:
208  mode = "f77"
209  # While mode is determined by is_free and is_strict all permutations
210  # are covered. There is no need for a final "else" clause as the
211  # object cannot get wedged in an invalid mode.
212  return mode
213 
214 
Here is the call graph for this function:

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