70f54a7aed3ac7d3108cb7b651fccb27e80b754a
[gentoo.git] /
1 From 0991ccb0e7c0be66e087839f88a7120394c2f052 Mon Sep 17 00:00:00 2001
2 From: Mike Frysinger <vapier@chromium.org>
3 Date: Tue, 5 May 2015 23:54:16 -0400
4 Subject: [PATCH 2/3] pwclient: use print_function for better py3 compatibility
5
6 The script already tries to use print like a function in many places but
7 is really passing a parenthesized string.  Import the print_function from
8 the future module so that it actually works as intended.
9
10 We also need to fix up a few latent print statements to make it work.
11
12 Signed-off-by: Mike Frysinger <vapier@chromium.org>
13 ---
14  apps/patchwork/bin/pwclient | 26 ++++++++++++++------------
15  1 file changed, 14 insertions(+), 12 deletions(-)
16
17 diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
18 index 56aa909..2e6daa5 100755
19 --- a/apps/patchwork/bin/pwclient
20 +++ b/apps/patchwork/bin/pwclient
21 @@ -19,6 +19,8 @@
22  # along with Patchwork; if not, write to the Free Software
23  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  
25 +from __future__ import print_function
26 +
27  import os
28  import sys
29  import xmlrpclib
30 @@ -170,9 +172,9 @@ def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
31          else:
32              for id in ids:
33                  person = rpc.person_get(id)
34 -                print "Patches submitted by %s <%s>:" % \
35 -                        (unicode(person['name']).encode("utf-8"), \
36 -                         unicode(person['email']).encode("utf-8"))
37 +                print('Patches submitted by %s <%s>:' %
38 +                      (unicode(person['name']).encode('utf-8'),
39 +                       unicode(person['email']).encode('utf-8')))
40                  f = filter
41                  f.add("submitter_id", id)
42                  patches = rpc.patch_list(f.d)
43 @@ -187,8 +189,8 @@ def action_list(rpc, filter, submitter_str, delegate_str, format_str=None):
44          else:
45              for id in ids:
46                  person = rpc.person_get(id)
47 -                print "Patches delegated to %s <%s>:" % \
48 -                        (person['name'], person['email'])
49 +                print('Patches delegated to %s <%s>:' %
50 +                      (person['name'], person['email']))
51                  f = filter
52                  f.add("delegate_id", id)
53                  patches = rpc.patch_list(f.d)
54 @@ -245,7 +247,7 @@ def action_get(rpc, patch_id):
55      try:
56          f.write(unicode(s).encode("utf-8"))
57          f.close()
58 -        print "Saved patch to %s" % fname
59 +        print('Saved patch to %s' % fname)
60      except:
61          sys.stderr.write("Failed to write to %s\n" % fname)
62          sys.exit(1)
63 @@ -258,13 +260,13 @@ def action_apply(rpc, patch_id, apply_cmd=None):
64          sys.exit(1)
65  
66      if apply_cmd is None:
67 -      print "Applying patch #%d to current directory" % patch_id
68 +      print('Applying patch #%d to current directory' % patch_id)
69        apply_cmd = ['patch', '-p1']
70      else:
71 -      print "Applying patch #%d using %s" % (
72 -          patch_id, repr(' '.join(apply_cmd)))
73 +      print('Applying patch #%d using %s' %
74 +            (patch_id, repr(' '.join(apply_cmd))))
75  
76 -    print "Description: %s" % patch['name']
77 +    print('Description: %s' % patch['name'])
78      s = rpc.patch_get_mbox(patch_id)
79      if len(s) > 0:
80          proc = subprocess.Popen(apply_cmd, stdin = subprocess.PIPE)
81 @@ -295,7 +297,7 @@ def action_update_patch(rpc, patch_id, state = None, commit = None):
82      success = False
83      try:
84          success = rpc.patch_set(patch_id, params)
85 -    except xmlrpclib.Fault, f:
86 +    except xmlrpclib.Fault as f:
87          sys.stderr.write("Error updating patch: %s\n" % f.faultString)
88  
89      if not success:
90 @@ -668,7 +670,7 @@ def main():
91          for patch_id in non_empty(h, patch_ids):
92              s = rpc.patch_get_mbox(patch_id)
93              if len(s) > 0:
94 -                print unicode(s).encode("utf-8")
95 +                print(unicode(s).encode('utf-8'))
96  
97      elif action == 'info':
98          for patch_id in non_empty(h, patch_ids):
99 -- 
100 2.4.0
101