fab.tools.flags#

This file contains a simple Flag class to manage tool flags. It will need to be combined with build_config.FlagsConfig in a follow up PR.

Classes

Flags([list_of_flags])

This class represents a list of parameters for a tool.

ProfileFlags()

A list of flags that support a 'profile' to be used.

class fab.tools.flags.Flags(list_of_flags=None)#

This class represents a list of parameters for a tool. It is a list with some additional functionality.

TODO #22: This class and build_config.FlagsConfig should be combined.

Parameters:

list_of_flags (Optional[List[str]]) – List of parameters to initialise this object with. (default: None)

checksum()#
Return type:

str

Returns:

a checksum of the flags.

add_flags(new_flags)#

Adds the specified flags to the list of flags.

Parameters:

new_flags (Union[str, List[str]]) – A single string or list of strings which are the flags to be added.

remove_flag(remove_flag, has_parameter=False)#

Removes all occurrences of remove_flag in flags. If has_parameter is defined, the next entry in flags will also be removed, and if this object contains this flag+parameter without space (e.g. -J/tmp), it will be correctly removed. Note that only the flag itself must be specified, you cannot remove a flag only if a specific parameter is given (i.e. remove_flag=”-J/tmp” will not work if this object contains […,”-J”, “/tmp”]).

Parameters:
  • remove_flag (str) – the flag to remove

  • has_parameter (bool) – if the flag to remove takes a parameter (default: False)

class fab.tools.flags.ProfileFlags#

A list of flags that support a ‘profile’ to be used. If no profile is specified, it will use “” (empty string) as ‘profile’. All functions take an optional profile parameter, so this class can also be used for tools that do not need a profile.

define_profile(name, inherit_from=None)#

Defines a new profile name, and allows to specify if this new profile inherit settings from an existing profile. If inherit_from is specified, the newly defined profile will inherit from an existing profile (including the default profile “”).

Parameters:
  • name (str) – Name of the profile to define.

  • inherit_from (Optional[str]) – Optional name of a profile to inherit settings from. (default: None)

add_flags(new_flags, profile=None)#

Adds the specified flags to the list of flags.

Parameters:

new_flags (Union[str, List[str]]) – A single string or list of strings which are the flags to be added.

remove_flag(remove_flag, profile=None, has_parameter=False)#

Removes all occurrences of remove_flag in flags. If has_parameter is defined, the next entry in flags will also be removed, and if this object contains this flag+parameter without space (e.g. -J/tmp), it will be correctly removed. Note that only the flag itself must be specified, you cannot remove a flag only if a specific parameter is given (i.e. remove_flag=”-J/tmp” will not work if this object contains […,”-J”, “/tmp”]).

Parameters:
  • remove_flag (str) – the flag to remove

  • has_parameter (bool) – if the flag to remove takes a parameter (default: False)

checksum(profile=None)#
Return type:

str

Returns:

a checksum of the flags.