Skip to content
Myr

Renaming vars. String formatting

Before adoption: this commit came in with the history the project adopted, so no landing records it.

#139

authored by Mike Waldner · committed by Mike Waldner · parent 3dd2235 · Browse files · 1 file+29 added−28 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+29 added−28 removed

  • other:+29 added−28 removed

1 file+29 added−28 removed

modified:requests/utils.py+29 added-28 removed
166 unmodified lines
167168 return zlib.decompress(content, 16+zlib.MAX_WBITS)169170171def curl_from_request(request):172 """Creates a curl command from the request."""171def curl_from_request(request): 172 """Creates a curl command from the request.""" 173174 #TODO - Files175 #TODO - OAuth176 #TODO - Cookies174 #TODO - Files 175 #TODO - OAuth 176 #TODO - Cookies 177178 #: -L/--location - if there is a redirect, redo request on the new place179 curl = 'curl -L '178 #: -L/--location - if there is a redirect, redo request on the new place 179 curl = 'curl -L ' 180181 #: -u/--user - Specify the user name and password to use for server auth. 182 auth = ''183 if request.auth is not None:182 auth = '' 183 if request.auth is not None: 184 auth = '-u "%s:%s" ' % (request.auth.username, request.auth.password) 185186 if request.method.upper() == 'HEAD':187 #: -I/--head - fetch headers only188 method = '-I '189 else:190 #: -X/--request - specify request method191 method = '-X %s ' % request.method.upper()186 if request.method.upper() == 'HEAD': 187 #: -I/--head - fetch headers only 188 method = '-I ' 189 else: 190 #: -X/--request - specify request method 191 method = '-X %s ' % request.method.upper() 192193 #: -H/--header - Extra header to use when getting a web page194 header = ''195 if request.headers:196 header = header.join(['-H "%s:%s" ' % (k, v) for k, v in request.headers.iteritems()])193 #: -H/--header - Extra header to use when getting a web page 194 header = '' 195 if request.headers: 196 header = header.join(['-H "%s:%s" ' % (k, v) for k, v in request.headers.iteritems()]) 197198 data = ''199 if request.method in ('PUT', 'POST', 'PATCH'):200 #: -d/--data - send specified data in post request.201 if isinstance(request.data, (list, tuple)):202 data = data.join(['-d "%s=%s" ' % (k, v) for (k, v) in request.data])203 elif request._enc_data is not None:204 data = '-d %s ' % (request._enc_data)198 data = '' 199 if request.method in ('PUT', 'POST', 'PATCH'): 200 #: -d/--data - send specified data in post request. 201 if isinstance(request.data, (list, tuple)): 202 data = data.join(['-d "%s=%s" ' % (k, v) for (k, v) in request.data]) 203 elif request._enc_data is not None: 204 data = '-d %s ' % (request._enc_data) 205206206 #: Params handled in _build_url207 return curl + auth + method + header + data + '"' + request._build_url() + '"'207 #: Params handled in _build_url 208 return curl + auth + method + header + data + '"' + request._build_url() + '"'