pyccel.commands.argparse_helpers module#

File containing functions that help build argparse.ArgumentParser objects.

File containing functions that help build argparse.ArgumentParser objects. Several of these functions are common to multiple sub-commands so the logic can be shared.

class pyccel.commands.argparse_helpers.ErrorModeSelector(**kwargs)[source]View on GitHub#

Bases: Action

Class describing an action which sets the error mode.

Class describing an action which sets the error mode to the value saved in the const argument.

Parameters:

**kwargs (dict) – See argparse.Action.

pyccel.commands.argparse_helpers.add_accelerator_selection(parser)[source]View on GitHub#

Add group of accelerator flags to argument parser.

Add argument group to parser, with flags for selecting any accelerators to be used in compilation.

Parameters:

parser (argparse.ArgumentParser) – The parser to be modified.

pyccel.commands.argparse_helpers.add_common_settings(parser)[source]View on GitHub#

Add common settings controlling how Pyccel reports progress.

Add settings controlling how Pyccel reports progress: - help - verbosity - developer-mode - conda warnings level - time execution

Parameters:

parser (argparse.ArgumentParser) – The parser to be modified.

pyccel.commands.argparse_helpers.add_compiler_selection(parser, allow_compiler_config)[source]View on GitHub#

Add group of compiler selection flags to argument parser.

Add argument group to parser, with flags for selecting a compiler. This can be done by family or with a json config file.

Parameters:
  • parser (argparse.ArgumentParser) – The parser to be modified.

  • allow_compiler_config (bool) – Indicates if a compiler config file is a valid input.

Returns:

The newly created argument group.

Return type:

argparse._MutuallyExclusiveGroup

pyccel.commands.argparse_helpers.add_help_flag(parser)[source]View on GitHub#

Add -h/–help flag to argument parser.

Add -h/–help flag to argument parser.

Parameters:

parser (argparse.ArgumentParser) – The parser to be modified.

pyccel.commands.argparse_helpers.add_version_flag(parser)[source]View on GitHub#

Add version flag to argument parser.

Add version flag to argument parser.

Parameters:

parser (argparse.ArgumentParser) – The parser to be modified.

pyccel.commands.argparse_helpers.path_with_suffix(suffixes, must_exist=True)[source]View on GitHub#

Get the function which returns a Path to a file with one of the suffixes.

Get the function which returns a Path to a file with one of the specified suffixes. The function returns a argparse.ArgumentTypeError if the input does not respect the expected file format.

Parameters:
  • suffixes (iterable[str]) – An iterable describing the valid suffixes.

  • must_exist (bool, default=True) – A flag to indicate whether the path passed as argument must exist.

Returns:

A function which checks if the argument is of the expected type.

Return type:

function