Use the print function everywhere

python modernize.py --no-six -f libmodernize.fixes.fix_print -w

With manual fixes as the import was put always on top.
This commit is contained in:
Laurent Bachelier 2014-10-06 14:23:20 +02:00
commit 74a4ef6723
73 changed files with 499 additions and 442 deletions

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.torrent import CapTorrent, MagnetOnly
from weboob.tools.application.repl import ReplApplication, defaultcount
@ -116,7 +116,7 @@ class Weboorrents(ReplApplication):
"""
torrent = self.get_object(id, 'get_torrent', ('description', 'files'))
if not torrent:
print >>self.stderr, 'Torrent not found: %s' % id
print('Torrent not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@ -141,7 +141,7 @@ class Weboorrents(ReplApplication):
torrent = self.get_object(id, 'get_torrent', ('description', 'files'))
if not torrent:
print >>self.stderr, 'Torrent not found: %s' % id
print('Torrent not found: %s' % id, file=self.stderr)
return 3
dest = self.obj_to_filename(torrent, dest, '{id}-{name}.torrent')
@ -150,26 +150,26 @@ class Weboorrents(ReplApplication):
for backend, buf in self.do('get_torrent_file', torrent.id, backends=torrent.backend):
if buf:
if dest == '-':
print buf
print(buf)
else:
try:
with open(dest, 'w') as f:
f.write(buf)
except IOError as e:
print >>self.stderr, 'Unable to write .torrent in "%s": %s' % (dest, e)
print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
except CallErrors as errors:
for backend, error, backtrace in errors:
if isinstance(error, MagnetOnly):
print >>self.stderr, u'Error(%s): No direct URL available, ' \
print(u'Error(%s): No direct URL available, ' \
u'please provide this magnet URL ' \
u'to your client:\n%s' % (backend, error.magnet)
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
return 4
else:
self.bcall_error_handler(backend, error, backtrace)
print >>self.stderr, 'Torrent "%s" not found' % id
print('Torrent "%s" not found' % id, file=self.stderr)
return 3
@defaultcount(10)