Prepare request data

    :param params:
    :param files:
    :return:
545506
def compose_data(params=None, files=None):
    
    data = aiohttp.formdata.FormData(quote_fields=False)

    if params:
        for key, value in params.items():
            data.add_field(key, str(value))

    if files:
        for key, f in files.items():
            if isinstance(f, tuple):
                if len(f) == 2:
                    filename, fileobj = f
                else:
                    raise ValueError('Tuple must have exactly 2 elements: filename, fileobj')
            elif isinstance(f, types.InputFile):
                filename, fileobj = f.filename, f.file
            else:
                filename, fileobj = guess_filename(f) or key, f

            data.add_field(key, fileobj, filename=filename)

    return data
1030514
def _load_params(params, logger=logging):
    
    if isinstance(params, str):
        cur_path = os.path.dirname(os.path.realpath(__file__))
        param_file_path = os.path.join(cur_path, params)
        logger.info('Loading params from file %s' % param_file_path)
        save_dict = nd_load(param_file_path)
        arg_params = {}
        aux_params = {}
        for k, v in save_dict.items():
            tp, name = k.split(':', 1)
            if tp == 'arg':
                arg_params[name] = v
            if tp == 'aux':
                aux_params[name] = v
        return arg_params, aux_params
    elif isinstance(params, (tuple, list)) and len(params) == 2:
        return params[0], params[1]
    else:
        raise ValueError('Unsupported params provided. Must be either a path to the param file or'
                         ' a pair of dictionaries representing arg_params and aux_params')
286806
function runner (params, files) {
  var list = array(files || globs())

  list.forEach(function (file) {
    apply(require(path.resolve(file)), [test].concat(params))
  })

  return list
}
617251
def file_get_details(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/getDetails' % object_id, input_params, always_retry=always_retry, **kwargs)
960683
private void prepareUploadParams(RequestElements requestElements) {
		Map<String, String> requestHeaders = requestElements.getRequestHeaders();
		UploadRequestElements uploadRequestElements = requestElements.getUploadRequestElements();
		String boundaryId = uploadRequestElements.getBoundaryId();
		String formMetadataName = "file_metadata_" + boundaryId.substring(0, 5) + "_" + uploadRequestElements.getElementsId();
		String formContentName = "file_content_" + boundaryId.substring(0, 5) + "_" + uploadRequestElements.getElementsId();
		String contentType = ContentTypes.getContentType(getSerializationRequestFormat());
		
		Attachable attachable = (Attachable) requestElements.getEntity();
		String fileName = (attachable.getFileName() != null) ? "; filename=\"" + attachable.getFileName() + "\"" : "";
		String fileType = (attachable.getContentType() != null) ? "Content-Type: " + attachable.getContentType() + "\r\n" : "";
		
		String entityBoundary = String.format(UploadRequestElements.TEMPLATE_ENTITY_BOUNDARY, boundaryId, formMetadataName, contentType);
		String contentBoundary = String.format(UploadRequestElements.TEMPLATE_CONTENT_BOUNDARY, boundaryId, formContentName, fileName, fileType);
		
		requestHeaders.put(RequestElements.HEADER_PARAM_CONTENT_TYPE, ContentTypes.MULTIPART_FORMDATA.toString() + "; boundary=" + boundaryId);
		
		uploadRequestElements.setBoundaryForEntity(entityBoundary);
		uploadRequestElements.setBoundaryForContent(contentBoundary);
	}
430093
def get_params(names):
    
    params = {}
    for name in names:
        value = request.form.get(name) or request.files.get(name)
        if value is not None:
            params[name] = value
    return params
20168
def prepare_params(request):
    """"""
    return request.replace(
        params={key: dump_param(val) for key, val in request.params.items()
                if val is not None})
1334348
def prepare(self):
        """"""
        p = PreparedRequest()
        p.prepare(
            method=self.method,
            url=self.url,
            headers=self.headers,
            files=self.files,
            data=self.data,
            params=self.params,
            auth=self.auth,
            cookies=self.cookies,
            hooks=self.hooks,
        )
        return p
688568
function sendFile(params) {
    const p = params;
    
    checkParams(params);
    
    fs.lstat(p.name, (error, stat) => {
        if (error)
            return sendError(error, params);
        
        const isGzip = isGZIP(p.request) && p.gzip;
        const time = stat.mtime.toUTCString();
        const length = stat.size;
        const range = getRange(p.request, length);
        
        if (range)
            assign(p, {
                range,
                status: RANGE
            });
        
        assign(p, {
            time
        });
        
        if (!isGzip)
            p.length = length;
        
        setHeader(params);
        
        const options = {
            gzip    : isGzip,
            range,
        };
        
        files.pipe(p.name, p.response, options).catch((error) => {
            sendError(error, params);
        });
    });
}
749851
def prepare_params(modeline, fileconfig, options):
    
    params = dict(skip=False, ignore=[], select=[], linters=[])
    if options:
        params['ignore'] = list(options.ignore)
        params['select'] = list(options.select)

    for config in filter(None, [modeline, fileconfig]):
        for key in ('ignore', 'select', 'linters'):
            params[key] += process_value(key, config.get(key, []))
        params['skip'] = bool(int(config.get('skip', False)))
    # TODO: skip what? This is causing erratic behavior for linters.
    params['skip'] = False

    params['ignore'] = set(params['ignore'])
    params['select'] = set(params['select'])

    return params
232712
def upload_files(files, options = {})
      data = upload_params(options).for_file_upload(files)

      response = @upload_connection.post('/base/', data)

      response.body.values.map! { |f| Uploadcare::Api::File.new(self, f) }
    end
1320300
def _upload_files(item, files, upload_kwargs, prev_identifier=None, archive_session=None):
    """"""
    responses = []
    if (upload_kwargs['verbose']) and (prev_identifier != item.identifier):
        print('{0}:'.format(item.identifier))

    try:
        response = item.upload(files, **upload_kwargs)
        responses += response
    except HTTPError as exc:
        responses += [exc.response]
    finally:
        # Debug mode.
        if upload_kwargs['debug']:
            for i, r in enumerate(responses):
                if i != 0:
                    print('---')
                headers = '\n'.join(
                    [' {0}:{1}'.format(k, v) for (k, v) in r.headers.items()]
                )
                print('Endpoint:\n {0}\n'.format(r.url))
                print('HTTP Headers:\n{0}'.format(headers))
                return responses

        # Format error message for any non 200 responses that
        # we haven't caught yet,and write to stderr.
        if responses and responses[-1].status_code and responses[-1].status_code != 200:
            if not responses[-1].status_code:
                return responses
            filename = responses[-1].request.url.split('/')[-1]
            try:
                msg = get_s3_xml_text(responses[-1].content)
            except:
                msg = responses[-1].content
            print(' error uploading {}: {}'.format(filename, msg), file=sys.stderr)

    return responses
1342387
def build_parameters(request, meta, orgaMode, currentOrga):
    """"""

    postParameters = {}
    getParameters = {}
    files = {}

    def update_parameters(data):
        tmp_getParameters, tmp_postParameters, tmp_files = data

        getParameters.update(tmp_getParameters)
        postParameters.update(tmp_postParameters)
        files.update(tmp_files)

    update_parameters(build_base_parameters(request))
    update_parameters(build_user_requested_parameters(request, meta))
    update_parameters(build_orga_parameters(request, orgaMode, currentOrga))

    return (getParameters, postParameters, files)
593169
def paras(self: object, fileids: str):
        

        for text in self.texts(fileids):
            for para in text.split('\n\n'):
                yield para
752290
def cache_data(self, request, data, key='params'):
        
        request.session['%s:%s' % (constants.SESSION_KEY, key)] = data
1194960
function(params, callback) {
                getFileData = {};

                if (params) {
                    if (typeof params.fileId != 'undefined') {
                        getFileData.fileId = params.fileId;
                    }

                    if (typeof params.hashCode == 'string') {
                        getFileData.hashCode = params.hashCode;
                    }

                    if (typeof params.downloadable == 'boolean') {
                        getFileData.downloadable = params.downloadable;
                    }
                }

                httpRequest({
                    url: SERVICE_ADDRESSES.FILESERVER_ADDRESS +
                    SERVICES_PATH.GET_FILE,
                    method: 'GET',
                    data: getFileData
                }, function(result) {
                    if (!result.hasError) {
                        var queryString = '?';
                        for (var i in params) {
                            queryString += i + '=' + params[i] + '&';
                        }
                        queryString = queryString.slice(0, -1);
                        var file = SERVICE_ADDRESSES.FILESERVER_ADDRESS + SERVICES_PATH.GET_FILE + queryString;
                        callback({
                            hasError: result.hasError,
                            result: file
                        });
                    }
                    else {
                        callback({
                            hasError: true
                        });
                    }
                });
            }
900979
def _prepare_batch_request(self):
        
        if len(self._requests) == 0:
            raise ValueError("No deferred requests")

        multi = MIMEMultipart()

        for method, uri, headers, body in self._requests:
            subrequest = MIMEApplicationHTTP(method, uri, headers, body)
            multi.attach(subrequest)

        # The `email` package expects to deal with "native" strings
        if six.PY3:  # pragma: NO COVER  Python3
            buf = io.StringIO()
        else:
            buf = io.BytesIO()
        generator = Generator(buf, False, 0)
        generator.flatten(multi)
        payload = buf.getvalue()

        # Strip off redundant header text
        _, body = payload.split("\n\n", 1)
        return dict(multi._headers), body