##// END OF EJS Templates
py3: use print_function in get-with-headers.py
Robert Stanca -
r28726:f4b31fcd default
parent child Browse files
Show More
@@ -3,7 +3,7 b''
3 """This does HTTP GET requests given a host:port and path and returns
3 """This does HTTP GET requests given a host:port and path and returns
4 a subset of the headers plus the body of the result."""
4 a subset of the headers plus the body of the result."""
5
5
6 from __future__ import absolute_import
6 from __future__ import absolute_import, print_function
7
7
8 import httplib
8 import httplib
9 import json
9 import json
@@ -41,15 +41,15 b' def request(host, path, show):'
41 conn = httplib.HTTPConnection(host)
41 conn = httplib.HTTPConnection(host)
42 conn.request("GET", '/' + path, None, headers)
42 conn.request("GET", '/' + path, None, headers)
43 response = conn.getresponse()
43 response = conn.getresponse()
44 print response.status, response.reason
44 print(response.status, response.reason)
45 if show[:1] == ['-']:
45 if show[:1] == ['-']:
46 show = sorted(h for h, v in response.getheaders()
46 show = sorted(h for h, v in response.getheaders()
47 if h.lower() not in show)
47 if h.lower() not in show)
48 for h in [h.lower() for h in show]:
48 for h in [h.lower() for h in show]:
49 if response.getheader(h, None) is not None:
49 if response.getheader(h, None) is not None:
50 print "%s: %s" % (h, response.getheader(h))
50 print("%s: %s" % (h, response.getheader(h)))
51 if not headeronly:
51 if not headeronly:
52 print
52 print()
53 data = response.read()
53 data = response.read()
54
54
55 # Pretty print JSON. This also has the beneficial side-effect
55 # Pretty print JSON. This also has the beneficial side-effect
@@ -60,7 +60,7 b' def request(host, path, show):'
60 data = json.loads(data)
60 data = json.loads(data)
61 lines = json.dumps(data, sort_keys=True, indent=2).splitlines()
61 lines = json.dumps(data, sort_keys=True, indent=2).splitlines()
62 for line in lines:
62 for line in lines:
63 print line.rstrip()
63 print(line.rstrip())
64 else:
64 else:
65 sys.stdout.write(data)
65 sys.stdout.write(data)
66
66
@@ -40,7 +40,6 b''
40 i18n/check-translation.py not using absolute_import
40 i18n/check-translation.py not using absolute_import
41 i18n/polib.py not using absolute_import
41 i18n/polib.py not using absolute_import
42 setup.py not using absolute_import
42 setup.py not using absolute_import
43 tests/get-with-headers.py requires print_function
44 tests/heredoctest.py requires print_function
43 tests/heredoctest.py requires print_function
45 tests/hypothesishelpers.py not using absolute_import
44 tests/hypothesishelpers.py not using absolute_import
46 tests/hypothesishelpers.py requires print_function
45 tests/hypothesishelpers.py requires print_function
@@ -257,7 +256,6 b''
257 mercurial/win*.py: error importing module: <ImportError> No module named 'msvcrt' (line *) (glob)
256 mercurial/win*.py: error importing module: <ImportError> No module named 'msvcrt' (line *) (glob)
258 mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)
257 mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)
259 mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
258 mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
260 tests/get-with-headers.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
261 tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
259 tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
262 tests/silenttestrunner.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
260 tests/silenttestrunner.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
263 tests/test-batching.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
261 tests/test-batching.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
General Comments 0
You need to be logged in to leave comments. Login now