

def _get_params(mapper_spec, allowed_keys=None):
    'Obtain output writer parameters.\n\n  Utility function for output writer implementation. Fetches parameters\n  from mapreduce specification giving appropriate usage warnings.\n\n  Args:\n    mapper_spec: The MapperSpec for the job\n    allowed_keys: set of all allowed keys in parameters as strings. If it is not\n      None, then parameters are expected to be in a separate "output_writer"\n      subdictionary of mapper_spec parameters.\n\n  Returns:\n    mapper parameters as dict\n\n  Raises:\n    BadWriterParamsError: if parameters are invalid/missing or not allowed.\n  '
    if ('output_writer' not in mapper_spec.params):
        message = "Output writer's parameters should be specified in output_writer subdictionary."
        if allowed_keys:
            raise errors.BadWriterParamsError(message)
        params = mapper_spec.params
        params = dict(((str(n), v) for (n, v) in params.iteritems()))
    else:
        if (not isinstance(mapper_spec.params.get('output_writer'), dict)):
            raise errors.BadWriterParamsError('Output writer parameters should be a dictionary')
        params = mapper_spec.params.get('output_writer')
        params = dict(((str(n), v) for (n, v) in params.iteritems()))
        if allowed_keys:
            params_diff = (set(params.keys()) - allowed_keys)
            if params_diff:
                raise errors.BadWriterParamsError(('Invalid output_writer parameters: %s' % ','.join(params_diff)))
    return params

dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/mapreduce/output_writers.py _get_params/original