How to use the f90nml.parser.Parser function in f90nml

To help you get started, we’ve selected a few f90nml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marshallward / f90nml / f90nml / __init__.py View on Github external
def patch(nml_fname, nml_patch, out_fname=None):
    """Create a new namelist based on an input namelist and reference dict.

    >>> f90nml.patch('data.nml', nml_patch, 'patched_data.nml')"""
    return Parser().read(nml_fname, nml_patch, out_fname)
github marshallward / f90nml / f90nml / __init__.py View on Github external
def patch(nml_path, nml_patch, out_path=None):
    """Create a new namelist based on an input namelist and reference dict.

    >>> f90nml.patch('data.nml', nml_patch, 'patched_data.nml')

    This function is equivalent to the ``read`` function of the ``Parser``
    object with the patch output arguments.

    >>> parser = f90nml.Parser()
    >>> nml = parser.read('data.nml', nml_patch, 'patched_data.nml')

    A patched namelist file will retain any formatting or comments from the
    original namelist file.  Any modified values will be formatted based on the
    settings of the ``Namelist`` object.
    """
    parser = Parser()

    return parser.read(nml_path, nml_patch, out_path)
github marshallward / f90nml / f90nml / __init__.py View on Github external
File object usage:

    >>> with open(nml_path) as nml_file:
    >>>     nml = f90nml.read(nml_file)

    File path usage:

    >>> nml = f90nml.read(nml_path)

    This function is equivalent to the ``read`` function of the ``Parser``
    object.

    >>> parser = f90nml.Parser()
    >>> nml = parser.read(nml_file)
    """
    parser = Parser()
    return parser.read(nml_path)
github marshallward / f90nml / f90nml / __init__.py View on Github external
def reads(nml_string):
    """Parse a Fortran namelist string and return its contents.

    >>> nml_str = '&data_nml x=1 y=2 /'
    >>> nml = f90nml.reads(nml_str)

    This function is equivalent to the ``reads`` function of the ``Parser``
    object.

    >>> parser = f90nml.Parser()
    >>> nml = parser.reads(nml_str)
    """
    parser = Parser()
    return parser.reads(nml_string)
github marshallward / f90nml / f90nml / __init__.py View on Github external
def read(nml_fname):
    """Parse a Fortran 90 namelist file (data.nml) and store its contents.

    >>> nml = f90nml.read('data.nml')"""
    return Parser().read(nml_fname)