'Initialize a DeferredList.
@param deferredList: The list of deferreds to track.
@type deferredList:  L{list} of L{Deferred}s
@param fireOnOneCallback: (keyword param) a flag indicating that this
L{DeferredList} will fire when the first L{Deferred} in
C{deferredList} fires with a non-failure result without waiting for
any of the other Deferreds.  When this flag is set, the DeferredList
will fire with a two-tuple: the first element is the result of the
Deferred which fired; the second element is the index in
C{deferredList} of that Deferred.
@type fireOnOneCallback: L{bool}
@param fireOnOneErrback: (keyword param) a flag indicating that this
L{DeferredList} will fire when the first L{Deferred} in
C{deferredList} fires with a failure result without waiting for any
of the other Deferreds.  When this flag is set, if a Deferred in the
list errbacks, the DeferredList will errback with a L{FirstError}
failure wrapping the failure of that Deferred.
@type fireOnOneErrback: L{bool}
@param consumeErrors: (keyword param) a flag indicating that failures in
any of the included L{Deferred}s should not be propagated to
errbacks added to the individual L{Deferred}s after this
L{DeferredList} is constructed.  After constructing the
L{DeferredList}, any errors in the individual L{Deferred}s will be
converted to a callback result of L{None}.  This is useful to
prevent spurious \'Unhandled error in Deferred\' messages from being
logged.  This does not prevent C{fireOnOneErrback} from working.
@type consumeErrors: L{bool}'

def __init__(self, deferredList, fireOnOneCallback=False, fireOnOneErrback=False, consumeErrors=False):

    self._deferredList = list(deferredList)
    self.resultList = ([None] * len(self._deferredList))
    Deferred.__init__(self)
    if ((len(self._deferredList) == 0) and (not fireOnOneCallback)):
        self.callback(self.resultList)
    self.fireOnOneCallback = fireOnOneCallback
    self.fireOnOneErrback = fireOnOneErrback
    self.consumeErrors = consumeErrors
    self.finishedCount = 0
    index = 0
    for deferred in self._deferredList:
        deferred.addCallbacks(self._cbDeferred, self._cbDeferred, callbackArgs=(index, SUCCESS), errbackArgs=(index, FAILURE))
        index = (index + 1)
