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
Provenance
- Commit
cfee830- Tree
738e83f- Author
Mike Waldner <mwaldner@gilt.com>- Committer
Mike Waldner <mwaldner@gilt.com>- Parent
3dd2235
1 file changed+29 added−28 removed
modified:requests/utils.py+29 added-28 removed
166 unmodified lines167 168 return zlib.decompress(content, 16+zlib.MAX_WBITS)169 170 171-def curl_from_request(request):172- """Creates a curl command from the request."""171+def curl_from_request(request): 172+ """Creates a curl command from the request.""" 173 174- #TODO - Files175- #TODO - OAuth176- #TODO - Cookies174+ #TODO - Files 175+ #TODO - OAuth 176+ #TODO - Cookies 177 178- #: -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 ' 180 181 #: -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) 185 186- 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() 192 193- #: -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()]) 197 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)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) 205 206+206- #: 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() + '"'