pyesorex.action

Custom argparse Action classes for use by the PyEsoRex command line interface.

class pyesorex.action.ConfigAction(option_strings, pyesorex, dest='config', **kwargs)

argparse Action used when loading a Pyesorex config file using the command line option.

This is implemented as an Action so that the config file parameter is set and the config file is read before parsing the remaining arguments. This is necessary so that if special options such as –create-config or –recipes stop the processing of command line options before it is complete the correct config will still be used.

This is used internally by the pyesorex.pyesore.Pyesorex class and pyesorex.pyesorex.__main__.pyesorex_cli(). It should not be necessary to instantiate this directly, it is instead passed to an argparse.ArgumentParser instance.

Parameters:
  • option_strings (list of str) – A list of command-line option strings which should be associated with this action.

  • pyesorex (pyesorex.pyesorex.Pyesorex) – Pyesorex instance that will use the config.

class pyesorex.action.CreateConfigAction(option_strings, pyesorex, dest='create_config', **kwargs)

argparse Action used when creating a PyEsoRex/recipe config file at the command line.

This is implemented as an Action in order to interrupt parsing of command line arguments after creating the config file. This is necessary because otherwise there would be error due to missing positonal arguments (sof_location, recipe).

This is used internally by the pyesorex.pyesore.Pyesorex class and pyesorex.pyesorex.__main__.pyesorex_cli(). It should not be necessary to instantiate this directly, it is instead passed to an argparse.ArgumentParser instance.

Parameters:
  • option_strings (list of str) – A list of command-line option strings which should be associated with this action.

  • pyesorex (pyesorex.pyesorex.Pyesorex) – Pyesorex instance to be used to create config files.

class pyesorex.action.HelpAction(option_strings, pyesorex, dest='help', **kwargs)

argparse Action used for displaying the help page, for both pyesorex itself and for recipes

This is implemented as an Action in order to interrupt parsing of command line arguments after listing the recipes. This is necessary because otherwise there would be error due to missing positonal arguments (sof_location, recipe).

This is used internally by the pyesorex.pyesore.Pyesorex class and pyesorex.pyesorex.__main__.pyesorex_cli(). It should not be necessary to instatiate this directly, it is instead passed to an argparse.ArgumentParser instance.

Parameters:
  • option_strings (list of str) – A list of command-line option strings which should be associated with this action.

  • pyesorex (pyesorex.pyesorex.Pyesorex) – Pyesorex instance to be used to find recipes.

class pyesorex.action.ManPageAction(option_strings, pyesorex, dest='help', **kwargs)

argparse Action used for displaying the manual page for a given recipe

This is implemented as an Action in order to interrupt parsing of command line arguments after listing the recipes. This is necessary because otherwise there would be error due to missing positonal arguments (sof_location, recipe).

This is used internally by the pyesorex.pyesore.Pyesorex class and pyesorex.pyesorex.__main__.pyesorex_cli(). It should not be necessary to instatiate this directly, it is instead passed to an argparse.ArgumentParser instance.

Parameters:
  • option_strings (list of str) – A list of command-line option strings which should be associated with this action.

  • pyesorex (pyesorex.pyesorex.Pyesorex) – Pyesorex instance to be used to find recipes.

class pyesorex.action.ParameterAction(option_strings, pyesorex, dest, nargs='?', const=True, metavar=None, **kwargs)

argparse Action used for pyesorex options that correspond to parameter settings.

These require a custom Action in order to directly set the corresponding pyesorex parameter value while the command line arguments are being parsed. This is necessary so that if special options such as –create-config or –recipes stop the processing of command line options before it is complete the parameter settings will still take effect.

This is used internally by the pyesorex.pyesore.Pyesorex class and pyesorex.pyesorex.__main__.pyesorex_cli(). It should not be necessary to instantiate this directly, it is instead passed to an argparse.ArgumentParser instance.

Parameters:
  • option_strings (list of str) – A list of command-line option strings which should be associated with this action.

  • pyesorex (pyesorex.pyesorex.Pyesorex) – Pyesorex instance that will have its parameter value set.

  • dest (str) – The name of the attribute to be added to the object returned by parse_args() and, more importantly, the name of corresponding parameter in the Pyesorex object.

  • nargs (str or int, default="?") – The number of command line arguments that should be consumed, default “?” (1 or 0)

  • const (str or int or bool or float or complex, default=True) – The value used if nargs is “?” (the default) and the option string is present on the command line but is not followed by a value. The type of this argument must match the data type of the parameter or be convertable to it by the data type’s constructor, e.g. a string literal for a value of the correct type.

  • metavar (str, optional) – A name for the argument in usage messages.

Raises:

KeyError: – If the Pyesorex object does not have a parameter with a name matching dest.

class pyesorex.action.ParamsAction(option_strings, pyesorex, dest='params', **kwargs)

argparse Action used when listing current parameter values.

This is implemented as an Action in order to interrupt parsing of command line arguments after listing the parameter values. This is necessary because otherwise there would be error due to missing positonal arguments (sof_location, recipe).

This is used internally by the pyesorex.pyesore.Pyesorex class and pyesorex.pyesorex.__main__.pyesorex_cli(). It should not be necessary to instatiate this directly, it is instead passed to an argparse.ArgumentParser instance.

Parameters:
  • option_strings (list of str) – A list of command-line option strings which should be associated with this action.

  • pyesorex (pyesorex.pyesorex.Pyesorex) – Pyesorex instance to be used to find recipes.

class pyesorex.action.RecipesAction(option_strings, pyesorex, dest='recipes', **kwargs)

argparse Action used when listing available recipes on the command line.

This is implemented as an Action in order to interrupt parsing of command line arguments after listing the recipes. This is necessary because otherwise there would be error due to missing positonal arguments (sof_location, recipe).

This is used internally by the pyesorex.pyesore.Pyesorex class and pyesorex.pyesorex.__main__.pyesorex_cli(). It should not be necessary to instatiate this directly, it is instead passed to an argparse.ArgumentParser instance.

Parameters:
  • option_strings (list of str) – A list of command-line option strings which should be associated with this action.

  • pyesorex (pyesorex.pyesorex.Pyesorex) – Pyesorex instance to be used to find recipes.