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,6 +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
import hashlib
import sys
@ -92,13 +93,13 @@ class Tile(object):
self.map.append(pxls)
def display(self):
print '-' * (len(self.map) * 2 + 2)
print('-' * (len(self.map) * 2 + 2))
for y in xrange(len(self.map[0])):
sys.stdout.write('|')
for x in xrange(len(self.map)):
sys.stdout.write('%s' % ('XX' if self.map[x][y] else ' '))
print '|'
print '-' * (len(self.map) * 2 + 2)
print('|')
print('-' * (len(self.map) * 2 + 2))
def checksum(self):
s = ''
@ -113,9 +114,9 @@ class Tile(object):
try:
return self.hash[checksum]
except KeyError:
print 'Unable te resolve:'
print('Unable te resolve:')
self.display()
print 'hash: %s' % checksum
print('hash: %s' % checksum)
raise CaptchaError()
@ -175,11 +176,11 @@ class Decoder(object):
checksum = tile.checksum()
if checksum in self.hash:
print 'Skipping %s' % self.hash[checksum]
print('Skipping %s' % self.hash[checksum])
continue
tile.display()
print 'Checksum: %s' % checksum
print('Checksum: %s' % checksum)
ntry = 2
while ntry:
sys.stdout.write('Enter the letter: ')
@ -187,9 +188,9 @@ class Decoder(object):
ntry -= 1
if len(l) != 1:
print 'Error: please enter only one letter'
print('Error: please enter only one letter')
elif l in self.hash.itervalues():
print 'Warning! This letter has already been catched!'
print('Warning! This letter has already been catched!')
else:
ntry = 0
@ -200,13 +201,13 @@ class Decoder(object):
while True:
self.process()
except KeyboardInterrupt:
print ''
print 'hash = {'
print('')
print('hash = {')
l = sorted(self.hash.iteritems(), key=lambda (k,v): (v,k))
for hash, value in l:
print ' \'%s\': %s' % (hash, value)
print(' \'%s\': %s' % (hash, value))
print '}'
print('}')
if __name__ == '__main__':
d = Decoder()

View file

@ -17,6 +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 random import randint
@ -93,7 +94,7 @@ class ProfilesWalker(Optimization):
self.profiles_queue.add(id)
return
except Exception as e:
print e
print(e)
finally:
if self.view_cron is not None:
self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile)

View file

@ -17,6 +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.tools.browser import BrowserUnavailable
from weboob.capabilities.dating import Optimization
@ -45,5 +46,5 @@ class Visibility(Optimization):
with self.browser:
self.browser.login()
except BrowserUnavailable as e:
print str(e)
print(str(e))
pass