How to use the f90nml.cli.parse 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 / tests / test_f90nml.py View on Github external
def get_cli_output(self, args, get_stderr=False):
        argv_in, stdout_in, stderr_in = sys.argv, sys.stdout, sys.stderr

        sys.argv = args
        sys.stdout = StringIO()
        sys.stderr = StringIO()

        try:
            f90nml.cli.parse()
        except SystemExit:
            pass

        sys.stdout.seek(0)
        stdout = sys.stdout.read()
        sys.stdout.close()

        sys.stderr.seek(0)
        stderr = sys.stderr.read()
        sys.stderr.close()

        sys.argv, sys.stdout, sys.stderr = argv_in, stdout_in, stderr_in

        # TODO: Some way to check both would be more useful...
        if get_stderr:
            return stderr