Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/
Date: Wed, 27 Apr 2011 11:00:33
Message-Id: e14906b88ec2da99dba82d565d88ed5ca1d40099.dol-sen@gentoo
1 commit: e14906b88ec2da99dba82d565d88ed5ca1d40099
2 Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
3 AuthorDate: Sun Mar 27 03:24:26 2011 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Sun Mar 27 03:24:26 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=e14906b8
7
8 migrate to print()
9
10 ---
11 layman/api.py | 10 +++++---
12 layman/cli.py | 22 ++++++++++---------
13 layman/dbbase.py | 6 +++-
14 layman/debug.py | 59 +++++++++++++++++++++++++++-------------------------
15 layman/output.py | 15 +++++++------
16 layman/version.py | 4 ++-
17 6 files changed, 64 insertions(+), 52 deletions(-)
18
19 diff --git a/layman/api.py b/layman/api.py
20 index 75d0c10..9dfb1a3 100644
21 --- a/layman/api.py
22 +++ b/layman/api.py
23 @@ -13,6 +13,8 @@
24 # Brian Dolbec <dol-sen@×××××××××××.net>
25 #
26
27 +from __future__ import print_function
28 +
29 from sys import stderr
30 import os
31
32 @@ -248,10 +250,10 @@ class LaymanAPI(object):
33 continue
34 try:
35 overlay = db.select(ovl)
36 - #print "overlay = ", ovl
37 - #print "!!!", overlay
38 + #print("overlay = ", ovl)
39 + #print("!!!", overlay)
40 except UnknownOverlayException, error:
41 - #print "ERRORS", str(error)
42 + #print("ERRORS", str(error))
43 self._error(error)
44 result[ovl] = ('', False, False)
45 else:
46 @@ -422,7 +424,7 @@ class LaymanAPI(object):
47 #msg = "Error: %d," % num, message
48 self._error_messages.append(message)
49 if self.report_errors:
50 - print >>stderr, msg
51 + print(msg, file=stderr)
52
53
54 def get_errors(self):
55
56 diff --git a/layman/cli.py b/layman/cli.py
57 index 8f94f4a..1187ef2 100644
58 --- a/layman/cli.py
59 +++ b/layman/cli.py
60 @@ -19,6 +19,8 @@
61 #
62 ''' Provides the command line actions that can be performed by layman.'''
63
64 +from __future__ import print_function
65 +
66 __version__ = "$Id: cli.py 2011-01-15 23:52 PST Brian Dolbec$"
67
68
69 @@ -48,27 +50,27 @@ class ListPrinter(object):
70 self.my_lister = self.short_list
71
72 def print_shortdict(self, info, complain):
73 - #print "ListPrinter.print_shortdict()",info, "\n\n"
74 + #print("ListPrinter.print_shortdict()",info, "\n\n")
75 overlays = sorted(info)
76 - #print "ids =======>", overlays, "\n"
77 + #print("ids =======>", overlays, "\n")
78 for ovl in overlays:
79 overlay = info[ovl]
80 - #print "overlay =", overlay
81 + #print("overlay =", overlay)
82 summary, supported, official = overlay
83 self.print_overlay(summary, supported, official, complain)
84
85 def print_shortlist(self, info, complain):
86 - #print "ListPrinter.print_shortlist()",info
87 + #print("ListPrinter.print_shortlist()",info)
88 for summary, supported, official in info:
89 self.print_overlay(summary, supported, official, complain)
90
91
92 def print_fulldict(self, info, complain):
93 ids = sorted(info)
94 - #print "ids =======>", ids, "\n"
95 + #print("ids =======>", ids, "\n")
96 for ovl in ids:
97 overlay = info[ovl]
98 - #print overlay
99 + #print(overlay)
100 self.print_overlay(self.my_lister(overlay),
101 overlay['supported'],
102 overlay['official'],
103 @@ -101,7 +103,7 @@ class ListPrinter(object):
104
105 def short_list(self, overlay):
106 '''
107 - >>> print short_list(overlay)
108 + >>> print(short_list(overlay))
109 wrobel [Subversion] (https://o.g.o/svn/dev/wrobel )
110 '''
111 name = pad(overlay['name'], 25)
112 @@ -127,7 +129,7 @@ class Main(object):
113
114 def __init__(self, config):
115 self.config = config
116 - #print "config.keys()", config.keys()
117 + #print("config.keys()", config.keys())
118 self.output = config['output']
119 self.api = LaymanAPI(config,
120 report_errors=True,
121 @@ -260,7 +262,7 @@ class Main(object):
122
123 info = self.api.get_info_str(selection, local=False,
124 verbose=True, width=list_printer.width)
125 - #print "info =", info
126 + #print("info =", info)
127 list_printer.print_shortdict(info, complain=_complain)
128
129 return info != {}
130 @@ -284,7 +286,7 @@ class Main(object):
131 def ListLocal(self):
132 ''' Lists the local overlays.
133 '''
134 - #print "ListLocal()"
135 + #print("ListLocal()")
136 self.output.debug('Printing installed overlays.', 6)
137 list_printer = ListPrinter(self.config)
138
139
140 diff --git a/layman/dbbase.py b/layman/dbbase.py
141 index 776a90f..02aeb9d 100644
142 --- a/layman/dbbase.py
143 +++ b/layman/dbbase.py
144 @@ -20,6 +20,8 @@
145 #
146 '''Main handler for overlays.'''
147
148 +from __future__ import print_function
149 +
150 __version__ = "$Id: overlay.py 273 2006-12-30 15:54:50Z wrobel $"
151
152 #===============================================================================
153 @@ -240,7 +242,7 @@ class DbBase:
154 >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
155 >>> a = DbBase([here + '/tests/testfiles/global-overlays.xml', ], config)
156 >>> for i in a.list(True):
157 - ... print i[0]
158 + ... print(i[0])
159 wrobel
160 ~~~~~~
161 Source : https://overlays.gentoo.org/svn/dev/wrobel
162 @@ -263,7 +265,7 @@ class DbBase:
163 <BLANKLINE>
164
165 >>> for i in a.list(False, 80):
166 - ... print i[0]
167 + ... print(i[0])
168 wrobel [Subversion] (https://o.g.o/svn/dev/wrobel )
169 wrobel-stable [Rsync ] (rsync://gunnarwrobel.de/wrobel-stable)
170 '''
171
172 diff --git a/layman/debug.py b/layman/debug.py
173 index f5c247b..ab04f40 100644
174 --- a/layman/debug.py
175 +++ b/layman/debug.py
176 @@ -6,6 +6,8 @@
177 # Copyright 2005 - 2008 Gunnar Wrobel
178 # Distributed under the terms of the GNU General Public License v2
179
180 +from __future__ import print_function
181 +
182 __version__ = "$Id: debug.py 153 2006-06-05 06:03:16Z wrobel $"
183
184 #################################################################################
185 @@ -101,7 +103,7 @@ class DebugMessage(Message):
186
187 def cli_opts(self, parser):
188
189 - #print "Parsing debug opts"
190 + #print("Parsing debug opts")
191
192 group = OptionGroup(parser,
193 '<Debugging options>',
194 @@ -327,11 +329,11 @@ class DebugMessage(Message):
195 if lines > 0:
196 for j in range(lines):
197 ## Print line with continuation marker
198 - print >> self.debug_out, ls + '// ' + x[0:60] + ' \\'
199 + print(ls + '// ' + x[0:60] + ' \\', file=self.debug_out)
200 ## Remove printed characters from output
201 x = x[60:]
202 ## Print final line
203 - print >> self.debug_out, ls + '// ' + x
204 + print(ls + '// ' + x, file=self.debug_out)
205
206 if self.debug_vrb == 1:
207 # Top line indicates class and method
208 @@ -340,60 +342,61 @@ class DebugMessage(Message):
209 c += 'Class: ' + str(callerobject.__class__.__name__) + ' | '
210 if callermethod:
211 c += 'Method: ' + str(callermethod)
212 - print >> self.debug_out, '// ' + c
213 + print('// ' + c, file=self.debug_out)
214 # Selected variables follow
215 if callerlocals:
216 for i,j in callerlocals.items():
217 - print >> self.debug_out, '// ' \
218 - + self.maybe_color('turquoise', str(i)) + ':' + str(j)
219 + print('// ' + self.maybe_color('turquoise',
220 + str(i)) + ':' + str(j), file=self.debug_out)
221 # Finally the message
222 - print >> self.debug_out, self.maybe_color('yellow', message)
223 + print(self.maybe_color('yellow', message), file=self.debug_out)
224 return
225
226 if self.debug_vrb == 3:
227 - print >> self.debug_out, ls + '/////////////////////////////////' + \
228 - '////////////////////////////////'
229 + print(ls + '/////////////////////////////////' + \
230 + '////////////////////////////////', file=self.debug_out)
231
232 # General information about what is being debugged
233 #(module name or similar)
234 - print >> self.debug_out, ls + '// ' + self.debug_env
235 - print >> self.debug_out, ls + '//-----------------------------------' + \
236 - '----------------------------'
237 + print(ls + '// ' + self.debug_env, file=self.debug_out)
238 + print(ls + '//-----------------------------------' + \
239 + '----------------------------', file=self.debug_out)
240
241 ## If the caller is a class print the name here
242 if callerobject:
243 - print >> self.debug_out, ls + \
244 - '// Object Class: ' + str(callerobject.__class__.__name__)
245 + print(ls + '// Object Class: ' +
246 + str(callerobject.__class__.__name__), file=self.debug_out)
247
248 ## If the method has been extracted print it here
249 if callermethod:
250 - print >> self.debug_out, ls + '// ' \
251 - + self.maybe_color('green', 'Method: ') + str(callermethod)
252 + print(ls + '// ' + self.maybe_color('green', 'Method: ')
253 + + str(callermethod), file=self.debug_out)
254 if self.debug_vrb == 3:
255 - print >> self.debug_out, ls + '//---------------------------' + \
256 - '------------------------------------'
257 + print(ls + '//---------------------------' + \
258 + '------------------------------------', file=self.debug_out)
259
260 ## Print the information on all available local variables
261 if callerlocals:
262 if self.debug_vrb == 3:
263 - print >> self.debug_out, ls + '//'
264 - print >> self.debug_out, ls + '// VALUES '
265 + print(ls + '//', file=self.debug_out)
266 + print(ls + '// VALUES ', file=self.debug_out)
267 for i,j in callerlocals.items():
268 - print >> self.debug_out, ls + '// ------------------> ' \
269 - + self.maybe_color('turquoise', str(i)) + ':'
270 + print(ls + '// ------------------> ' \
271 + + self.maybe_color('turquoise', str(i)) + ':',
272 + file=self.debug_out)
273 breaklines(str(j))
274 if self.debug_vrb == 3:
275 - print >> self.debug_out, ls + '//------------------------------'\
276 - '---------------------------------'
277 + print(ls + '//------------------------------'\
278 + '---------------------------------', file=self.debug_out)
279
280 # Finally print the message
281 breaklines(self.maybe_color('yellow', message))
282
283 if self.debug_vrb == 3:
284 - print >> self.debug_out, ls + '//-------------------------------' + \
285 - '--------------------------------'
286 - print >> self.debug_out, ls + '/////////////////////////////////' + \
287 - '////////////////////////////////'
288 + print(ls + '//-------------------------------' + \
289 + '--------------------------------', file=self.debug_out)
290 + print(ls + '/////////////////////////////////' + \
291 + '////////////////////////////////', file=self.debug_out)
292
293 ## gloabal message handler
294 OUT = Message('layman')
295
296 diff --git a/layman/output.py b/layman/output.py
297 index 469f673..caccd93 100644
298 --- a/layman/output.py
299 +++ b/layman/output.py
300 @@ -6,6 +6,7 @@
301 Distributed under the terms of the GNU General Public License v2
302 """
303
304 +from __future__ import print_function
305
306 __version__ = "0.1"
307
308 @@ -112,7 +113,7 @@ class Message(MessageBase):
309
310
311 def notice (self, note):
312 - print >> self.std_out, note
313 + print(note, file=self.std_out)
314
315
316 def info (self, info, level = INFO_LEVEL):
317 @@ -124,7 +125,7 @@ class Message(MessageBase):
318 return
319
320 for i in info.split('\n'):
321 - print >> self.std_out, self.color_func('green', '* ') + i
322 + print(self.color_func('green', '* ') + i, file=self.std_out)
323
324
325 def status (self, message, status, info = 'ignored'):
326 @@ -138,7 +139,7 @@ class Message(MessageBase):
327 return
328
329 for i in lines[0:-1]:
330 - print >> self.std_out, self.color_func('green', '* ') + i
331 + print(self.color_func('green', '* ') + i, file=self.std_out)
332
333 i = lines[-1]
334
335 @@ -152,8 +153,8 @@ class Message(MessageBase):
336 else:
337 result = '[' + self.color_func('yellow', info) + ']'
338
339 - print >> self.std_out, self.color_func('green', '* ') + i + ' ' + \
340 - '.' * (58 - len(i)) + ' ' + result
341 + print(self.color_func('green', '* ') + i + ' ' + \
342 + '.' * (58 - len(i)) + ' ' + result, file=self.std_out)
343
344
345 def warn (self, warn, level = WARN_LEVEL):
346 @@ -165,7 +166,7 @@ class Message(MessageBase):
347 return
348
349 for i in warn.split('\n'):
350 - print >> self.std_out, self.color_func('yellow', '* ') + i
351 + print(self.color_func('yellow', '* ') + i, file=self.std_out)
352
353
354 def error (self, error):
355 @@ -178,7 +179,7 @@ class Message(MessageBase):
356 # stay in nice order. This is a workaround for calls like
357 # "layman -L |& less".
358 sys.stdout.flush()
359 - print >> self.error_out, self.color_func('red', '* ') + i
360 + print(self.color_func('red', '* ') + i, file=self.error_out)
361 self.error_out.flush()
362 self.do_error_callback(error)
363
364
365 diff --git a/layman/version.py b/layman/version.py
366 index 5d7a73d..02750c5 100644
367 --- a/layman/version.py
368 +++ b/layman/version.py
369 @@ -17,10 +17,12 @@
370 # Sebastian Pipping <sebastian@×××××××.org>
371 #
372
373 +from __future__ import print_function
374 +
375 __version__ = "$Id: version.py 309 2007-04-09 16:23:38Z wrobel $"
376
377
378 VERSION = '1.4.2'
379
380 if __name__ == '__main__':
381 - print VERSION
382 + print(VERSION)