summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Dolbec <brian.dolbec@gmail.com>2011-03-26 20:24:26 -0700
committerBrian Dolbec <brian.dolbec@gmail.com>2011-03-26 20:24:26 -0700
commite14906b88ec2da99dba82d565d88ed5ca1d40099 (patch)
tree704b905dc66b6c21bfcfca6d95467bcf8bb650ea
parentd73b5dacce0927e727db5aebb9384a6fd2bb1cd5 (diff)
downloadlayman-e14906b88ec2da99dba82d565d88ed5ca1d40099.tar.gz
layman-e14906b88ec2da99dba82d565d88ed5ca1d40099.tar.bz2
layman-e14906b88ec2da99dba82d565d88ed5ca1d40099.zip
migrate to print()
-rw-r--r--layman/api.py10
-rw-r--r--layman/cli.py22
-rw-r--r--layman/dbbase.py6
-rw-r--r--layman/debug.py59
-rw-r--r--layman/output.py15
-rw-r--r--layman/version.py4
6 files changed, 64 insertions, 52 deletions
diff --git a/layman/api.py b/layman/api.py
index 75d0c10..9dfb1a3 100644
--- a/layman/api.py
+++ b/layman/api.py
@@ -13,6 +13,8 @@
# Brian Dolbec <dol-sen@sourceforge.net>
#
+from __future__ import print_function
+
from sys import stderr
import os
@@ -248,10 +250,10 @@ class LaymanAPI(object):
continue
try:
overlay = db.select(ovl)
- #print "overlay = ", ovl
- #print "!!!", overlay
+ #print("overlay = ", ovl)
+ #print("!!!", overlay)
except UnknownOverlayException, error:
- #print "ERRORS", str(error)
+ #print("ERRORS", str(error))
self._error(error)
result[ovl] = ('', False, False)
else:
@@ -422,7 +424,7 @@ class LaymanAPI(object):
#msg = "Error: %d," % num, message
self._error_messages.append(message)
if self.report_errors:
- print >>stderr, msg
+ print(msg, file=stderr)
def get_errors(self):
diff --git a/layman/cli.py b/layman/cli.py
index 8f94f4a..1187ef2 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -19,6 +19,8 @@
#
''' Provides the command line actions that can be performed by layman.'''
+from __future__ import print_function
+
__version__ = "$Id: cli.py 2011-01-15 23:52 PST Brian Dolbec$"
@@ -48,27 +50,27 @@ class ListPrinter(object):
self.my_lister = self.short_list
def print_shortdict(self, info, complain):
- #print "ListPrinter.print_shortdict()",info, "\n\n"
+ #print("ListPrinter.print_shortdict()",info, "\n\n")
overlays = sorted(info)
- #print "ids =======>", overlays, "\n"
+ #print("ids =======>", overlays, "\n")
for ovl in overlays:
overlay = info[ovl]
- #print "overlay =", overlay
+ #print("overlay =", overlay)
summary, supported, official = overlay
self.print_overlay(summary, supported, official, complain)
def print_shortlist(self, info, complain):
- #print "ListPrinter.print_shortlist()",info
+ #print("ListPrinter.print_shortlist()",info)
for summary, supported, official in info:
self.print_overlay(summary, supported, official, complain)
def print_fulldict(self, info, complain):
ids = sorted(info)
- #print "ids =======>", ids, "\n"
+ #print("ids =======>", ids, "\n")
for ovl in ids:
overlay = info[ovl]
- #print overlay
+ #print(overlay)
self.print_overlay(self.my_lister(overlay),
overlay['supported'],
overlay['official'],
@@ -101,7 +103,7 @@ class ListPrinter(object):
def short_list(self, overlay):
'''
- >>> print short_list(overlay)
+ >>> print(short_list(overlay))
wrobel [Subversion] (https://o.g.o/svn/dev/wrobel )
'''
name = pad(overlay['name'], 25)
@@ -127,7 +129,7 @@ class Main(object):
def __init__(self, config):
self.config = config
- #print "config.keys()", config.keys()
+ #print("config.keys()", config.keys())
self.output = config['output']
self.api = LaymanAPI(config,
report_errors=True,
@@ -260,7 +262,7 @@ class Main(object):
info = self.api.get_info_str(selection, local=False,
verbose=True, width=list_printer.width)
- #print "info =", info
+ #print("info =", info)
list_printer.print_shortdict(info, complain=_complain)
return info != {}
@@ -284,7 +286,7 @@ class Main(object):
def ListLocal(self):
''' Lists the local overlays.
'''
- #print "ListLocal()"
+ #print("ListLocal()")
self.output.debug('Printing installed overlays.', 6)
list_printer = ListPrinter(self.config)
diff --git a/layman/dbbase.py b/layman/dbbase.py
index 776a90f..02aeb9d 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -20,6 +20,8 @@
#
'''Main handler for overlays.'''
+from __future__ import print_function
+
__version__ = "$Id: overlay.py 273 2006-12-30 15:54:50Z wrobel $"
#===============================================================================
@@ -240,7 +242,7 @@ class DbBase:
>>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
>>> a = DbBase([here + '/tests/testfiles/global-overlays.xml', ], config)
>>> for i in a.list(True):
- ... print i[0]
+ ... print(i[0])
wrobel
~~~~~~
Source : https://overlays.gentoo.org/svn/dev/wrobel
@@ -263,7 +265,7 @@ class DbBase:
<BLANKLINE>
>>> for i in a.list(False, 80):
- ... print i[0]
+ ... print(i[0])
wrobel [Subversion] (https://o.g.o/svn/dev/wrobel )
wrobel-stable [Rsync ] (rsync://gunnarwrobel.de/wrobel-stable)
'''
diff --git a/layman/debug.py b/layman/debug.py
index f5c247b..ab04f40 100644
--- a/layman/debug.py
+++ b/layman/debug.py
@@ -6,6 +6,8 @@
# Copyright 2005 - 2008 Gunnar Wrobel
# Distributed under the terms of the GNU General Public License v2
+from __future__ import print_function
+
__version__ = "$Id: debug.py 153 2006-06-05 06:03:16Z wrobel $"
#################################################################################
@@ -101,7 +103,7 @@ class DebugMessage(Message):
def cli_opts(self, parser):
- #print "Parsing debug opts"
+ #print("Parsing debug opts")
group = OptionGroup(parser,
'<Debugging options>',
@@ -327,11 +329,11 @@ class DebugMessage(Message):
if lines > 0:
for j in range(lines):
## Print line with continuation marker
- print >> self.debug_out, ls + '// ' + x[0:60] + ' \\'
+ print(ls + '// ' + x[0:60] + ' \\', file=self.debug_out)
## Remove printed characters from output
x = x[60:]
## Print final line
- print >> self.debug_out, ls + '// ' + x
+ print(ls + '// ' + x, file=self.debug_out)
if self.debug_vrb == 1:
# Top line indicates class and method
@@ -340,60 +342,61 @@ class DebugMessage(Message):
c += 'Class: ' + str(callerobject.__class__.__name__) + ' | '
if callermethod:
c += 'Method: ' + str(callermethod)
- print >> self.debug_out, '// ' + c
+ print('// ' + c, file=self.debug_out)
# Selected variables follow
if callerlocals:
for i,j in callerlocals.items():
- print >> self.debug_out, '// ' \
- + self.maybe_color('turquoise', str(i)) + ':' + str(j)
+ print('// ' + self.maybe_color('turquoise',
+ str(i)) + ':' + str(j), file=self.debug_out)
# Finally the message
- print >> self.debug_out, self.maybe_color('yellow', message)
+ print(self.maybe_color('yellow', message), file=self.debug_out)
return
if self.debug_vrb == 3:
- print >> self.debug_out, ls + '/////////////////////////////////' + \
- '////////////////////////////////'
+ print(ls + '/////////////////////////////////' + \
+ '////////////////////////////////', file=self.debug_out)
# General information about what is being debugged
#(module name or similar)
- print >> self.debug_out, ls + '// ' + self.debug_env
- print >> self.debug_out, ls + '//-----------------------------------' + \
- '----------------------------'
+ print(ls + '// ' + self.debug_env, file=self.debug_out)
+ print(ls + '//-----------------------------------' + \
+ '----------------------------', file=self.debug_out)
## If the caller is a class print the name here
if callerobject:
- print >> self.debug_out, ls + \
- '// Object Class: ' + str(callerobject.__class__.__name__)
+ print(ls + '// Object Class: ' +
+ str(callerobject.__class__.__name__), file=self.debug_out)
## If the method has been extracted print it here
if callermethod:
- print >> self.debug_out, ls + '// ' \
- + self.maybe_color('green', 'Method: ') + str(callermethod)
+ print(ls + '// ' + self.maybe_color('green', 'Method: ')
+ + str(callermethod), file=self.debug_out)
if self.debug_vrb == 3:
- print >> self.debug_out, ls + '//---------------------------' + \
- '------------------------------------'
+ print(ls + '//---------------------------' + \
+ '------------------------------------', file=self.debug_out)
## Print the information on all available local variables
if callerlocals:
if self.debug_vrb == 3:
- print >> self.debug_out, ls + '//'
- print >> self.debug_out, ls + '// VALUES '
+ print(ls + '//', file=self.debug_out)
+ print(ls + '// VALUES ', file=self.debug_out)
for i,j in callerlocals.items():
- print >> self.debug_out, ls + '// ------------------> ' \
- + self.maybe_color('turquoise', str(i)) + ':'
+ print(ls + '// ------------------> ' \
+ + self.maybe_color('turquoise', str(i)) + ':',
+ file=self.debug_out)
breaklines(str(j))
if self.debug_vrb == 3:
- print >> self.debug_out, ls + '//------------------------------'\
- '---------------------------------'
+ print(ls + '//------------------------------'\
+ '---------------------------------', file=self.debug_out)
# Finally print the message
breaklines(self.maybe_color('yellow', message))
if self.debug_vrb == 3:
- print >> self.debug_out, ls + '//-------------------------------' + \
- '--------------------------------'
- print >> self.debug_out, ls + '/////////////////////////////////' + \
- '////////////////////////////////'
+ print(ls + '//-------------------------------' + \
+ '--------------------------------', file=self.debug_out)
+ print(ls + '/////////////////////////////////' + \
+ '////////////////////////////////', file=self.debug_out)
## gloabal message handler
OUT = Message('layman')
diff --git a/layman/output.py b/layman/output.py
index 469f673..caccd93 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -6,6 +6,7 @@
Distributed under the terms of the GNU General Public License v2
"""
+from __future__ import print_function
__version__ = "0.1"
@@ -112,7 +113,7 @@ class Message(MessageBase):
def notice (self, note):
- print >> self.std_out, note
+ print(note, file=self.std_out)
def info (self, info, level = INFO_LEVEL):
@@ -124,7 +125,7 @@ class Message(MessageBase):
return
for i in info.split('\n'):
- print >> self.std_out, self.color_func('green', '* ') + i
+ print(self.color_func('green', '* ') + i, file=self.std_out)
def status (self, message, status, info = 'ignored'):
@@ -138,7 +139,7 @@ class Message(MessageBase):
return
for i in lines[0:-1]:
- print >> self.std_out, self.color_func('green', '* ') + i
+ print(self.color_func('green', '* ') + i, file=self.std_out)
i = lines[-1]
@@ -152,8 +153,8 @@ class Message(MessageBase):
else:
result = '[' + self.color_func('yellow', info) + ']'
- print >> self.std_out, self.color_func('green', '* ') + i + ' ' + \
- '.' * (58 - len(i)) + ' ' + result
+ print(self.color_func('green', '* ') + i + ' ' + \
+ '.' * (58 - len(i)) + ' ' + result, file=self.std_out)
def warn (self, warn, level = WARN_LEVEL):
@@ -165,7 +166,7 @@ class Message(MessageBase):
return
for i in warn.split('\n'):
- print >> self.std_out, self.color_func('yellow', '* ') + i
+ print(self.color_func('yellow', '* ') + i, file=self.std_out)
def error (self, error):
@@ -178,7 +179,7 @@ class Message(MessageBase):
# stay in nice order. This is a workaround for calls like
# "layman -L |& less".
sys.stdout.flush()
- print >> self.error_out, self.color_func('red', '* ') + i
+ print(self.color_func('red', '* ') + i, file=self.error_out)
self.error_out.flush()
self.do_error_callback(error)
diff --git a/layman/version.py b/layman/version.py
index 5d7a73d..02750c5 100644
--- a/layman/version.py
+++ b/layman/version.py
@@ -17,10 +17,12 @@
# Sebastian Pipping <sebastian@pipping.org>
#
+from __future__ import print_function
+
__version__ = "$Id: version.py 309 2007-04-09 16:23:38Z wrobel $"
VERSION = '1.4.2'
if __name__ == '__main__':
- print VERSION
+ print(VERSION)