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]#
Bases:
ActionClass 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]#
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]#
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)[source]#
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.
- pyccel.commands.argparse_helpers.add_help_flag(parser)[source]#
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]#
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.deprecation_warning(tool)[source]#
Create a deprecation warning message for an old pyccel-TOOL command.
Create a deprecation warning message for an old pyccel-TOOL command.
- Parameters:
tool (str) – The name of the tool for which pyccel-TOOL is a deprecated command.
- Returns:
The deprecation warning message.
- Return type:
str
- pyccel.commands.argparse_helpers.get_warning_and_line()[source]#
Get colored WARNING and LINE strings.
Get colored WARNING and LINE strings if termcolor is installed, otherwise return plain strings.
- Returns:
The WARNING and LINE strings.
- Return type:
tuple[str, str]
- pyccel.commands.argparse_helpers.path_with_suffix(suffixes, must_exist=True)[source]#
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