natcap.invest.cli

Single entry point for all InVEST applications.

class natcap.invest.cli.SelectModelAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)

Bases: Action

Given a possibly-ambiguous model string, identify the model to run.

This is a subclass of argparse.Action and is executed when the argparse interface detects that the user has attempted to select a model by name.

natcap.invest.cli.build_model_list_json(locale_code)

Build a json object of relevant information for the CLI.

The json object returned uses the human-readable model names for keys and the values are another dict containing the internal name of the model and the aliases recognized by the CLI.

Parameters:

locale_code (str) – Language code to pass to gettext. The model names will be returned in this language.

Returns:

A string representation of the JSON object.

natcap.invest.cli.build_model_list_table(locale_code)

Build a table of model names, aliases and other details.

This table is a table only in the sense that its contents are aligned into columns, but are not separated by a delimiter. This table is intended to be printed to stdout.

Parameters:

locale_code (str) – Language code to pass to gettext. The model names will be returned in this language.

Returns:

A string representation of the formatted table.

natcap.invest.cli.export_to_python(target_filepath, model_id, args_dict=None)

Generate a python script that executes a model.

Parameters:
  • target_filepath (str) – path to generate the python file

  • model_id (str) – ID of the model to generate the script for

  • args_dict (dict) – If provided, prefill these arg values in the script

Returns:

None

natcap.invest.cli.main(user_args=None)

CLI entry point for launching InVEST runs and other useful utilities.

This command-line interface supports two methods of launching InVEST models from the command-line:

  • through its GUI

  • in headless mode, without its GUI.

Running in headless mode allows us to bypass all GUI functionality, so models may be run in this way without having GUI packages installed.