This module contains the main PYFT class.
PYFT (Python FORTRAN Tool) is the primary class for reading, manipulating,
and writing FORTRAN source files. It provides file-level operations and
wraps the scope-level functionality from PYFTscope.
Examples
--------
>>> from pyfortool import PYFT
# Read and modify a file
>>> pft = PYFT('input.F90')
>>> pft.removePrints()
>>> pft.write()
# Use context manager
>>> with PYFT('input.F90') as pft:
... pft.removeComments()
... pft.write()
| pyfortool.pyfortool.conservativePYFT |
( |
|
filename, |
|
|
|
parserOptions, |
|
|
|
wrapH, |
|
|
|
tree = None, |
|
|
|
verbosity = None, |
|
|
|
clsPYFT = None |
|
) |
| |
Create a PYFT object with conservative parsing options.
Similar to PYFT constructor but forces the '-no-include' option
to prevent automatic inclusion of header files.
Parameters
----------
filename : str
Path to the FORTRAN source file.
parserOptions : list or None
Parser options passed to PYFT. If None, uses default options.
wrapH : bool
Whether to wrap .h file content. See PYFT class.
tree : Tree, optional
Tree instance for cross-file analysis.
verbosity : str or int, optional
Logging verbosity level.
clsPYFT : type, optional
PYFT subclass to use instead of default PYFT.
Returns
-------
PYFT
A PYFT instance configured for conservative tree manipulation.
See Also
--------
PYFT : The main PYFT class.
Definition at line 36 of file pyfortool.py.
| pyfortool.pyfortool.generateEmptyPYFT |
( |
|
filename, |
|
|
|
fortran = None, |
|
|
** |
kwargs |
|
) |
| |
Generate a new PYFT object from a file path, creating the file if needed.
Parameters
----------
filename : str
Path for the new file.
fortran : str, optional
FORTRAN source code to write to the file.
If None, creates a stub subroutine "SUBROUTINE FOO\nEND".
**kwargs
Additional arguments passed to PYFT constructor.
Returns
-------
PYFT
PYFT instance for the newly created file.
Examples
--------
>>> pft = generateEmptyPYFT('new.F90', 'MODULE TEST\nEND MODULE')
>>> pft.addVar([('module:TEST', 'X', 'INTEGER :: X', None)])
>>> pft.write()
Definition at line 80 of file pyfortool.py.