def exists_context(**context):
    return {key: value for key, value in context.items() if value or isinstance(value, (bool,float,int))}


INIT_CONTEXT = lambda fields=list(), iterateUnit=None, interval=None, startDate=None, endDate=None, \
                        datetimeUnit="second", tzinfo=None, returnType=None, \
                        logName=str(), logLevel="WARN", logFile=str(), debug=False, rename=dict(), \
                        delay=1., numTasks=100, progress=True, message=str(), apiRedirect=False, \
                        queryInfo=None, uploadInfo=None, encryptedKey=None, cookies=str(), **context: \
    dict(exists_context(
        fields = fields,
        startDate = startDate,
        endDate = endDate,
        datetimeUnit = datetimeUnit,
        tzinfo = tzinfo,
        logName = logName,
        logLevel = logLevel,
        logFile = logFile,
        debug = debug,
        rename = rename,
        delay = delay,
        numTasks = numTasks,
        progress = progress,
        message = message,
        apiRedirect = apiRedirect,
        encryptedKey = encryptedKey,
        cookies = cookies,
        ), **context)


UNIQUE_CONTEXT = lambda asyncio=False, operation=None, host=None, where=None, which=None, initTime=None, \
                        session=None, semaphore=None, contextFields=None, \
                        iterateArgs=None, iterateQuery=None, iterateUnit=None, responseType=None, \
                        logger=None, logJson=None, errors=None, rename=None, \
                        redirectArgs=None, redirectQuery=None, redirectUnit=None, \
                        maxLimit=None, redirectLimit=None, authClass=None, dependencies=None, \
                        data=None, results=None, crawler=None, prefix=None, self_var=True, **context: context


REDIRECT_CONTEXT = lambda apiRedirect=None, logFile=None, **context: INIT_CONTEXT(**UNIQUE_CONTEXT(**context))
