List
Collection of DIRAC useful list related modules. By default on Error they return None.
- DIRAC.Core.Utilities.List.appendUnique(aList, anObject)
Append to list if object does not exist.
- Parameters
aList (list) – list of elements
anObject – object you want to append
- DIRAC.Core.Utilities.List.breakListIntoChunks(aList, chunkSize)
- This function takes a list as input and breaks it into list of size ‘chunkSize’.
It returns a list of lists.
- DIRAC.Core.Utilities.List.fromChar(inputString, sepChar=',')
Generates a list splitting a string by the required character(s) resulting string items are stripped and empty items are removed.
- Parameters
inputString (string) – list serialised to string
sepChar (string) – separator
- Returns
list of strings or None if sepChar has a wrong type
- DIRAC.Core.Utilities.List.getChunk(aList, chunkSize)
Generator yielding chunk from a list of a size chunkSize.
- Parameters
- Raise
StopIteration
Usage:
>>> for chunk in getChunk( aList, chunkSize=10): process( chunk )
- DIRAC.Core.Utilities.List.getIndexInList(anItem, aList)
Return the index of the element x in the list l or sys.maxint if it does not exist
- Parameters
anItem – element to look for
aList (list) – list to look into
- Returns
the index or sys.maxint
- DIRAC.Core.Utilities.List.intListToString(aList)
This function is used for making MySQL queries with a list of int elements.
- Parameters
aList (list) – list to be serialized to string for making queries
- DIRAC.Core.Utilities.List.pop(aList, popElement)
Pop the first element equal to popElement from the list.
- Parameters
aList (list) – list
popElement – element to pop
- DIRAC.Core.Utilities.List.randomize(aList)
Return a randomly sorted list.
- Parameters
aList (list) – list to permute