easybuild.tools.variables module¶
Module that contains a set of classes and function to generate variables to be used e.g., in compiling or linking
Authors:
- Stijn De Weirdt (Ghent University)
- Kenneth Hoste (Ghent University)
-
class
easybuild.tools.variables.AbsPathList(*args, **kwargs)¶ Bases:
easybuild.tools.variables.StrListAbsolute paths (eg -L or -I)
-
SANITIZE_REMOVE_DUPLICATE_KEEP= -1¶
-
append_exists(prefix, paths, suffix=None, filename=None, append_all=False)¶ - Given prefix and list of paths, return first that exists
- if suffix : extend the paths with prefixes if filename : look for filename in prefix+paths
-
append_subdirs(base, subdirs=None)¶ Add directory base, or its subdirs if subdirs is not None
-
-
class
easybuild.tools.variables.CommaList(*args, **kwargs)¶ Bases:
easybuild.tools.variables.StrListComma-separated list
-
SEPARATOR= ','¶
-
-
class
easybuild.tools.variables.ListOfLists(*args, **kwargs)¶ Bases:
listList of lists
-
JOIN_BEGIN_END= False¶
-
PROTECTED_CLASSES= []¶
-
PROTECTED_INSTANCES= []¶
-
PROTECT_CLASS_SELF= True¶
-
PROTECT_INSTANCE_SELF= True¶
-
SANITIZE_REMOVE_DUPLICATE= False¶
-
SANITIZE_REMOVE_DUPLICATE_KEEP= None¶
-
SANITIZE_SORT= True¶
-
SEPARATOR= None¶
-
append_empty()¶ Initialise MAP_CLASS instance
-
copy()¶ Return copy of self
-
flatten()¶
-
get_first()¶ Return first non-empty list if it doesn’t exist, try to return first element
-
nappend(value, **kwargs)¶ Named append name is not used anymore
-
nextend(value=None, **kwargs)¶ Named extend, value is list type (TODO: tighten the allowed values) name not used anymore
-
sanitize()¶ Cleanup self
-
show_el()¶ Show some info on the elements
-
str_convert(x)¶ Given x, return a string representing x called in __str__ of this class
-
try_function_on_element(function_name, names=None, args=None, kwargs=None)¶ Try to run function function_name on each element
-
try_remove(values)¶ Try to remove one or more values from the elements
-
-
class
easybuild.tools.variables.StrList(*args, **kwargs)¶ Bases:
listList of strings
-
BEGIN= None¶
-
END= None¶
-
JOIN_BEGIN_END= False¶
-
POSITION= 0¶
-
PREFIX= None¶
-
SANITIZE_REMOVE_DUPLICATE_KEEP= None¶
-
SEPARATOR= ' '¶
-
SUFFIX= None¶
-
copy()¶ Return copy of self
-
sanitize()¶ Sanitize self
-
str_convert(x)¶ Convert members of list to string (no prefix of begin and end)
-
try_remove(values)¶ Remove without ValueError in case of missing element
-
-
class
easybuild.tools.variables.Variables(*args, **kwargs)¶ Bases:
dict- Class to hold variable-like key/value pairs
- All values are lists (or derived from list class)
- most only have a single element though some are lists of lists
__str__ creates a single string
- Most items are of same DEFAULT_CLASS
- but are in different classes
-
DEFAULT_LISTCLASS¶ alias of
ListOfLists
-
MAP_CLASS= {}¶
-
MAP_LISTCLASS= {}¶
-
append(name, value)¶ Append value to element name (alias for nappend)
-
get_element_class(name)¶ Return the class associated with the name according to the DEFAULT_CLASS and MAP_CLASS
-
get_instance(name=None)¶ Return an instance of the class
-
get_list_class(name)¶ Return the class associated with the name according to the DEFAULT_LISTCLASS and MAP_LISTCLASS
-
join(name, *others)¶ Join all values in others into name it is first tested if other is an existing element
else it is nappend-ed
-
setdefault(name, default=None, append_empty=False)¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
try_function_on_element(function_name, names=None, args=None, kwargs=None)¶ Try to run function function_name on each element of names
-
easybuild.tools.variables.get_class(name, default_class, map_class=None)¶ Return class based on default map_class
if key == str -> value = class else: key = class -> list of strings
-
easybuild.tools.variables.join_map_class(map_classes)¶ Join all class_maps into single class_map