fparser.common.sourceinfo

Provides functions to determine whether a piece of Fortran source is free or fixed format. It also tries to differentiate between strict and “pyf” although I’m not sure what that is.

Module Contents

Classes

FortranFormat

Describes the nature of a piece of Fortran source.

Functions

get_source_info_str(source[, ignore_encoding])

Determines the format of Fortran source held in a string.

get_source_info(file_candidate[, ignore_encoding])

Determines the format of Fortran source held in a file.

Attributes

_HAS_F_EXTENSION

_HAS_F_HEADER

_HAS_F90_HEADER

_HAS_F03_HEADER

_HAS_F08_HEADER

_HAS_FREE_HEADER

_HAS_FIX_HEADER

_HAS_PYF_HEADER

_FREE_FORMAT_START

class fparser.common.sourceinfo.FortranFormat(is_free, is_strict, enable_f2py=False)[source]

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.

Parameters:
  • is_free (bool) – True for free format, False for fixed.

  • is_strict (bool) – some amount of strictness.

  • enable_f2py (bool) – whether f2py directives are enabled or treated as comments (the default).

property is_free[source]

Returns true for free format.

property is_fixed[source]

Returns true for fixed format.

property is_strict[source]

Returns true for strict format.

property is_f77[source]

Returns true for strict fixed format.

property is_fix[source]

Returns true for slack fixed format.

property is_pyf[source]

Returns true for strict free format.

property f2py_enabled[source]
Returns:

whether or not f2py directives are enabled.

Return type:

bool

property mode[source]

Returns a string representing this format.

classmethod from_mode(mode)[source]

Constructs a FortranFormat object from a mode string.

Arguments:

mode - (String) One of ‘free’, ‘fix’, ‘f77’ or ‘pyf’

__eq__(other)[source]

Return self==value.

__str__()[source]

Return str(self).

fparser.common.sourceinfo._HAS_F_EXTENSION[source]
fparser.common.sourceinfo._HAS_F_HEADER[source]
fparser.common.sourceinfo._HAS_F90_HEADER[source]
fparser.common.sourceinfo._HAS_F03_HEADER[source]
fparser.common.sourceinfo._HAS_F08_HEADER[source]
fparser.common.sourceinfo._HAS_FREE_HEADER[source]
fparser.common.sourceinfo._HAS_FIX_HEADER[source]
fparser.common.sourceinfo._HAS_PYF_HEADER[source]
fparser.common.sourceinfo._FREE_FORMAT_START[source]
fparser.common.sourceinfo.get_source_info_str(source, ignore_encoding=True)[source]

Determines the format of Fortran source held in a string.

Parameters:

ignore_encoding (bool) – whether or not to ignore any Python-style encoding information in the first line of the file.

Returns:

a FortranFormat object.

Return type:

fparser.common.sourceinfo.FortranFormat

fparser.common.sourceinfo.get_source_info(file_candidate, ignore_encoding=True)[source]

Determines the format of Fortran source held in a file.

Parameters:

file_candidate (str or _io.TextIOWrapper (py3)) – a filename or a file object

Returns:

the Fortran format encoded as a string.

Return type:

str