diff --git a/contrib/boobot.py b/contrib/boobot.py
index 6b6cc08cf49f34a550a61548caaad9ab550f715e..f01de7e3377ef83de9740d6d9b4fd18f615b94bf 100755
--- a/contrib/boobot.py
+++ b/contrib/boobot.py
@@ -18,6 +18,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from datetime import datetime, timedelta
import logging
@@ -138,7 +139,7 @@ def urlinfo(self, url, maxback=2):
# meta charset=...
encoding = meta.attrib.get('charset', encoding).lower()
except Exception as e:
- print e
+ print(e)
finally:
r.seek(0)
if encoding == 'iso-8859-1' or not encoding:
@@ -159,7 +160,7 @@ def urlinfo(self, url, maxback=2):
title = ' '.join(title.splitlines())
except AssertionError as e:
# invalid HTML
- print e
+ print(e)
return content_type, hsize, title
@@ -377,7 +378,7 @@ def on_boobid(self, boobid):
for msg in getattr(self, func)(backend, _id):
yield msg
except Exception as e:
- print get_backtrace()
+ print(get_backtrace())
yield u'Oops: [%s] %s' % (type(e).__name__, e)
break
@@ -394,7 +395,7 @@ def on_url(self, url):
except BrowserUnavailable as e:
yield u'URL (error): %s' % e
except Exception as e:
- print get_backtrace()
+ print(get_backtrace())
yield u'Oops: [%s] %s' % (type(e).__name__, e)
def obj_info_video(self, backend, id):
@@ -418,7 +419,7 @@ def main():
try:
bot.start()
except KeyboardInterrupt:
- print "Stopped."
+ print("Stopped.")
thread.stop()
diff --git a/contrib/downloadboob/downloadboob.py b/contrib/downloadboob/downloadboob.py
index 27df16b3908d017b578ed274d50df7e1974455df..4ccb4ebc5640a42eb96c6cd1261c549e63e295bc 100755
--- a/contrib/downloadboob/downloadboob.py
+++ b/contrib/downloadboob/downloadboob.py
@@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
import subprocess
import os
import re
@@ -69,10 +71,10 @@ def purge(self):
for local_link_name in dirList:
link_name = self.links_directory + "/" + local_link_name
if not self.check_link(link_name):
- print u"Remove %s" % link_name
+ print(u"Remove %s" % link_name)
os.remove(link_name)
else:
- print u"Keep %s" % link_name
+ print(u"Keep %s" % link_name)
def check_link(self, link_name):
if os.path.islink(link_name):
@@ -85,10 +87,10 @@ def check_link(self, link_name):
return True
def download(self, pattern=None, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None, title_exclude=[], id_regexp=None):
- print "For backend %s, search for '%s'" % (backend_name, pattern)
+ print("For backend %s, search for '%s'" % (backend_name, pattern))
# create directory for links
- print " create link to %s" % self.links_directory
+ print(" create link to %s" % self.links_directory)
if not os.path.isdir(self.links_directory):
os.makedirs(self.links_directory)
@@ -101,17 +103,17 @@ def download(self, pattern=None, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False, m
if not self.is_downloaded(video):
self.backend.fill_video(video, ('url','title', 'url', 'duration'))
if not(self.is_excluded(video.title, title_exclude)) and self.id_regexp_matched(video.id, id_regexp):
- print " %s\n Id:%s\n Duration:%s" % (video.title, video.id, video.duration)
+ print(" %s\n Id:%s\n Duration:%s" % (video.title, video.id, video.duration))
videos.append(video)
else:
- print "Already downloaded, check %s" % video.id
+ print("Already downloaded, check %s" % video.id)
self.backend.fill_video(video, ('url','title', 'url', 'duration'))
linkname = self.get_linkname(video)
if not os.path.exists(linkname):
self.remove_download(video)
# download videos
- print "Downloading..."
+ print("Downloading...")
for video in videos:
self.do_download(video)
@@ -164,7 +166,7 @@ def remove_download(self, video):
# already empty
return
- print 'Remove video %s' % video.title
+ print('Remove video %s' % video.title)
# Empty it to keep information we have already downloaded it.
with open(path, 'w'):
@@ -175,23 +177,23 @@ def set_linkname(self, video):
idname = self.get_filename(video, relative=True)
absolute_idname = self.get_filename(video, relative=False)
if not os.path.islink(linkname) and os.path.isfile(absolute_idname):
- print "%s -> %s" % (linkname, idname)
+ print("%s -> %s" % (linkname, idname))
os.symlink(idname, linkname)
def do_download(self, video):
if not video:
- print >>sys.stderr, 'Video not found: %s' % video
+ print('Video not found: %s' % video, file=sys.stderr)
return 3
if not video.url:
- print >>sys.stderr, 'Error: the direct URL is not available.'
+ print('Error: the direct URL is not available.', file=sys.stderr)
return 4
def check_exec(executable):
with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0:
- print >>sys.stderr, 'Please install "%s"' % executable
+ print('Please install "%s"' % executable, file=sys.stderr)
return False
return True
@@ -220,14 +222,14 @@ def check_exec(executable):
try:
links_directory=os.path.expanduser(config.get('main','directory', '.'))
except ConfigParser.NoSectionError:
- print "Please create a documentation file (see the README file and the downloadboob.conf example file)"
+ print("Please create a documentation file (see the README file and the downloadboob.conf example file)")
sys.exit(2)
links_directory=links_directory.decode('utf-8')
download_directory=os.path.join(links_directory, DOWNLOAD_DIRECTORY)
-print "Downloading to %s" % (links_directory)
+print("Downloading to %s" % (links_directory))
for section in config.sections():
if section != "main":
diff --git a/contrib/hds/export.py b/contrib/hds/export.py
index b8a860c624fdb7b4d17708e828cbef9f5864efb0..5e3244955bb9fc0f9badf4a44d8e16f1c878b1f9 100755
--- a/contrib/hds/export.py
+++ b/contrib/hds/export.py
@@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
try:
import sqlite3 as sqlite
except ImportError as e:
@@ -36,13 +38,13 @@ def main(filename):
try:
hds = weboob.build_backend('hds')
except ModuleLoadError as e:
- print >>sys.stderr, 'Unable to load "hds" module: %s' % e
+ print('Unable to load "hds" module: %s' % e, file=sys.stderr)
return 1
try:
db = sqlite.connect(database=filename, timeout=10.0)
except sqlite.OperationalError as err:
- print >>sys.stderr, 'Unable to open %s database: %s' % (filename, err)
+ print('Unable to open %s database: %s' % (filename, err), file=sys.stderr)
return 1
sys.stdout.write('Reading database... ')
@@ -50,7 +52,7 @@ def main(filename):
try:
results = db.execute('SELECT id, author FROM stories')
except sqlite.OperationalError as err:
- print >>sys.stderr, 'fail!\nUnable to read database: %s' % err
+ print('fail!\nUnable to read database: %s' % err, file=sys.stderr)
return 1
stored = set()
@@ -104,33 +106,33 @@ def main(filename):
if __name__ == '__main__':
if len(sys.argv) < 2:
- print >>sys.stderr, 'Syntax: %s [--help] SQLITE_FILENAME' % sys.argv[0]
+ print('Syntax: %s [--help] SQLITE_FILENAME' % sys.argv[0], file=sys.stderr)
sys.exit(1)
if sys.argv[1] in ('-h', '--help'):
- print 'Syntax: %s SQLITE_FILENAME' % sys.argv[0]
- print ''
- print 'Before running this software, please create the database with'
- print 'this command:'
- print ' $ cat scheme.sql | sqlite3 hds.sql'
- print ''
- print 'You can then run export.py with:'
- print ' $ %s hds.sql ' % sys.argv[0]
- print ''
- print 'It fill the database with stories and authors information'
- print 'fetched from histoires-de-sexe.net'
- print ''
- print 'You can next use SQL queries to find interesting stories, for'
- print 'example:'
- print ''
- print '- To get all stories written by women'
- print ' sqlite> SELECT s.id, s.title, s.category, a.name'
- print ' FROM stories AS s LEFT JOIN authors AS a'
- print ' WHERE a.name = s.author AND a.sex = 2;'
- print '- To get all stories where it talks about bukkake'
- print ' sqlite> SELECT s.id, s.title, s.category, a.name'
- print ' FROM stories AS s LEFT JOIN authors AS a'
- print ' WHERE a.name = s.author AND s.body LIKE \'%bukkake%\';'
+ print('Syntax: %s SQLITE_FILENAME' % sys.argv[0])
+ print('')
+ print('Before running this software, please create the database with')
+ print('this command:')
+ print(' $ cat scheme.sql | sqlite3 hds.sql')
+ print('')
+ print('You can then run export.py with:')
+ print(' $ %s hds.sql ' % sys.argv[0])
+ print('')
+ print('It fill the database with stories and authors information')
+ print('fetched from histoires-de-sexe.net')
+ print('')
+ print('You can next use SQL queries to find interesting stories, for')
+ print('example:')
+ print('')
+ print('- To get all stories written by women')
+ print(' sqlite> SELECT s.id, s.title, s.category, a.name')
+ print(' FROM stories AS s LEFT JOIN authors AS a')
+ print(' WHERE a.name = s.author AND a.sex = 2;')
+ print('- To get all stories where it talks about bukkake')
+ print(' sqlite> SELECT s.id, s.title, s.category, a.name')
+ print(' FROM stories AS s LEFT JOIN authors AS a')
+ print(' WHERE a.name = s.author AND s.body LIKE \'%bukkake%\';')
sys.exit(0)
sys.exit(main(sys.argv[1]))
diff --git a/contrib/plugin.video.videoobmc/default_test.py b/contrib/plugin.video.videoobmc/default_test.py
index f045c825406611b97f92732d800882efb97e8bde..c8b712fda660f4cac922174a69be54a1808affe0 100755
--- a/contrib/plugin.video.videoobmc/default_test.py
+++ b/contrib/plugin.video.videoobmc/default_test.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
+from __future__ import print_function
import sys
import resources.lib.test.common_test as common_xbmc
@@ -7,7 +8,7 @@
from resources.lib.actions import actions
-print sys.argv
+print(sys.argv)
if len(sys.argv) < 2:
actions[constants.DISPLAY_MENU]()._do()
else:
diff --git a/contrib/plugin.video.videoobmc/resources/lib/actions.py b/contrib/plugin.video.videoobmc/resources/lib/actions.py
index 63949c4388af84fb0a68222518dd7b11ce20fac4..10382c74779bb46b8b60fb00002f9f8ddfa66b90 100644
--- a/contrib/plugin.video.videoobmc/resources/lib/actions.py
+++ b/contrib/plugin.video.videoobmc/resources/lib/actions.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from __future__ import print_function
import sys
from . import constants
@@ -52,7 +53,7 @@ def _do(self, param={}):
common_xbmc.end_of_directory(False)
def add_videos(self, _video, backend):
- print _video
+ print(_video)
video = self.videoobmc.get_video(_video, backend)
if video:
MenuItemVideo(video).add_to_menu()
diff --git a/contrib/plugin.video.videoobmc/resources/lib/base/common_xbmc.py b/contrib/plugin.video.videoobmc/resources/lib/base/common_xbmc.py
index 5dce9c5471aca815ff3efeaf12dbd07b2782cef8..75948a4d5fddad88a2b2ef4526e5a495e39cdbd2 100644
--- a/contrib/plugin.video.videoobmc/resources/lib/base/common_xbmc.py
+++ b/contrib/plugin.video.videoobmc/resources/lib/base/common_xbmc.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from __future__ import print_function
import xbmc
import xbmcgui
@@ -41,7 +42,7 @@ def get_addon_dir():
def display_error(msg):
xbmc.executebuiltin("XBMC.Notification(%s, %s)" % (get_translation('30200').decode('utf-8'), msg))
- print msg
+ print(msg)
print_exc(msg)
diff --git a/contrib/plugin.video.videoobmc/resources/lib/base/weboobmc2.py b/contrib/plugin.video.videoobmc/resources/lib/base/weboobmc2.py
index 16cc498366ae2c8c9b674045f82b37c2eda2bdf4..a1eeb41c883ecfd08f38c874203c22691dbc90b4 100644
--- a/contrib/plugin.video.videoobmc/resources/lib/base/weboobmc2.py
+++ b/contrib/plugin.video.videoobmc/resources/lib/base/weboobmc2.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
+from __future__ import print_function
from weboob.tools.application.base import Application
import os
@@ -53,7 +54,7 @@ def check_exec(executable):
with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0:
- print 'Please install "%s"' % executable
+ print('Please install "%s"' % executable)
return False
return True
diff --git a/contrib/plugin.video.videoobmc/resources/lib/test/common_test.py b/contrib/plugin.video.videoobmc/resources/lib/test/common_test.py
index 0da8c54ca1ebe743658b194ed8c467c039d2cbf3..4e74fef301fa92fb2d339649bfba4ac8a2151f3d 100644
--- a/contrib/plugin.video.videoobmc/resources/lib/test/common_test.py
+++ b/contrib/plugin.video.videoobmc/resources/lib/test/common_test.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from __future__ import print_function
import urllib
@@ -33,11 +34,11 @@ def get_settings(key):
def display_error(error):
- print "%s: %s" % ("ERROR", error)
+ print("%s: %s" % ("ERROR", error))
def display_info(msg):
- print "%s: %s" % ("INFO", msg)
+ print("%s: %s" % ("INFO", msg))
def parse_params(paramStr):
@@ -93,18 +94,18 @@ def create_param_url(paramsDic, quote_plus=False):
def add_menu_item(params={}):
- print '%s => "%s"' % (params.get('name'), create_param_url(params))
+ print('%s => "%s"' % (params.get('name'), create_param_url(params)))
def add_menu_link(params={}):
- print '[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url'))
+ print('[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url')))
#print params.get('itemInfoLabels')
#print params.get('c_items')
def end_of_directory(update=False):
- print '******************************************************'
+ print('******************************************************')
def download_video(url, name, dir='./'):
- print 'Downlaod a video %s from %s' % (name, url)
+ print('Downlaod a video %s from %s' % (name, url))
diff --git a/contrib/plugin.video.videoobmc/resources/lib/videoobmc2.py b/contrib/plugin.video.videoobmc/resources/lib/videoobmc2.py
index 1f98ff76f9d6c06213cba45e567feec88332c518..e7f9130c06ab90624fa0493f5d8c8f7de81c8f6a 100644
--- a/contrib/plugin.video.videoobmc/resources/lib/videoobmc2.py
+++ b/contrib/plugin.video.videoobmc/resources/lib/videoobmc2.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
+from __future__ import print_function
from .base.weboobmc2 import Weboobmc
from weboob.capabilities.video import BaseVideo, CapVideo
@@ -22,7 +23,7 @@ def search(self, pattern, backend=''):
for _backend, video in self.weboob.do(self._do_complete, self.count, fields, 'search_videos', **kwargs):
yield video
except Exception as e:
- print e
+ print(e)
def get_video(self, video, _backend):
backend = self.weboob.get_backend(_backend)
diff --git a/contrib/videoob_web/videoob_web/videoob_web.py b/contrib/videoob_web/videoob_web/videoob_web.py
index f0f56fec2f64d6eeb2025db5186d0cdbb72ae918..ab0445893b6a4ec78e59955ec5499b09355c14f6 100644
--- a/contrib/videoob_web/videoob_web/videoob_web.py
+++ b/contrib/videoob_web/videoob_web/videoob_web.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import os
@@ -79,8 +80,8 @@ def make_app(self, req):
def main(self, argv):
self.load_config()
self.weboob.load_backends(CapVideo)
- print 'Web server created. Listening on http://%s:%s' % (
- self.config.get('host'), int(self.config.get('port')))
+ print('Web server created. Listening on http://%s:%s' % (
+ self.config.get('host'), int(self.config.get('port'))))
srv = make_server(self.config.get('host'), int(self.config.get('port')), self.make_app)
srv.serve_forever()
diff --git a/modules/aum/captcha.py b/modules/aum/captcha.py
index f02bef3e173844c61d37641c84c830d01b902a50..68b9a95f79974094b9b23ed15d5c2c85adcceefa 100644
--- a/modules/aum/captcha.py
+++ b/modules/aum/captcha.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import hashlib
import sys
@@ -92,13 +93,13 @@ def append(self, pxls):
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 @@ def letter(self):
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 @@ def process(self):
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 @@ def process(self):
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 @@ def main(self):
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()
diff --git a/modules/aum/optim/profiles_walker.py b/modules/aum/optim/profiles_walker.py
index 03d22e1d626e1ba8450ca7795270672c18618049..26bac996690ac6cc1215bfa76d8cb751a37f4dff 100644
--- a/modules/aum/optim/profiles_walker.py
+++ b/modules/aum/optim/profiles_walker.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from random import randint
@@ -93,7 +94,7 @@ def view_profile(self):
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)
diff --git a/modules/aum/optim/visibility.py b/modules/aum/optim/visibility.py
index b3fbceb69754aee7f9c8358611aa6a8828e128f0..da9c407c8cf14c97a71024a53deee90952d56dde 100644
--- a/modules/aum/optim/visibility.py
+++ b/modules/aum/optim/visibility.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from weboob.tools.browser import BrowserUnavailable
from weboob.capabilities.dating import Optimization
@@ -45,5 +46,5 @@ def reconnect(self):
with self.browser:
self.browser.login()
except BrowserUnavailable as e:
- print str(e)
+ print(str(e))
pass
diff --git a/modules/boursorama/pages/two_authentication.py b/modules/boursorama/pages/two_authentication.py
index 0fe861489c368485eb66947fcf396fe9e178539c..33bc97d2172e370c344a36576bd30cf2c7ab9ce9 100644
--- a/modules/boursorama/pages/two_authentication.py
+++ b/modules/boursorama/pages/two_authentication.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from weboob.tools.browser import Page, BrowserIncorrectPassword
import urllib2
@@ -121,4 +122,4 @@ def authenticate(self, device):
def print_cookies(self):
for c in self.browser._ua_handlers["_cookies"].cookiejar:
- print "%s : %s" % (c.name, c.value)
+ print("%s : %s" % (c.name, c.value))
diff --git a/modules/cragr/web/pages.py b/modules/cragr/web/pages.py
index c8b67189f72c2a562f1b1457d88ce62cce770bec..5971b0f191e4665ce59fda4c588f2fa701335c5a 100644
--- a/modules/cragr/web/pages.py
+++ b/modules/cragr/web/pages.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
import re
from decimal import Decimal
@@ -217,8 +219,8 @@ def get_history(self, date_guesser):
try:
t.id = t.unique_id(seen)
except UnicodeEncodeError:
- print t
- print t.label
+ print(t)
+ print(t.label)
raise
yield t
diff --git a/modules/europarl/pages.py b/modules/europarl/pages.py
index 4b711275f2f242ff837d9957770b113bf2408dcb..f6f832721a20a15f3d007d9a38bb81c5a8cad2a3 100644
--- a/modules/europarl/pages.py
+++ b/modules/europarl/pages.py
@@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
from weboob.tools.mech import ClientForm
ControlNotFoundError = ClientForm.ControlNotFoundError
@@ -73,7 +75,7 @@ def set_details(self, v):
obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1)
if obj is not None:
value = obj.attrib['content']
- print value
+ print(value)
m = re.match('(\d\d)-(\d\d)-(\d\d\d\d)\s*(\d\d):(\d\d)', value)
if not m:
raise BrokenPageError('Unable to parse datetime: %r' % value)
diff --git a/modules/gdcvault/browser.py b/modules/gdcvault/browser.py
index cb1180e9ec827d95e65ff250a26273c8618aa7be..25987cc27d50d402c72a7df583f79694fd348078 100644
--- a/modules/gdcvault/browser.py
+++ b/modules/gdcvault/browser.py
@@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
import urllib
from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\
@@ -149,7 +151,7 @@ def search_videos(self, pattern, sortby):
return self.page.iter_videos()
def latest_videos(self):
- print "browser:latest_videos()"
+ print("browser:latest_videos()")
#self.home()
self.location('/free')
assert self.is_on_page(IndexPage)
diff --git a/modules/hellobank/browser.py b/modules/hellobank/browser.py
index 3897192e897f63279545e3928a6851f9247c250d..f9a638154c62486a8ff8d20e66569e34659ffe81 100644
--- a/modules/hellobank/browser.py
+++ b/modules/hellobank/browser.py
@@ -18,6 +18,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import urllib
import mechanize
@@ -85,7 +86,7 @@ def get_accounts_list(self):
accounts = self.page.get_accounts()
if len(accounts) == 0:
- print 'no accounts'
+ print('no accounts')
# oops, no accounts? check if we have not exhausted the allowed use
# of this password
for img in self.document.getroot().cssselect('img[align="middle"]'):
diff --git a/modules/hellobank/perso/accounts_list.py b/modules/hellobank/perso/accounts_list.py
index 1284b310f1b00647a0ebbfb98cabce3baae4e847..08d0fd32fbd0679a7c2efbc720f32ec9a88f183b 100644
--- a/modules/hellobank/perso/accounts_list.py
+++ b/modules/hellobank/perso/accounts_list.py
@@ -18,6 +18,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from decimal import Decimal
@@ -66,7 +67,7 @@ def get_list(self, accounts_ids):
l.append(account)
if len(l) == 0:
- print 'no accounts'
+ print('no accounts')
# oops, no accounts? check if we have not exhausted the allowed use
# of this password
for img in self.document.getroot().cssselect('img[align="middle"]'):
diff --git a/modules/okc/optim/profiles_walker.py b/modules/okc/optim/profiles_walker.py
index 0f3c60ce1ef9f886574c12e7265fb363bfa1cf98..c6eaa2cf906f9371d6dca08fc40923cf074b1efc 100644
--- a/modules/okc/optim/profiles_walker.py
+++ b/modules/okc/optim/profiles_walker.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from random import randint
@@ -100,7 +101,7 @@ def view_profile(self):
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)
diff --git a/modules/societegenerale/captcha.py b/modules/societegenerale/captcha.py
index 57b0edd214117dc006bbb844a5535dcbad88a0f9..7e5178c7a91524156cfe830d25ce46e43cc29dc1 100644
--- a/modules/societegenerale/captcha.py
+++ b/modules/societegenerale/captcha.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import hashlib
@@ -133,7 +134,7 @@ def get_num(self):
raise TileError('Tile not found ' + sum, self)
def display(self):
- print self.checksum()
+ print(self.checksum())
#im = Image.new('RGB', (24, 23))
#im.putdata(self.map)
#im.save('/tmp/%s.png' % self.checksum())
diff --git a/modules/transilien/pages.py b/modules/transilien/pages.py
index 064731b8eeb39e4863699c46b63bc08ee050e370..6fdadc99f38dda2fe88b607f230ab887159ef040 100644
--- a/modules/transilien/pages.py
+++ b/modules/transilien/pages.py
@@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
import re
from weboob.browser2.page import JsonPage, HTMLPage, method
@@ -142,7 +144,7 @@ def get_departures(self, arrival, date):
form['moiHoraire'] = '%s|%s' % (date.month, date.year)
form['heureHoraire'] = date.hour
form['minuteHoraire'] = date.minute
- print form
+ print(form)
form.submit()
diff --git a/tools/boilerplate.py b/tools/boilerplate.py
index db71ea05a891f71069e69165f0800a10733f6952..23d8bb0e6a478fd86716de4491723805f25f2ce4 100755
--- a/tools/boilerplate.py
+++ b/tools/boilerplate.py
@@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
import argparse
import subprocess
import datetime
@@ -50,11 +52,11 @@ def write(target, contents):
if not os.path.isdir(os.path.dirname(target)):
os.makedirs(os.path.dirname(target))
if os.path.exists(target):
- print >>sys.stderr, "%s already exists." % target
+ print("%s already exists." % target, file=sys.stderr)
sys.exit(4)
with codecs.open(target, mode='w', encoding='utf-8') as f:
f.write(contents)
- print 'Created %s' % target
+ print('Created %s' % target)
class Recipe(object):
@@ -156,7 +158,7 @@ def search_cap(self):
self.error('Capability %r not found' % self.capname)
def error(self, message):
- print >>sys.stderr, message
+ print(message, file=sys.stderr)
sys.exit(1)
def methods_code(self, klass):
diff --git a/tools/certhash.py b/tools/certhash.py
index b56542b5540310ed74f0cf45edeaecd61484c32b..219c3249695231f9383a0118015adb8d6b6785e9 100755
--- a/tools/certhash.py
+++ b/tools/certhash.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
import sys
from weboob.tools.browser import StandardBrowser
-print StandardBrowser()._certhash(sys.argv[1])
+print(StandardBrowser()._certhash(sys.argv[1]))
diff --git a/tools/debpydep.py b/tools/debpydep.py
index 71076160f1d30037f990d1e56c138f40acffa93a..3df79ce5c454d02dd7d9a601de0d22b7ac16f3ed 100755
--- a/tools/debpydep.py
+++ b/tools/debpydep.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import print_function
import os
import subprocess
@@ -15,7 +16,7 @@
try:
exec(s)
except ImportError as e:
- print >>sys.stderr, str(e)
+ print(str(e), file=sys.stderr)
else:
m = eval(f[:-3])
for attrname in dir(m):
@@ -36,7 +37,7 @@
for line in p.stdout.readlines():
dependencies.add(line.strip().split(':')[0])
else:
- print 'not found: %s' % f
+ print('not found: %s' % f)
for d in dependencies:
- print d
+ print(d)
diff --git a/tools/local_install.py b/tools/local_install.py
index a7a336efc1f603f68584bdf12b2e3ad81fa695ae..59693f39ebc4290953253001bf7fde49b1c1190a 100644
--- a/tools/local_install.py
+++ b/tools/local_install.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import print_function
+
import subprocess
import sys
import os
@@ -10,26 +12,26 @@
else:
deps = ['--nodeps']
-print "Weboob local installer"
-print
+print("Weboob local installer")
+print()
if len(sys.argv) < 2:
- print "This tool will install Weboob to be usuable without requiring"
- print "messing with your system, which should only be touched by a package manager."
- print
- print "Usage: %s DESTINATION [OPTIONS]" % sys.argv[0]
- print
- print "By default, no dependencies are installed, as you should try"
- print "to install them from your package manager as much as possible."
- print "To install all the missing dependencies, add the option --deps"
- print "at the end of the command line."
- print
- print >>sys.stderr, "Error: Please provide a destination, " \
- "for example ‘%s/bin’" % os.getenv('HOME')
+ print("This tool will install Weboob to be usuable without requiring")
+ print("messing with your system, which should only be touched by a package manager.")
+ print()
+ print("Usage: %s DESTINATION [OPTIONS]" % sys.argv[0])
+ print()
+ print("By default, no dependencies are installed, as you should try")
+ print("to install them from your package manager as much as possible.")
+ print("To install all the missing dependencies, add the option --deps")
+ print("at the end of the command line.")
+ print()
+ print("Error: Please provide a destination, " \
+ "for example ‘%s/bin’" % os.getenv('HOME'), file=sys.stderr)
sys.exit(1)
else:
dest = os.path.expanduser(sys.argv[1])
-print "Installing weboob applications into ‘%s’." % dest
+print("Installing weboob applications into ‘%s’." % dest)
subprocess.check_call(
[sys.executable, 'setup.py',
@@ -38,11 +40,11 @@
subprocess.check_call([sys.executable, os.path.join(dest, 'weboob-config'), 'update'])
-print
-print "Installation done. Applications are available in ‘%s’." % dest
-print "You can remove the source files."
-print
-print "To have easy access to the Weboob applications,"
-print "you should add the following line to your ~/.bashrc or ~/.zshrc file:"
-print "export PATH=\"$PATH:%s\"" % dest
-print "And then restart your shells."
+print()
+print("Installation done. Applications are available in ‘%s’." % dest)
+print("You can remove the source files.")
+print()
+print("To have easy access to the Weboob applications,")
+print("you should add the following line to your ~/.bashrc or ~/.zshrc file:")
+print("export PATH=\"$PATH:%s\"" % dest)
+print("And then restart your shells.")
diff --git a/tools/local_run.py b/tools/local_run.py
index c3748a16d03c64d082a44db0df166b8681fed429..7454d124450dc42f537fbaa0c1a6ef6a6687d09a 100644
--- a/tools/local_run.py
+++ b/tools/local_run.py
@@ -1,11 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import print_function
+
import subprocess
import sys
import os
if len(sys.argv) < 2:
- print "Usage: %s SCRIPTNAME [args]" % sys.argv[0]
+ print("Usage: %s SCRIPTNAME [args]" % sys.argv[0])
sys.exit(1)
else:
script = sys.argv[1]
@@ -37,7 +39,7 @@
stdout=subprocess.PIPE)
s = p.communicate()
if p.returncode != 0:
- print s[0]
+ print(s[0])
sys.exit(p.returncode)
if os.path.exists(script):
diff --git a/tools/make_man.py b/tools/make_man.py
index 2c37f7f3e86f0479caaef8e3a2814d065780db35..f8ca73887924be91b09847130a5f31fb84659455 100755
--- a/tools/make_man.py
+++ b/tools/make_man.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import print_function
# Copyright(C) 2010-2011 Laurent Bachelier
#
@@ -120,10 +121,10 @@ def main():
try:
script = imp.load_module("scripts.%s" % fname, f, tmpfile, desc)
except ImportError as e:
- print >>sys.stderr, "Unable to load the %s script (%s)" \
- % (fname, e)
+ print("Unable to load the %s script (%s)" \
+ % (fname, e), file=sys.stderr)
else:
- print "Loaded %s" % fname
+ print("Loaded %s" % fname)
# Find the applications we can handle
for klass in script.__dict__.itervalues():
if inspect.isclass(klass) and issubclass(klass, Application):
@@ -227,7 +228,7 @@ def analyze_application(app, script_name):
with open(os.path.join(BASE_PATH, DEST_DIR, "%s.1" % script_name), 'w+') as manfile:
for line in mantext.split('\n'):
manfile.write('%s\n' % line.lstrip().encode('utf-8'))
- print "wrote %s/%s.1" % (DEST_DIR, script_name)
+ print("wrote %s/%s.1" % (DEST_DIR, script_name))
if __name__ == '__main__':
sys.exit(main())
diff --git a/tools/stale_pyc.py b/tools/stale_pyc.py
index 7d04471804bbdbb29bdfc878c29184c7f1fdb035..b5b42062b7afd2a57f67babeb2cb94c5fef80860 100755
--- a/tools/stale_pyc.py
+++ b/tools/stale_pyc.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import os
import sys
@@ -17,4 +19,4 @@
if not os.path.exists(os.path.join(dirpath, filename[:-1])):
os.unlink(os.path.join(dirpath, filename))
if verbose:
- print os.path.join(dirpath, filename)
+ print(os.path.join(dirpath, filename))
diff --git a/tools/weboob_lint.py b/tools/weboob_lint.py
index 39c6c990638a087a31ffb1c1dd332da647fdae22..7b8bcbcab11e5b400e812bfcea41dae9dfbc8452 100755
--- a/tools/weboob_lint.py
+++ b/tools/weboob_lint.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
# Hint: use this script with file:///path/to/local/modules/ in sources.list
# if you want to correctly check all modules.
@@ -22,6 +23,6 @@
backends_without_icons.append(name)
if backends_without_tests:
- print 'Modules without tests: %s' % backends_without_tests
+ print('Modules without tests: %s' % backends_without_tests)
if backends_without_icons:
- print 'Modules without icons: %s' % backends_without_icons
+ print('Modules without icons: %s' % backends_without_icons)
diff --git a/weboob/applications/boobathon/boobathon.py b/weboob/applications/boobathon/boobathon.py
index 0df5e1267d08c64bdcbdfa349e2ae61f73bf90d2..7940a23eb7c5dac952915dcf1645ba460f31037e 100644
--- a/weboob/applications/boobathon/boobathon.py
+++ b/weboob/applications/boobathon/boobathon.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from datetime import datetime, timedelta
import re
@@ -119,7 +120,7 @@ def load(self):
elif line.startswith('h3=. '):
m = re.match('h3=. Event finished. Winner is "(.*)":/users/(\d+)\!', line)
if not m:
- print >>self.stderr, 'Unable to parse h3=: %s' % line
+ print('Unable to parse h3=: %s' % line, file=self.stderr)
continue
self.winner = Member(int(m.group(2)), m.group(1))
elif line.startswith('h2. '):
@@ -127,7 +128,7 @@ def load(self):
elif line.startswith('h3. '):
m = re.match('h3. "(.*)":/users/(\d+)', line)
if not m:
- print >>self.stderr, 'Unable to parse user "%s"' % line
+ print('Unable to parse user "%s"' % line, file=self.stderr)
continue
member = Member(int(m.group(2)), m.group(1))
if member.id == self.my_id:
@@ -166,7 +167,7 @@ def load(self):
elif line.startswith('[['):
m = re.match('\[\[(\w+)\]\]\|\[\[(\w+)\]\]\|(.*)\|', line)
if not m:
- print >>self.stderr, 'Unable to parse task: "%s"' % line
+ print('Unable to parse task: "%s"' % line, file=self.stderr)
continue
task = Task(m.group(1), m.group(2))
member.tasks.append(task)
@@ -292,7 +293,7 @@ def __init__(self, *args, **kwargs):
def main(self, argv):
if len(argv) < 2:
- print >>self.stderr, 'Please give the name of the boobathon'
+ print('Please give the name of the boobathon', file=self.stderr)
return 1
self.event = Event(argv[1], choice(self.weboob.backend_instances.values()))
@@ -372,9 +373,9 @@ def do_progress(self, line):
else:
s += ' '
s += '|%s' % self.NC
- print s
+ print(s)
- print ''
+ print('')
now = datetime.now()
if self.event.begin > now:
d = self.event.begin - now
@@ -394,13 +395,13 @@ def do_progress(self, line):
progress += '>'
else:
progress += ' '
- print 'Event started: %s |%s| %s' % (self.event.begin.strftime('%H:%M'),
+ print('Event started: %s |%s| %s' % (self.event.begin.strftime('%H:%M'),
progress,
- self.event.end.strftime('%H:%M'))
+ self.event.end.strftime('%H:%M')))
d = self.event.end - now
msg = 'The event will be finished in %d days, %02d:%02d:%02d'
- print msg % (d.days, d.seconds/3600, d.seconds%3600/60, d.seconds%60)
+ print(msg % (d.days, d.seconds/3600, d.seconds%3600/60, d.seconds%60))
def do_tasks(self, line):
"""
@@ -468,10 +469,10 @@ def do_close(self, name):
if member.name == name:
self.event.winner = member
if self.save_event('Close event'):
- print 'Event is now closed. Winner is %s!' % self.event.winner.name
+ print('Event is now closed. Winner is %s!' % self.event.winner.name)
return
- print >>self.stderr, '"%s" not found' % name
+ print('"%s" not found' % name, file=self.stderr)
return 3
def complete_edit(self, text, line, *ignored):
@@ -486,7 +487,7 @@ def do_edit(self, line):
Edit information about you or about event.
"""
if not line:
- print >>self.stderr, 'Syntax: edit [event | me]'
+ print('Syntax: edit [event | me]', file=self.stderr)
return 2
self.event.load()
@@ -496,12 +497,12 @@ def do_edit(self, line):
elif line == 'me':
mem = self.event.get_me()
if not mem:
- print >>self.stderr, 'You haven\'t joined the event.'
+ print('You haven\'t joined the event.', file=self.stderr)
return 1
self.edit_member(mem)
self.save_event('Member edited')
else:
- print >>self.stderr, 'Unable to edit "%s"' % line
+ print('Unable to edit "%s"' % line, file=self.stderr)
return 1
def do_info(self, line):
@@ -511,19 +512,19 @@ def do_info(self, line):
Display information about this event.
"""
self.event.load()
- print self.event.title
- print '-' * len(self.event.title)
- print self.event.description
- print ''
- print 'Date:', self.event.date.strftime('%Y-%m-%d') if self.event.date else 'Unknown'
- print 'Begin:', self.event.begin.strftime('%H:%M') if self.event.begin else 'Unknown'
- print 'End:', self.event.end.strftime('%H:%M') if self.event.end else 'Unknown'
- print 'Duration:', self.event.format_duration() or 'Unknown'
- print 'Location:', self.event.location or 'Unknown'
- print ''
- print 'There are %d members, use the "members" command to list them' % len(self.event.members)
+ print(self.event.title)
+ print('-' * len(self.event.title))
+ print(self.event.description)
+ print('')
+ print('Date:', self.event.date.strftime('%Y-%m-%d') if self.event.date else 'Unknown')
+ print('Begin:', self.event.begin.strftime('%H:%M') if self.event.begin else 'Unknown')
+ print('End:', self.event.end.strftime('%H:%M') if self.event.end else 'Unknown')
+ print('Duration:', self.event.format_duration() or 'Unknown')
+ print('Location:', self.event.location or 'Unknown')
+ print('')
+ print('There are %d members, use the "members" command to list them' % len(self.event.members))
if self.event.get_me() is None:
- print 'To join this event, use the command "join".'
+ print('To join this event, use the command "join".')
def do_members(self, line):
"""
@@ -533,22 +534,22 @@ def do_members(self, line):
"""
self.event.load()
for member in self.event.members.itervalues():
- print member.name
- print '-' * len(member.name)
- print 'Repository:', member.repository
+ print(member.name)
+ print('-' * len(member.name))
+ print('Repository:', member.repository)
if self.event.date is None:
- print 'Availabilities:', member.availabilities
- print 'Hardware:', member.hardware
+ print('Availabilities:', member.availabilities)
+ print('Hardware:', member.hardware)
accompl = 0
for task in member.tasks:
if task.status == task.STATUS_DONE:
accompl += 1
- print '%d tasks (%d accomplished)' % (len(member.tasks), accompl)
+ print('%d tasks (%d accomplished)' % (len(member.tasks), accompl))
if member is self.event.winner:
- print '=== %s is the winner!' % member.name
- print ''
+ print('=== %s is the winner!' % member.name)
+ print('')
- print 'Use the "tasks" command to display all tasks'
+ print('Use the "tasks" command to display all tasks')
def do_join(self, line):
"""
@@ -558,11 +559,11 @@ def do_join(self, line):
"""
self.event.load()
if self.event.backend.browser.get_userid() in self.event.members:
- print >>self.stderr, 'You have already joined this event.'
+ print('You have already joined this event.', file=self.stderr)
return 1
if self.event.is_closed():
- print >>self.stderr, "Boobathon is closed."
+ print("Boobathon is closed.", file=self.stderr)
return 1
m = Member(self.event.backend.browser.get_userid(), None)
@@ -579,17 +580,17 @@ def do_leave(self, line):
self.event.load()
if self.event.currently_in_event():
- print >>self.stderr, 'Unable to leave during the event, loser!'
+ print('Unable to leave during the event, loser!', file=self.stderr)
return 1
if self.event.is_closed():
- print >>self.stderr, "Boobathon is closed."
+ print("Boobathon is closed.", file=self.stderr)
return 1
try:
self.event.members.pop(self.event.backend.browser.get_userid())
except KeyError:
- print >>self.stderr, "You have not joined this event."
+ print("You have not joined this event.", file=self.stderr)
return 1
else:
self.save_event('Left the event')
@@ -603,26 +604,26 @@ def do_remtask(self, line):
self.event.load()
mem = self.event.get_me()
if not mem:
- print >>self.stderr, "You have not joined this event."
+ print("You have not joined this event.", file=self.stderr)
return 1
if self.event.is_closed():
- print >>self.stderr, "Boobathon is closed."
+ print("Boobathon is closed.", file=self.stderr)
return 1
try:
task_id = int(line)
except ValueError:
- print >>self.stderr, 'The task ID should be a number'
+ print('The task ID should be a number', file=self.stderr)
return 2
try:
task = mem.tasks.pop(task_id)
except IndexError:
- print >>self.stderr, 'Unable to find task #%d' % task_id
+ print('Unable to find task #%d' % task_id, file=self.stderr)
return 1
else:
- print 'Removing task #%d (%s,%s).' % (task_id, task.backend, task.capability)
+ print('Removing task #%d (%s,%s).' % (task_id, task.backend, task.capability))
self.save_event('Remove task')
def do_addtask(self, line):
@@ -634,24 +635,24 @@ def do_addtask(self, line):
self.event.load()
mem = self.event.get_me()
if not mem:
- print >>self.stderr, "You have not joined this event."
+ print("You have not joined this event.", file=self.stderr)
return 1
if self.event.is_closed():
- print >>self.stderr, "Boobathon is closed."
+ print("Boobathon is closed.", file=self.stderr)
return 1
backend, capability = self.parse_command_args(line, 2, 2)
if not backend[0].isupper():
- print >>self.stderr, 'The backend name "%s" needs to start with a capital.' % backend
+ print('The backend name "%s" needs to start with a capital.' % backend, file=self.stderr)
return 2
if not capability.startswith('Cap') or not capability[3].isupper():
- print >>self.stderr, '"%s" is not a proper capability name (must start with Cap).' % capability
+ print('"%s" is not a proper capability name (must start with Cap).' % capability, file=self.stderr)
return 2
for task in mem.tasks:
if (task.backend,task.capability) == (backend,capability):
- print >>self.stderr, "A task already exists for that."
+ print("A task already exists for that.", file=self.stderr)
return 1
task = Task(backend, capability)
@@ -668,15 +669,15 @@ def do_start(self, line):
self.event.load()
mem = self.event.get_me()
if not mem:
- print >>self.stderr, "You have not joined this event."
+ print("You have not joined this event.", file=self.stderr)
return 1
if len(mem.tasks) == 0:
- print >>self.stderr, "You don't have any task to do."
+ print("You don't have any task to do.", file=self.stderr)
return 1
if not self.event.currently_in_event():
- print >>self.stderr, "You can't start a task, we are not in event."
+ print("You can't start a task, we are not in event.", file=self.stderr)
return 1
if line.isdigit():
@@ -690,16 +691,16 @@ def do_start(self, line):
last_done = i
elif task.status == task.STATUS_PROGRESS:
task.status = task.STATUS_NONE
- print 'Task #%s (%s,%s) canceled.' % (i, task.backend, task.capability)
+ print('Task #%s (%s,%s) canceled.' % (i, task.backend, task.capability))
if (i == task_id or task_id < 0) and task.status == task.STATUS_NONE:
break
else:
- print >>self.stderr, 'Task not found.'
+ print('Task not found.', file=self.stderr)
return 3
if task.status == task.STATUS_DONE:
- print >>self.stderr, 'Task is already done.'
+ print('Task is already done.', file=self.stderr)
return 1
task.status = task.STATUS_PROGRESS
@@ -716,16 +717,16 @@ def do_done(self, line):
self.event.load()
mem = self.event.get_me()
if not mem:
- print >>self.stderr, "You have not joined this event."
+ print("You have not joined this event.", file=self.stderr)
return 1
if self.event.is_closed():
- print >>self.stderr, "Boobathon is closed."
+ print("Boobathon is closed.", file=self.stderr)
return 1
for i, task in enumerate(mem.tasks):
if task.status == task.STATUS_PROGRESS:
- print 'Task (%s,%s) done! (%d%%)' % (task.backend, task.capability, (i+1)*100/len(mem.tasks))
+ print('Task (%s,%s) done! (%d%%)' % (task.backend, task.capability, (i+1)*100/len(mem.tasks)))
if self.event.currently_in_event():
task.status = task.STATUS_DONE
task.date = datetime.now()
@@ -733,12 +734,12 @@ def do_done(self, line):
self.save_event('Task accomplished')
else:
task.status = task.STATUS_NONE
- print >>self.stderr, 'Oops, you are out of event. Canceling the task...'
+ print('Oops, you are out of event. Canceling the task...', file=self.stderr)
self.save_event('Cancel task')
return 1
return
- print >>self.stderr, "There isn't any task in progress."
+ print("There isn't any task in progress.", file=self.stderr)
return 1
def do_cancel(self, line):
@@ -750,21 +751,21 @@ def do_cancel(self, line):
self.event.load()
mem = self.event.get_me()
if not mem:
- print >>self.stderr, "You have not joined this event."
+ print("You have not joined this event.", file=self.stderr)
return 1
if self.event.is_closed():
- print >>self.stderr, "Boobathon is closed."
+ print("Boobathon is closed.", file=self.stderr)
return 1
for task in mem.tasks:
if task.status == task.STATUS_PROGRESS:
- print 'Task (%s,%s) canceled.' % (task.backend, task.capability)
+ print('Task (%s,%s) canceled.' % (task.backend, task.capability))
task.status = task.STATUS_NONE
self.save_event('Cancel task')
return
- print >>self.stderr, "There isn't any task in progress."
+ print("There isn't any task in progress.", file=self.stderr)
return 1
def load_default_backends(self):
@@ -780,7 +781,7 @@ def load_default_backends(self):
return
if not self.check_loaded_backends({'url': 'https://symlink.me'}):
- print "Ok, so leave now, fag."
+ print("Ok, so leave now, fag.")
sys.exit(0)
def is_module_loadable(self, module):
diff --git a/weboob/applications/boobcoming/__init__.py b/weboob/applications/boobcoming/__init__.py
index e817eef299e2b62b03b951e346531d06065730e9..20f3f3bdee48a22dbd4239d52b180ed4b6e71465 100644
--- a/weboob/applications/boobcoming/__init__.py
+++ b/weboob/applications/boobcoming/__init__.py
@@ -1,4 +1,3 @@
-
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
diff --git a/weboob/applications/boobcoming/boobcoming.py b/weboob/applications/boobcoming/boobcoming.py
index fab530f62c34b0778072d9be976b3133d1f73937..9c21b3a9fdaaecb9fb80ddcdbe95c7cf3f7f98ac 100644
--- a/weboob/applications/boobcoming/boobcoming.py
+++ b/weboob/applications/boobcoming/boobcoming.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
from datetime import time, datetime
from weboob.tools.date import parse_date
@@ -178,10 +180,10 @@ def do_search(self, line):
r = 'notempty'
while r != '':
for category in CATEGORIES.values:
- print ' %s%2d)%s [%s] %s' % (self.BOLD,
+ print(' %s%2d)%s [%s] %s' % (self.BOLD,
CATEGORIES.index[category] + 1,
self.NC,
- 'x' if category in query.categories else ' ', category)
+ 'x' if category in query.categories else ' ', category))
r = self.ask(' Select category (or empty to stop)', regexp='(\d+|)', default='')
if not r.isdigit():
continue
@@ -230,7 +232,7 @@ def do_list(self, line):
if line:
_date = parse_date(line)
if not _date:
- print >>self.stderr, 'Invalid argument: %s' % self.get_command_help('list')
+ print('Invalid argument: %s' % self.get_command_help('list'), file=self.stderr)
return 2
date_from = datetime.combine(_date, time.min)
@@ -255,13 +257,13 @@ def do_info(self, _id):
"""
if not _id:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
event = self.get_object(_id, 'get_event')
if not event:
- print >>self.stderr, 'Upcoming event not found: %s' % _id
+ print('Upcoming event not found: %s' % _id, file=self.stderr)
return 3
self.start_format()
@@ -278,7 +280,7 @@ def do_export(self, line):
Export event in ICALENDAR format
"""
if not line:
- print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('export')
+ print('This command takes at leat one argument: %s' % self.get_command_help('export'), file=self.stderr)
return 2
_file, args = self.parse_command_args(line, 2, req_n=1)
@@ -306,7 +308,7 @@ def retrieve_events(self, args):
event = self.get_object(_id, 'get_event')
if not event:
- print >>self.stderr, 'Upcoming event not found: %s' % _id
+ print('Upcoming event not found: %s' % _id, file=self.stderr)
return 3
l.append(event)
@@ -328,7 +330,7 @@ def do_attends(self, line):
ID is the identifier of the event.
"""
if not line:
- print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('attends')
+ print('This command takes at leat one argument: %s' % self.get_command_help('attends'), file=self.stderr)
return 2
args = self.parse_command_args(line, 1, req_n=1)
@@ -346,7 +348,7 @@ def do_unattends(self, line):
"""
if not line:
- print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('unattends')
+ print('This command takes at leat one argument: %s' % self.get_command_help('unattends'), file=self.stderr)
return 2
args = self.parse_command_args(line, 1, req_n=1)
diff --git a/weboob/applications/boobill/__init__.py b/weboob/applications/boobill/__init__.py
index 2224de587cecee38dc6877257f89af25f08579e7..4a9eb68c5ab8aa0c8e1784f0e61666831fef81aa 100644
--- a/weboob/applications/boobill/__init__.py
+++ b/weboob/applications/boobill/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2011 Laurent Bachelier
#
diff --git a/weboob/applications/boobill/boobill.py b/weboob/applications/boobill/boobill.py
index 58960f1a8f7046b1ef17de2d90002ee69465b83f..7950308a249e113a8adcb8ffee09cea8c584412f 100644
--- a/weboob/applications/boobill/boobill.py
+++ b/weboob/applications/boobill/boobill.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from decimal import Decimal
@@ -86,9 +87,9 @@ def exec_method(self, id, method):
self.bcall_error_handler(backend, error, backtrace)
if len(more_results) > 0:
- print >>self.stderr, 'Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results))
+ print('Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results)), file=self.stderr)
for backend in not_implemented:
- print >>self.stderr, u'Error(%s): This feature is not supported yet by this backend.' % backend.name
+ print(u'Error(%s): This feature is not supported yet by this backend.' % backend.name, file=self.stderr)
def do_subscriptions(self, line):
"""
@@ -183,7 +184,7 @@ def do_download(self, line):
id, dest = self.parse_command_args(line, 2, 1)
id, backend_name = self.parse_id(id)
if not id:
- print >>self.stderr, 'Error: please give a bill ID (hint: use bills command)'
+ print('Error: please give a bill ID (hint: use bills command)', file=self.stderr)
return 2
names = (backend_name,) if backend_name is not None else None
@@ -204,13 +205,13 @@ def do_download(self, line):
for backend, buf in self.do('download_bill', id, backends=names):
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 bill in "%s": %s' % (dest, e)
+ print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
@@ -221,13 +222,13 @@ def download_all(self, id, names):
for backend2, buf in self.do('download_bill', bill.id, backends=names):
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 bill in "%s": %s' % (dest, e)
+ print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
diff --git a/weboob/applications/booblyrics/booblyrics.py b/weboob/applications/booblyrics/booblyrics.py
index 12f7b1f8536649997ea4d954a9515075e4ac7fa2..586c815112e7efe4c5e40fc38209e9df822d24e5 100644
--- a/weboob/applications/booblyrics/booblyrics.py
+++ b/weboob/applications/booblyrics/booblyrics.py
@@ -17,8 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
-
+from __future__ import print_function
from weboob.capabilities.lyrics import CapLyrics
from weboob.capabilities.base import empty
@@ -84,7 +83,7 @@ def do_get(self, id):
songlyrics = self.get_object(id, 'get_lyrics')
if not songlyrics:
- print >>self.stderr, 'Song lyrics not found: %s' % id
+ print('Song lyrics not found: %s' % id, file=self.stderr)
return 3
self.start_format()
diff --git a/weboob/applications/boobmsg/boobmsg.py b/weboob/applications/boobmsg/boobmsg.py
index ebec6072bc6f1f1114525e912062f9ed18517699..f39b02e066a2db08695808d66a92c907ca1b1721 100644
--- a/weboob/applications/boobmsg/boobmsg.py
+++ b/weboob/applications/boobmsg/boobmsg.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import os
import datetime
@@ -288,14 +289,14 @@ def do_status(self, line):
results[backend.name] = [field]
for name, fields in results.iteritems():
- print ':: %s ::' % name
+ print(':: %s ::' % name)
for f in fields:
if f.flags & f.FIELD_HTML:
value = html2text(f.value)
else:
value = f.value
- print '%s: %s' % (f.label, value)
- print ''
+ print('%s: %s' % (f.label, value))
+ print('')
def do_post(self, line):
"""
@@ -347,7 +348,7 @@ def do_post(self, line):
self.bcall_errors_handler(errors)
else:
if self.interactive:
- print 'Message sent sucessfully to %s' % receiver
+ print('Message sent sucessfully to %s' % receiver)
threads = []
messages = []
@@ -430,7 +431,7 @@ def do_show(self, arg):
"""
message = None
if len(arg) == 0:
- print >>self.stderr, 'Please give a message ID.'
+ print('Please give a message ID.', file=self.stderr)
return 2
try:
@@ -447,7 +448,7 @@ def do_show(self, arg):
self.weboob.do('set_message_read', message, backends=message.backend)
return
else:
- print >>self.stderr, 'Message not found'
+ print('Message not found', file=self.stderr)
return 3
def do_profile(self, id):
@@ -475,7 +476,7 @@ def do_photos(self, id):
"""
photo_cmd = self.config.get('photo_viewer')
if photo_cmd is None:
- print >>self.stderr, "Configuration error: photo_viewer is undefined"
+ print("Configuration error: photo_viewer is undefined", file=self.stderr)
return
_id, backend_name = self.parse_id(id, unique_backend=True)
diff --git a/weboob/applications/boobooks/boobooks.py b/weboob/applications/boobooks/boobooks.py
index 2aff8a6177d3859cff4ef14ee40d772004389650..6eacabd97b98e3eb9523b6aca6ac929bef08c9a9 100644
--- a/weboob/applications/boobooks/boobooks.py
+++ b/weboob/applications/boobooks/boobooks.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
from weboob.capabilities.library import CapBook, Book
from weboob.tools.application.repl import ReplApplication
from weboob.tools.application.formatters.iformatter import PrettyFormatter
@@ -62,7 +64,7 @@ def do_renew(self, id):
id, backend_name = self.parse_id(id)
if not id:
- print >>self.stderr, 'Error: please give a book ID (hint: use ls command)'
+ print('Error: please give a book ID (hint: use ls command)', file=self.stderr)
return 2
names = (backend_name,) if backend_name is not None else None
diff --git a/weboob/applications/boobsize/boobsize.py b/weboob/applications/boobsize/boobsize.py
index 559678af9ca6d6e319db7d0df64d91d4daef2ec7..465605f9957515135c259f9c5942c9388e285dea 100644
--- a/weboob/applications/boobsize/boobsize.py
+++ b/weboob/applications/boobsize/boobsize.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from weboob.capabilities.base import empty
from weboob.capabilities.gauge import CapGauge, SensorNotFound
@@ -110,7 +111,7 @@ def main(self, argv):
def bcall_error_handler(self, backend, error, backtrace):
if isinstance(error, SensorNotFound):
msg = unicode(error) or 'Sensor not found (hint: try details command)'
- print >>self.stderr, 'Error(%s): %s' % (backend.name, msg)
+ print('Error(%s): %s' % (backend.name, msg), file=self.stderr)
else:
return ReplApplication.bcall_error_handler(self, backend, error, backtrace)
diff --git a/weboob/applications/boobtracker/boobtracker.py b/weboob/applications/boobtracker/boobtracker.py
index f6957f8e01e65aafa4bfbc5c5f1de8e801b95b9e..c7e6c414e4108dd3b6ea02e33da65d2a1cbc9e6c 100644
--- a/weboob/applications/boobtracker/boobtracker.py
+++ b/weboob/applications/boobtracker/boobtracker.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from datetime import timedelta
from email import message_from_string, message_from_file
@@ -156,7 +157,7 @@ def do_search(self, line):
elif len(path) > 0:
query.project = path[0]
else:
- print >>self.stderr, 'Please enter a project name'
+ print('Please enter a project name', file=self.stderr)
return 1
query.author = self.options.author
@@ -183,12 +184,12 @@ def do_get(self, line):
Get an issue and display it.
"""
if not line:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('get', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('get', short=True), file=self.stderr)
return 2
issue = self.get_object(line, 'get_issue')
if not issue:
- print >>self.stderr, 'Issue not found: %s' % line
+ print('Issue not found: %s' % line, file=self.stderr)
return 3
self.format(issue)
@@ -226,7 +227,7 @@ def do_logtime(self, line):
try:
hours = float(hours)
except ValueError:
- print >>self.stderr, 'Error: HOURS parameter may be a float'
+ print('Error: HOURS parameter may be a float', file=self.stderr)
return 1
id, backend_name = self.parse_id(id, unique_backend=True)
@@ -398,8 +399,8 @@ def edit_issue(self, issue, edit=True):
try:
issue = backend.post_issue(issue)
- print 'Issue %s %s' % (self.formatter.colored(issue.fullid, 'red', 'bold'),
- 'updated' if edit else 'created')
+ print('Issue %s %s' % (self.formatter.colored(issue.fullid, 'red', 'bold'),
+ 'updated' if edit else 'created'))
if edit:
self.format(issue)
elif email_to:
@@ -447,7 +448,7 @@ def do_post(self, line):
--status STATUS
"""
if not line.strip():
- print 'Please give the project name'
+ print('Please give the project name')
return 1
project, backend_name = self.parse_id(line, unique_backend=True)
@@ -481,7 +482,7 @@ def do_edit(self, line):
_id, key, value = self.parse_command_args(line, 3, 1)
issue = self.get_object(_id, 'get_issue')
if not issue:
- print >>self.stderr, 'Issue not found: %s' % _id
+ print('Issue not found: %s' % _id, file=self.stderr)
return 3
return self.edit_issue(issue, edit=True)
@@ -499,4 +500,4 @@ def do_attach(self, line):
Attach a file to an issue (Not implemented yet).
"""
- print >>self.stderr, 'Not implemented yet.'
+ print('Not implemented yet.', file=self.stderr)
diff --git a/weboob/applications/cineoob/cineoob.py b/weboob/applications/cineoob/cineoob.py
index c3ec55536fa48d5a1d00a5cce8271c5166da5d94..f3e5f4291656221ab6bebaebeb3301d8ff28e835 100644
--- a/weboob/applications/cineoob/cineoob.py
+++ b/weboob/applications/cineoob/cineoob.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
+from __future__ import print_function
from datetime import datetime
@@ -230,11 +230,11 @@ def do_movies_in_common(self, line):
person1 = self.get_object(id1, 'get_person', caps=CapCinema)
if not person1:
- print >>self.stderr, 'Person not found: %s' % id1
+ print('Person not found: %s' % id1, file=self.stderr)
return 3
person2 = self.get_object(id2, 'get_person', caps=CapCinema)
if not person2:
- print >>self.stderr, 'Person not found: %s' % id2
+ print('Person not found: %s' % id2, file=self.stderr)
return 3
initial_count = self.options.count
@@ -263,11 +263,11 @@ def do_persons_in_common(self, line):
movie1 = self.get_object(id1, 'get_movie', caps=CapCinema)
if not movie1:
- print >>self.stderr, 'Movie not found: %s' % id1
+ print('Movie not found: %s' % id1, file=self.stderr)
return 3
movie2 = self.get_object(id2, 'get_movie', caps=CapCinema)
if not movie2:
- print >>self.stderr, 'Movie not found: %s' % id2
+ print('Movie not found: %s' % id2, file=self.stderr)
return 3
initial_count = self.options.count
@@ -294,7 +294,7 @@ def do_info_movie(self, id):
movie = self.get_object(id, 'get_movie', caps=CapCinema)
if not movie:
- print >>self.stderr, 'Movie not found: %s' % id
+ print('Movie not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@@ -309,7 +309,7 @@ def do_info_person(self, id):
person = self.get_object(id, 'get_person', caps=CapCinema)
if not person:
- print >>self.stderr, 'Person not found: %s' % id
+ print('Person not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@@ -356,7 +356,7 @@ def do_casting(self, line):
movie = self.get_object(movie_id, 'get_movie', caps=CapCinema)
if not movie:
- print >>self.stderr, 'Movie not found: %s' % id
+ print('Movie not found: %s' % id, file=self.stderr)
return 3
for backend, person in self.do('iter_movie_persons', movie.id, role, backends=movie.backend, caps=CapCinema):
@@ -373,7 +373,7 @@ def do_filmography(self, line):
person = self.get_object(person_id, 'get_person', caps=CapCinema)
if not person:
- print >>self.stderr, 'Person not found: %s' % id
+ print('Person not found: %s' % id, file=self.stderr)
return 3
for backend, movie in self.do('iter_person_movies', person.id, role, backends=person.backend, caps=CapCinema):
@@ -387,7 +387,7 @@ def do_biography(self, person_id):
"""
person = self.get_object(person_id, 'get_person', ('name', 'biography'), caps=CapCinema)
if not person:
- print >>self.stderr, 'Person not found: %s' % person_id
+ print('Person not found: %s' % person_id, file=self.stderr)
return 3
self.start_format()
@@ -411,7 +411,7 @@ def do_releases(self, line):
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
if not movie:
- print >>self.stderr, 'Movie not found: %s' % id
+ print('Movie not found: %s' % id, file=self.stderr)
return 3
# i would like to clarify with fillobj but how could i fill the movie AND choose the country ?
@@ -419,7 +419,7 @@ def do_releases(self, line):
if not empty(release):
movie.all_release_dates = u'%s' % (release)
else:
- print >>self.stderr, 'Movie releases not found for %s' % movie.original_title
+ print('Movie releases not found for %s' % movie.original_title, file=self.stderr)
return 3
self.start_format()
self.format(movie)
@@ -440,7 +440,7 @@ def do_info_torrent(self, id):
torrent = self.get_object(id, 'get_torrent', caps=CapTorrent)
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()
@@ -472,26 +472,26 @@ def do_getfile_torrent(self, line):
for backend, buf in self.do('get_torrent_file', _id, backends=backend_name, caps=CapTorrent):
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)
@@ -518,7 +518,7 @@ def do_search_movie_torrent(self, id):
"""
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
if not movie:
- print >>self.stderr, 'Movie not found: %s' % id
+ print('Movie not found: %s' % id, file=self.stderr)
return 3
pattern = movie.original_title
@@ -547,7 +547,7 @@ def do_info_subtitle(self, id):
subtitle = self.get_object(id, 'get_subtitle', caps=CapCinema)
if not subtitle:
- print >>self.stderr, 'Subtitle not found: %s' % id
+ print('Subtitle not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@@ -578,17 +578,17 @@ def do_getfile_subtitle(self, line):
for backend, buf in self.do('get_subtitle_file', _id, backends=backend_name, caps=CapSubtitle):
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 file in "%s": %s' % (dest, e)
+ print('Unable to write file in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
- print >>self.stderr, 'Subtitle "%s" not found' % id
+ print('Subtitle "%s" not found' % id, file=self.stderr)
return 3
@defaultcount(10)
@@ -657,7 +657,7 @@ def do_search_movie_subtitle(self, line):
language, id = self.parse_command_args(line, 2, 2)
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
if not movie:
- print >>self.stderr, 'Movie not found: %s' % id
+ print('Movie not found: %s' % id, file=self.stderr)
return 3
pattern = movie.original_title
diff --git a/weboob/applications/comparoob/__init__.py b/weboob/applications/comparoob/__init__.py
index 394b92e6ca43a4ccc23eb4899ee3c131ffb858b9..513897941f5283eb3ad077354c6e434be8c8e4de 100644
--- a/weboob/applications/comparoob/__init__.py
+++ b/weboob/applications/comparoob/__init__.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
-
from .comparoob import Comparoob
diff --git a/weboob/applications/comparoob/comparoob.py b/weboob/applications/comparoob/comparoob.py
index a7b58c5332be2339bd0db110bda0c15df260beb0..723bbabe6b114bd50baf50d2ce17e2513e2aaa7b 100644
--- a/weboob/applications/comparoob/comparoob.py
+++ b/weboob/applications/comparoob/comparoob.py
@@ -17,9 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
-
-
+from __future__ import print_function
from weboob.capabilities.pricecomparison import CapPriceComparison
from weboob.tools.html import html2text
@@ -108,18 +106,18 @@ def do_prices(self, pattern):
product = None
if len(products) == 0:
- print >>self.stderr, 'Error: no product found with this pattern'
+ print('Error: no product found with this pattern', file=self.stderr)
return 1
elif len(products) == 1:
product = products[0]
else:
- print 'What product do you want to compare?'
+ print('What product do you want to compare?')
for i, p in enumerate(products):
- print ' %s%2d)%s %s' % (self.BOLD, i+1, self.NC, p.name)
+ print(' %s%2d)%s %s' % (self.BOLD, i+1, self.NC, p.name))
r = int(self.ask(' Select a product', regexp='\d+'))
while product is None:
if r <= 0 or r > len(products):
- print 'Error: Please enter a valid ID'
+ print('Error: Please enter a valid ID')
continue
product = products[r-1]
@@ -146,12 +144,12 @@ def do_info(self, _id):
Get information about a product.
"""
if not _id:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
price = self.get_object(_id, 'get_price')
if not price:
- print >>self.stderr, 'Price not found: %s' % _id
+ print('Price not found: %s' % _id, file=self.stderr)
return 3
self.start_format()
diff --git a/weboob/applications/cookboob/cookboob.py b/weboob/applications/cookboob/cookboob.py
index 4390befada5648aec7bd9c2a6b18fbc8ee7f0209..30a16cbd306783b4664391a5f999332d86ab2c8e 100644
--- a/weboob/applications/cookboob/cookboob.py
+++ b/weboob/applications/cookboob/cookboob.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
+from __future__ import print_function
import codecs
@@ -99,7 +99,7 @@ def do_info(self, id):
"""
recipe = self.get_object(id, 'get_recipe')
if not recipe:
- print >>self.stderr, 'Recipe not found: %s' % id
+ print('Recipe not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@@ -132,7 +132,7 @@ def do_export(self, line):
if recipe:
xmlstring = recipe.toKrecipesXml(backend_name or None)
if dest == '-':
- print xmlstring
+ print(xmlstring)
else:
if not dest.endswith('.kreml'):
dest += '.kreml'
@@ -140,10 +140,10 @@ def do_export(self, line):
with codecs.open(dest, 'w', 'utf-8') as f:
f.write(xmlstring)
except IOError as e:
- print >>self.stderr, 'Unable to write .kreml in "%s": %s' % (dest, e)
+ print('Unable to write .kreml in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
- print >>self.stderr, 'Recipe "%s" not found' % id
+ print('Recipe "%s" not found' % id, file=self.stderr)
return 3
@defaultcount(10)
diff --git a/weboob/applications/flatboob/flatboob.py b/weboob/applications/flatboob/flatboob.py
index b8aa7553a20a1928b3edee16639fb67f02d94999..5d7c28d015f904b23aa95119ee0cf515da19409f 100644
--- a/weboob/applications/flatboob/flatboob.py
+++ b/weboob/applications/flatboob/flatboob.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from weboob.capabilities.housing import CapHousing, Query
from weboob.tools.application.repl import ReplApplication, defaultcount
@@ -104,7 +105,7 @@ def do_search(self, line):
query.cities = []
while pattern:
if len(query.cities) > 0:
- print '\n%sSelected cities:%s %s' % (self.BOLD, self.NC, ', '.join([c.name for c in query.cities]))
+ print('\n%sSelected cities:%s %s' % (self.BOLD, self.NC, ', '.join([c.name for c in query.cities])))
pattern = self.ask('Enter a city pattern (or empty to stop)', default='')
if not pattern:
break
@@ -114,7 +115,7 @@ def do_search(self, line):
cities.append(city)
if len(cities) == 0:
- print ' Not found!'
+ print(' Not found!')
continue
if len(cities) == 1:
if city in query.cities:
@@ -126,7 +127,7 @@ def do_search(self, line):
r = 'notempty'
while r != '':
for i, city in enumerate(cities):
- print ' %s%2d)%s [%s] %s' % (self.BOLD, i+1, self.NC, 'x' if city in query.cities else ' ', city.name)
+ print(' %s%2d)%s [%s] %s' % (self.BOLD, i+1, self.NC, 'x' if city in query.cities else ' ', city.name))
r = self.ask(' Select cities (or empty to stop)', regexp='(\d+|)', default='')
if not r.isdigit():
continue
@@ -142,10 +143,10 @@ def do_search(self, line):
r = 'notempty'
while r != '':
for good in Query.HOUSE_TYPES.values:
- print ' %s%2d)%s [%s] %s' % (self.BOLD,
+ print(' %s%2d)%s [%s] %s' % (self.BOLD,
Query.HOUSE_TYPES.index[good] + 1,
self.NC,
- 'x' if good in query.house_types else ' ', good)
+ 'x' if good in query.house_types else ' ', good))
r = self.ask(' Select type of house (or empty to stop)', regexp='(\d+|)', default='')
if not r.isdigit():
continue
@@ -160,14 +161,14 @@ def do_search(self, line):
_type = None
while _type not in [query.TYPE_RENT, query.TYPE_SALE]:
- print ' %s%2d)%s %s' % (self.BOLD,
+ print(' %s%2d)%s %s' % (self.BOLD,
query.TYPE_RENT,
self.NC,
- "Rent")
- print ' %s%2d)%s %s' % (self.BOLD,
+ "Rent"))
+ print(' %s%2d)%s %s' % (self.BOLD,
query.TYPE_SALE,
self.NC,
- "Sale")
+ "Sale"))
_type = self.ask_int('Type of query')
query.type = _type
@@ -207,20 +208,20 @@ def do_load(self, query_name):
"""
queries = self.config.get('queries')
if not queries:
- print >>self.stderr, 'There is no saved queries'
+ print('There is no saved queries', file=self.stderr)
return 2
if not query_name:
for name in queries.keys():
- print ' %s* %s %s' % (self.BOLD,
+ print(' %s* %s %s' % (self.BOLD,
self.NC,
- name)
+ name))
query_name = self.ask('Which one')
if query_name in queries:
self.complete_search(queries.get(query_name))
else:
- print >>self.stderr, 'Unknown query'
+ print('Unknown query', file=self.stderr)
return 2
def complete_info(self, text, line, *ignored):
@@ -235,12 +236,12 @@ def do_info(self, _id):
Get information about a housing.
"""
if not _id:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
housing = self.get_object(_id, 'get_housing')
if not housing:
- print >>self.stderr, 'Housing not found: %s' % _id
+ print('Housing not found: %s' % _id, file=self.stderr)
return 3
self.start_format()
diff --git a/weboob/applications/galleroob/galleroob.py b/weboob/applications/galleroob/galleroob.py
index ed168cd9b993ef69b7cb1bb570c49c5922dd37e1..1e833184ec96bae1e3c58d4c089d867f9084f0af 100644
--- a/weboob/applications/galleroob/galleroob.py
+++ b/weboob/applications/galleroob/galleroob.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
+from __future__ import print_function
import os
from re import search, sub
@@ -67,7 +67,7 @@ def do_search(self, pattern):
List galleries matching a PATTERN.
"""
if not pattern:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('search', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('search', short=True), file=self.stderr)
return 2
self.start_format(pattern=pattern)
@@ -97,14 +97,14 @@ def do_download(self, line):
gallery = result
if not gallery:
- print >>self.stderr, 'Gallery not found: %s' % _id
+ print('Gallery not found: %s' % _id, file=self.stderr)
return 3
backend.fillobj(gallery, ('title',))
if dest is None:
dest = sub('/', ' ', gallery.title)
- print "Downloading to %s" % dest
+ print("Downloading to %s" % dest)
try:
os.mkdir(dest)
@@ -122,7 +122,7 @@ def do_download(self, line):
if img.data is None:
backend.fillobj(img, ('url', 'data'))
if img.data is None:
- print >>self.stderr, "Couldn't get page %d, exiting" % i
+ print("Couldn't get page %d, exiting" % i, file=self.stderr)
break
ext = search(r"\.([^\.]{1,5})$", img.url)
@@ -132,7 +132,7 @@ def do_download(self, line):
ext = "jpg"
name = '%03d.%s' % (i, ext)
- print 'Writing file %s' % name
+ print('Writing file %s' % name)
with open(name, 'w') as f:
f.write(img.data)
@@ -149,7 +149,7 @@ def do_info(self, line):
gallery = self.get_object(_id, 'get_gallery')
if not gallery:
- print >>self.stderr, 'Gallery not found: %s' % _id
+ print('Gallery not found: %s' % _id, file=self.stderr)
return 3
self.start_format()
diff --git a/weboob/applications/geolooc/__init__.py b/weboob/applications/geolooc/__init__.py
index 562dccc511d4f876e19a4551cad47aa9dcacb014..ef53d93f96ec984e6a1e76c362114c0e654eb344 100644
--- a/weboob/applications/geolooc/__init__.py
+++ b/weboob/applications/geolooc/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2011 Romain Bignon
#
diff --git a/weboob/applications/geolooc/geolooc.py b/weboob/applications/geolooc/geolooc.py
index 22d4a69e76fb9ca0d3e941d5a608c644bbb9c076..49152113c86ff990394323dbf7a74fddb54e333f 100644
--- a/weboob/applications/geolooc/geolooc.py
+++ b/weboob/applications/geolooc/geolooc.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
+from __future__ import print_function
from weboob.capabilities.geolocip import CapGeolocIp
from weboob.tools.application.repl import ReplApplication
@@ -36,7 +36,7 @@ class Geolooc(ReplApplication):
def main(self, argv):
if len(argv) < 2:
- print >>self.stderr, 'Syntax: %s ipaddr' % argv[0]
+ print('Syntax: %s ipaddr' % argv[0], file=self.stderr)
return 2
for backend, location in self.do('get_location', argv[1]):
diff --git a/weboob/applications/handjoob/handjoob.py b/weboob/applications/handjoob/handjoob.py
index d17bfff017480d130baa3ea45f175c42fec68e77..1cc4bcc3eee9411fbce91b421913f73a6a147ac3 100644
--- a/weboob/applications/handjoob/handjoob.py
+++ b/weboob/applications/handjoob/handjoob.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from weboob.capabilities.job import CapJob
from weboob.tools.application.repl import ReplApplication, defaultcount
@@ -122,13 +123,13 @@ def do_info(self, _id):
Get information about an advert.
"""
if not _id:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
job_advert = self.get_object(_id, 'get_job_advert')
if not job_advert:
- print >>self.stderr, 'Job advert not found: %s' % _id
+ print('Job advert not found: %s' % _id, file=self.stderr)
return 3
self.start_format()
diff --git a/weboob/applications/havedate/havedate.py b/weboob/applications/havedate/havedate.py
index 0eb177cbc1869fc75a3f8de4f71328ba4da8e41b..128a7dc009ea6a1de6a988c3e2ec5d8f16c51858 100644
--- a/weboob/applications/havedate/havedate.py
+++ b/weboob/applications/havedate/havedate.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from copy import copy
@@ -87,11 +88,11 @@ def do_query(self, id):
_id, backend_name = self.parse_id(id, unique_backend=True)
for backend, query in self.do('send_query', _id, backends=backend_name):
- print '%s' % query.message
+ print('%s' % query.message)
def edit_optims(self, backend_names, optims_names, stop=False):
if optims_names is None:
- print >>self.stderr, 'Error: missing parameters.'
+ print('Error: missing parameters.', file=self.stderr)
return 2
for optim_name in optims_names.split():
@@ -101,29 +102,29 @@ def edit_optims(self, backend_names, optims_names, stop=False):
backends_optims[backend.name] = optim
for backend_name, optim in backends_optims.iteritems():
if len(optim.CONFIG) == 0:
- print '%s.%s does not require configuration.' % (backend_name, optim_name)
+ print('%s.%s does not require configuration.' % (backend_name, optim_name))
continue
was_running = optim.is_running()
if stop and was_running:
- print 'Stopping %s: %s' % (optim_name, backend_name)
+ print('Stopping %s: %s' % (optim_name, backend_name))
optim.stop()
params = optim.get_config()
if params is None:
params = {}
- print 'Configuration of %s.%s' % (backend_name, optim_name)
- print '-----------------%s-%s' % ('-' * len(backend_name), '-' * len(optim_name))
+ print('Configuration of %s.%s' % (backend_name, optim_name))
+ print('-----------------%s-%s' % ('-' * len(backend_name), '-' * len(optim_name)))
for key, value in optim.CONFIG.iteritems():
params[key] = self.ask(value, default=params[key] if (key in params) else value.default)
optim.set_config(params)
if stop and was_running:
- print 'Starting %s: %s' % (optim_name, backend_name)
+ print('Starting %s: %s' % (optim_name, backend_name))
optim.start()
def optims(self, function, backend_names, optims, store=True):
if optims is None:
- print >>self.stderr, 'Error: missing parameters.'
+ print('Error: missing parameters.', file=self.stderr)
return 2
for optim_name in optims.split():
@@ -205,7 +206,7 @@ def do_optim(self, line):
if backend_name == '*':
backend_name = None
elif backend_name is not None and not backend_name in [b.name for b in self.enabled_backends]:
- print >>self.stderr, 'Error: No such backend "%s"' % backend_name
+ print('Error: No such backend "%s"' % backend_name, file=self.stderr)
return 1
if cmd == 'start':
@@ -245,7 +246,7 @@ def do_optim(self, line):
line.append((b, status))
self.format(tuple(line))
return
- print >>self.stderr, "No such command '%s'" % cmd
+ print("No such command '%s'" % cmd, file=self.stderr)
return 1
def do_events(self, line):
diff --git a/weboob/applications/masstransit/__init__.py b/weboob/applications/masstransit/__init__.py
index a6a7d034903899fcd9a7cae89f2993d0a3482680..9d07fccb20f3c447ff74db0ebc54afc7f207db03 100644
--- a/weboob/applications/masstransit/__init__.py
+++ b/weboob/applications/masstransit/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2011 Romain Bignon
#
diff --git a/weboob/applications/monboob/monboob.py b/weboob/applications/monboob/monboob.py
index e40af14a1469032af2c1d000a0d1fe9ef8694c9e..11e45d2e9accddb493c870a34251ab357e111d5a 100644
--- a/weboob/applications/monboob/monboob.py
+++ b/weboob/applications/monboob/monboob.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from email.mime.text import MIMEText
from smtplib import SMTP
@@ -118,7 +119,7 @@ def main(self, argv):
if self.config.get('interval') < 1:
raise ValueError()
except ValueError:
- print >>self.stderr, 'Configuration error: interval must be an integer >0.'
+ print('Configuration error: interval must be an integer >0.', file=self.stderr)
return 1
try:
@@ -126,7 +127,7 @@ def main(self, argv):
if self.config.get('html') not in (0, 1):
raise ValueError()
except ValueError:
- print >>self.stderr, 'Configuration error: html must be 0 or 1.'
+ print('Configuration error: html must be 0 or 1.', file=self.stderr)
return 2
return ReplApplication.main(self, argv)
@@ -189,7 +190,7 @@ def process_incoming_mail(self, msg):
break
if len(content) == 0:
- print >>self.stderr, 'Unable to send an empty message'
+ print('Unable to send an empty message', file=self.stderr)
return 1
# remove signature
@@ -209,7 +210,7 @@ def process_incoming_mail(self, msg):
bname, id = reply_to.split('.', 1)
thread_id, parent_id = id.rsplit('.', 1)
except ValueError:
- print >>self.stderr, 'In-Reply-To header might be in form '
+ print('In-Reply-To header might be in form ', file=self.stderr)
return 1
# Default use the To header field to know the backend to use.
@@ -219,11 +220,11 @@ def process_incoming_mail(self, msg):
try:
backend = self.weboob.backend_instances[bname]
except KeyError:
- print >>self.stderr, 'Backend %s not found' % bname
+ print('Backend %s not found' % bname, file=self.stderr)
return 1
if not backend.has_caps(CapMessagesPost):
- print >>self.stderr, 'The backend %s does not implement CapMessagesPost' % bname
+ print('The backend %s does not implement CapMessagesPost' % bname, file=self.stderr)
return 1
thread = Thread(thread_id)
diff --git a/weboob/applications/parceloob/parceloob.py b/weboob/applications/parceloob/parceloob.py
index 55b69ef545631e1a9fbd7d2d506ffa56d0ba42d0..bb9cd529bc8a723f32fbeb3204dac283547c5b9c 100644
--- a/weboob/applications/parceloob/parceloob.py
+++ b/weboob/applications/parceloob/parceloob.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
+from __future__ import print_function
from weboob.capabilities.base import empty
from weboob.capabilities.parcel import CapParcel, Parcel, ParcelNotFound
@@ -105,7 +105,7 @@ def do_track(self, line):
"""
parcel = self.get_object(line, 'get_parcel_tracking')
if not parcel:
- print >>self.stderr, 'Error: the parcel "%s" is not found' % line
+ print('Error: the parcel "%s" is not found' % line, file=self.stderr)
return 2
parcels = set(self.storage.get('tracking', default=[]))
@@ -113,7 +113,7 @@ def do_track(self, line):
self.storage.set('tracking', list(parcels))
self.storage.save()
- print 'Parcel "%s" has been tracked.' % parcel.fullid
+ print('Parcel "%s" has been tracked.' % parcel.fullid)
def do_untrack(self, line):
"""
@@ -137,22 +137,22 @@ def do_untrack(self, line):
parcel = False
if not parcel:
- print >>self.stderr, 'Error: the parcel "%s" is not found. Did you provide the full id@backend parameter?' % line
+ print('Error: the parcel "%s" is not found. Did you provide the full id@backend parameter?' % line, file=self.stderr)
return 2
try:
parcels.remove(parcel.fullid)
except KeyError:
- print >>self.stderr, "Error: parcel \"%s\" wasn't tracked" % parcel.fullid
+ print("Error: parcel \"%s\" wasn't tracked" % parcel.fullid, file=self.stderr)
return 2
self.storage.set('tracking', list(parcels))
self.storage.save()
if removed:
- print "Parcel \"%s\" isn't tracked anymore." % line
+ print("Parcel \"%s\" isn't tracked anymore." % line)
else:
- print "Parcel \"%s\" isn't tracked anymore." % parcel.fullid
+ print("Parcel \"%s\" isn't tracked anymore." % parcel.fullid)
def do_status(self, line):
"""
@@ -184,7 +184,7 @@ def do_info(self, id):
"""
parcel = self.get_object(id, 'get_parcel_tracking', [])
if not parcel:
- print >>self.stderr, 'Error: parcel not found'
+ print('Error: parcel not found', file=self.stderr)
return 2
self.start_format()
diff --git a/weboob/applications/pastoob/__init__.py b/weboob/applications/pastoob/__init__.py
index eb32d4772ac8686ab95af16019ca38319ef087ff..f27bfe066d89b2381bade0d2409e3d110f68d63e 100644
--- a/weboob/applications/pastoob/__init__.py
+++ b/weboob/applications/pastoob/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2011 Laurent Bachelier
#
diff --git a/weboob/applications/pastoob/pastoob.py b/weboob/applications/pastoob/pastoob.py
index 30f65a771ab07f2ac9a79d37e516203e3e83d93d..75dcc8be38c009f7d0c1435bc6d2c91887893be8 100644
--- a/weboob/applications/pastoob/pastoob.py
+++ b/weboob/applications/pastoob/pastoob.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import os
import codecs
@@ -49,14 +50,14 @@ def do_info(self, line):
Get information about pastes.
"""
if not line:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
self.start_format()
for _id in line.split(' '):
paste = self.get_object(_id, 'get_paste', ['id', 'title', 'language', 'public', 'contents'])
if not paste:
- print >>self.stderr, 'Paste not found: %s' % _id
+ print('Paste not found: %s' % _id, file=self.stderr)
self.format(paste)
@@ -80,22 +81,22 @@ def do_get_bin(self, line):
def _get_op(self, _id, binary, command='get'):
if not _id:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help(command, short=True)
+ print('This command takes an argument: %s' % self.get_command_help(command, short=True), file=self.stderr)
return 2
try:
paste = self.get_object(_id, 'get_paste', ['contents'])
except PasteNotFound:
- print >>self.stderr, 'Paste not found: %s' % _id
+ print('Paste not found: %s' % _id, file=self.stderr)
return 3
if not paste:
- print >>self.stderr, 'Unable to handle paste: %s' % _id
+ print('Unable to handle paste: %s' % _id, file=self.stderr)
return 1
if binary:
if self.interactive:
if not self.ask('The console may become messed up. Are you sure you want to show a binary file on your terminal?', default=False):
- print >>self.stderr, 'Aborting.'
+ print('Aborting.', file=self.stderr)
return 1
output = self.stdout
output.write(paste.contents.decode('base64'))
@@ -135,7 +136,7 @@ def _post(self, filename, binary):
else:
contents = self.acquire_input()
if not len(contents):
- print >>self.stderr, 'Empty paste, aborting.'
+ print('Empty paste, aborting.', file=self.stderr)
return 1
else:
@@ -147,7 +148,7 @@ def _post(self, filename, binary):
with m as fp:
contents = fp.read()
except IOError as e:
- print >>self.stderr, 'Unable to open file "%s": %s' % (filename, e.strerror)
+ print('Unable to open file "%s": %s' % (filename, e.strerror), file=self.stderr)
return 1
if binary:
@@ -164,7 +165,7 @@ def _post(self, filename, binary):
if len(backends):
backend = choice(backends[max(backends.keys())])
else:
- print >>self.stderr, 'No suitable backend found.'
+ print('No suitable backend found.', file=self.stderr)
return 1
p = backend.new_paste(_id=None)
@@ -175,7 +176,7 @@ def _post(self, filename, binary):
p.title = os.path.basename(filename)
p.contents = contents
backend.post_paste(p, max_age=params['max_age'])
- print 'Successfuly posted paste: %s' % p.page_url
+ print('Successfuly posted paste: %s' % p.page_url)
def get_params(self):
return {'public': self.options.public,
diff --git a/weboob/applications/qboobmsg/messages_manager.py b/weboob/applications/qboobmsg/messages_manager.py
index da89bcb088ac61f9d8523dab189d149f48e5a915..da3fc1218e1d808fabfd190b10e8846548bf6aeb 100644
--- a/weboob/applications/qboobmsg/messages_manager.py
+++ b/weboob/applications/qboobmsg/messages_manager.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
import time
import logging
@@ -208,7 +210,7 @@ def showMessage(self, message, item=None):
self.ui.profileButton.hide()
def _profilePressed(self):
- print self.thread.id
+ print(self.thread.id)
self.emit(SIGNAL('display_contact'), self.thread.id)
def displayReply(self):
diff --git a/weboob/applications/qcineoob/subtitle.py b/weboob/applications/qcineoob/subtitle.py
index ede06b75b05977ffddad4addc60037e17ed2e226..0f8d0c30749265e2994459a38c62507148382bf2 100644
--- a/weboob/applications/qcineoob/subtitle.py
+++ b/weboob/applications/qcineoob/subtitle.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import QFrame, QFileDialog
@@ -82,6 +83,6 @@ def download(self):
with open(dest, 'w') as f:
f.write(data)
except IOError as e:
- print >>self.stderr, 'Unable to write subtitle file in "%s": %s' % (dest, e)
+ print('Unable to write subtitle file in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
diff --git a/weboob/applications/qcineoob/torrent.py b/weboob/applications/qcineoob/torrent.py
index 926e13dd59456e11c96cdc2134ef09ecc2a1c550..2c2e9be7e6839e15b766f927f3757c59f6c17978 100644
--- a/weboob/applications/qcineoob/torrent.py
+++ b/weboob/applications/qcineoob/torrent.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import QFrame, QFileDialog
@@ -86,6 +87,6 @@ def download(self):
with open(unicode(dest), 'w') as f:
f.write(data)
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
diff --git a/weboob/applications/qcookboob/recipe.py b/weboob/applications/qcookboob/recipe.py
index 6fa5a29f5c5570b04b3ecc45dcac3834ef2d5cbb..671eab8165b6cba59bdb7e71a5c21da1f475c492 100644
--- a/weboob/applications/qcookboob/recipe.py
+++ b/weboob/applications/qcookboob/recipe.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
import urllib
import codecs
@@ -107,6 +109,6 @@ def export(self):
with codecs.open(dest, 'w', 'utf-8') as f:
f.write(data)
except IOError as e:
- print >>self.stderr, 'Unable to write Krecipe file in "%s": %s' % (dest, e)
+ print('Unable to write Krecipe file in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
diff --git a/weboob/applications/qhavedate/events.py b/weboob/applications/qhavedate/events.py
index d67743c35552a7321363ad5323c4a9293b7201a1..d5bfda4ec74bc1d40cbc3202ef318f2e97d9a412 100644
--- a/weboob/applications/qhavedate/events.py
+++ b/weboob/applications/qhavedate/events.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
from PyQt4.QtGui import QWidget, QTreeWidgetItem, QImage, QIcon, QPixmap
from PyQt4.QtCore import SIGNAL, Qt
@@ -101,7 +103,7 @@ def gotEvent(self, backend, event):
if s == event.type:
found = True
if not found:
- print event.type
+ print(event.type)
self.ui.typeBox.addItem(event.type.capitalize(), event.type)
if event.type == self.event_filter:
self.ui.typeBox.setCurrentIndex(self.ui.typeBox.count()-1)
diff --git a/weboob/applications/qweboobcfg/qweboobcfg.py b/weboob/applications/qweboobcfg/qweboobcfg.py
index 709d4fb811f5f3afbc492aca6dfddb385cd6fb8f..a0889ef402c72d0e9b3616b9dc4feea449471d29 100644
--- a/weboob/applications/qweboobcfg/qweboobcfg.py
+++ b/weboob/applications/qweboobcfg/qweboobcfg.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2011 Romain Bignon
#
diff --git a/weboob/applications/radioob/radioob.py b/weboob/applications/radioob/radioob.py
index 39ce7a1b40dee3e2f2ff93864522b1ffaf096160..82ee673413a4b6b5b09140708203103393805872 100644
--- a/weboob/applications/radioob/radioob.py
+++ b/weboob/applications/radioob/radioob.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
+
import subprocess
import os
import re
@@ -166,18 +168,18 @@ def do_download(self, line):
_id, dest = self.parse_command_args(line, 2, 1)
audio = self.get_object(_id, 'get_audio', ['url'])
if not audio:
- print >>self.stderr, 'Audio file not found: %s' % _id
+ print('Audio file not found: %s' % _id, file=self.stderr)
return 3
if not audio.url:
- print >>self.stderr, 'Error: the direct URL is not available.'
+ print('Error: the direct URL is not available.', file=self.stderr)
return 4
def check_exec(executable):
with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0:
- print >>self.stderr, 'Please install "%s"' % executable
+ print('Please install "%s"' % executable, file=self.stderr)
return False
return True
@@ -224,7 +226,7 @@ def do_play(self, line):
"""
_id, stream_id = self.parse_command_args(line, 2, 1)
if not _id:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('play', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('play', short=True), file=self.stderr)
return 2
try:
@@ -235,14 +237,14 @@ def do_play(self, line):
obj = self.retrieve_obj(_id)
if obj is None:
- print >>self.stderr, 'No object matches with this id:', _id
+ print('No object matches with this id:', _id, file=self.stderr)
return 3
if isinstance(obj, Radio):
try:
streams = [obj.streams[stream_id]]
except IndexError:
- print >>self.stderr, 'Stream %d not found' % stream_id
+ print('Stream %d not found' % stream_id, file=self.stderr)
return 1
elif isinstance(obj, BaseAudio):
streams = [obj]
@@ -251,7 +253,7 @@ def do_play(self, line):
streams = obj.tracks_list
if len(streams) == 0:
- print >>self.stderr, 'Radio or Audio file not found:', _id
+ print('Radio or Audio file not found:', _id, file=self.stderr)
return 3
try:
@@ -289,7 +291,7 @@ def do_play(self, line):
self.player.play(stream, player_name=player_name, player_args=media_player_args)
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
- print '%s\nRadio URL: %s' % (e, stream.url)
+ print('%s\nRadio URL: %s' % (e, stream.url))
def retrieve_obj(self, _id):
obj = None
@@ -316,7 +318,7 @@ def do_playlist(self, line):
"""
if not line:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
+ print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
return 2
cmd, args = self.parse_command_args(line, 2, req_n=1)
@@ -326,11 +328,11 @@ def do_playlist(self, line):
audio = self.get_object(_id, 'get_audio')
if not audio:
- print >>self.stderr, 'Audio file not found: %s' % _id
+ print('Audio file not found: %s' % _id, file=self.stderr)
return 3
if not audio.url:
- print >>self.stderr, 'Error: the direct URL is not available.'
+ print('Error: the direct URL is not available.', file=self.stderr)
return 4
self.PLAYLIST.append(audio)
@@ -342,11 +344,11 @@ def do_playlist(self, line):
audio_to_remove = self.get_object(_id, 'get_audio')
if not audio_to_remove:
- print >>self.stderr, 'Audio file not found: %s' % _id
+ print('Audio file not found: %s' % _id, file=self.stderr)
return 3
if not audio_to_remove.url:
- print >>self.stderr, 'Error: the direct URL is not available.'
+ print('Error: the direct URL is not available.', file=self.stderr)
return 4
for audio in self.PLAYLIST:
@@ -369,7 +371,7 @@ def do_playlist(self, line):
self.cached_format(audio)
else:
- print >>self.stderr, 'Playlist command only support "add", "remove", "display" and "export" arguments.'
+ print('Playlist command only support "add", "remove", "display" and "export" arguments.', file=self.stderr)
return 2
def complete_info(self, text, line, *ignored):
@@ -384,7 +386,7 @@ def do_info(self, _id):
Get information about a radio or an audio file.
"""
if not _id:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
obj = self.retrieve_obj(_id)
@@ -395,7 +397,7 @@ def do_info(self, _id):
self.set_formatter('playlist_tracks_list_info')
if obj is None:
- print >>self.stderr, 'No object matches with this id:', _id
+ print('No object matches with this id:', _id, file=self.stderr)
return 3
self.format(obj)
@@ -411,7 +413,7 @@ def do_search(self, pattern=None):
"""
if not pattern:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
+ print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
return 2
cmd, args = self.parse_command_args(pattern, 2, req_n=1)
@@ -446,7 +448,7 @@ def do_search(self, pattern=None):
self.format(playlist)
else:
- print >>self.stderr, 'Search command only supports "radio", "song", "album" and "playlist" arguments.'
+ print('Search command only supports "radio", "song", "album" and "playlist" arguments.', file=self.stderr)
return 2
def do_ls(self, line):
diff --git a/weboob/applications/suboob/suboob.py b/weboob/applications/suboob/suboob.py
index 7d7975a4b0f1bb0d3255979519aa88ba48612207..bef74d65c82ecde68bafdd7008f396fac932a9e7 100644
--- a/weboob/applications/suboob/suboob.py
+++ b/weboob/applications/suboob/suboob.py
@@ -17,8 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
-
+from __future__ import print_function
from weboob.capabilities.subtitle import CapSubtitle
from weboob.capabilities.base import empty
@@ -113,7 +112,7 @@ def do_info(self, id):
subtitle = self.get_object(id, 'get_subtitle')
if not subtitle:
- print >>self.stderr, 'Subtitle not found: %s' % id
+ print('Subtitle not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@@ -138,7 +137,7 @@ def do_download(self, line):
subtitle = self.get_object(id, 'get_subtitle')
if not subtitle:
- print >>self.stderr, 'Subtitle not found: %s' % id
+ print('Subtitle not found: %s' % id, file=self.stderr)
return 3
if dest is None:
@@ -156,10 +155,10 @@ def do_download(self, line):
with open(dest, 'w') as f:
f.write(buf)
except IOError as e:
- print >>self.stderr, 'Unable to write file in "%s": %s' % (dest, e)
+ print('Unable to write file in "%s": %s' % (dest, e), file=self.stderr)
return 1
else:
- print 'Saved to %s' % dest
+ print('Saved to %s' % dest)
return
@defaultcount(10)
diff --git a/weboob/applications/translaboob/translaboob.py b/weboob/applications/translaboob/translaboob.py
index de5177ce06b13a789b71979f7dfa3d3f97c68237..b496f49cfb895e793a368b67d7b8953bacc3b037 100644
--- a/weboob/applications/translaboob/translaboob.py
+++ b/weboob/applications/translaboob/translaboob.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from weboob.capabilities.translate import CapTranslate, TranslationFail, LanguageNotSupported
from weboob.tools.application.repl import ReplApplication
@@ -114,5 +115,5 @@ def do_translate(self, line):
for backend, translation in self.do('translate', self.LANGUAGE[lan_from], self.LANGUAGE[lan_to], text):
self.format(translation)
except (TranslationFail, LanguageNotSupported) as error:
- print >>self.stderr, error
+ print(error, file=self.stderr)
pass
diff --git a/weboob/applications/traveloob/__init__.py b/weboob/applications/traveloob/__init__.py
index 1594d0fd2910b358a2ce17493a5bca21edda8cb2..d0e1258a29c6942b719ff8699f8ce80d04074487 100644
--- a/weboob/applications/traveloob/__init__.py
+++ b/weboob/applications/traveloob/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2011 Romain Bignon
#
diff --git a/weboob/applications/traveloob/traveloob.py b/weboob/applications/traveloob/traveloob.py
index a9e0e3eeb84319430177d447825d1b0d18d58714..f715e9f7bd224388a8c54202f292713c63d6d2a2 100644
--- a/weboob/applications/traveloob/traveloob.py
+++ b/weboob/applications/traveloob/traveloob.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import datetime
@@ -104,7 +105,7 @@ def do_departures(self, line):
if arrival:
arrival_id, backend_name2 = self.parse_id(arrival)
if backend_name and backend_name2 and backend_name != backend_name2:
- print >>self.stderr, 'Departure and arrival aren\'t on the same backend'
+ print('Departure and arrival aren\'t on the same backend', file=self.stderr)
return 1
else:
arrival_id = backend_name2 = None
@@ -120,8 +121,8 @@ def do_departures(self, line):
try:
date = self.parse_datetime(date)
except ValueError as e:
- print >>self.stderr, 'Invalid datetime value: %s' % e
- print >>self.stderr, 'Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".'
+ print('Invalid datetime value: %s' % e, file=self.stderr)
+ print('Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".', file=self.stderr)
return 1
for backend, departure in self.do('iter_station_departures', station_id, arrival_id, date, backends=backends):
@@ -149,8 +150,8 @@ def do_roadmap(self, line):
filters.departure_time = self.parse_datetime(self.options.departure_time)
filters.arrival_time = self.parse_datetime(self.options.arrival_time)
except ValueError as e:
- print >>self.stderr, 'Invalid datetime value: %s' % e
- print >>self.stderr, 'Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".'
+ print('Invalid datetime value: %s' % e, file=self.stderr)
+ print('Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".', file=self.stderr)
return 1
for backend, route in self.do('iter_roadmap', departure, arrival, filters):
diff --git a/weboob/applications/videoob/videoob.py b/weboob/applications/videoob/videoob.py
index 6104bac255bfff3502e83fc82fce43ec9341713f..de8a5e426809acac8eb3070b27842c3f7aea9898 100644
--- a/weboob/applications/videoob/videoob.py
+++ b/weboob/applications/videoob/videoob.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import requests
import subprocess
@@ -76,14 +77,14 @@ def main(self, argv):
def download(self, video, dest, default=None):
if not video.url:
- print >>self.stderr, 'Error: the direct URL is not available.'
+ print('Error: the direct URL is not available.', file=self.stderr)
return 4
def check_exec(executable):
with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0:
- print >>self.stderr, 'Please install "%s"' % executable
+ print('Please install "%s"' % executable, file=self.stderr)
return False
return True
@@ -146,7 +147,7 @@ def do_download(self, line):
_id, dest = self.parse_command_args(line, 2, 1)
video = self.get_object(_id, 'get_video', ['url'])
if not video:
- print >>self.stderr, 'Video not found: %s' % _id
+ print('Video not found: %s' % _id, file=self.stderr)
return 3
return self.download(video, dest)
@@ -163,7 +164,7 @@ def do_play(self, line):
Play a video with a found player.
"""
if not line:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('play', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('play', short=True), file=self.stderr)
return 2
ret = 0
@@ -177,10 +178,10 @@ def do_play(self, line):
def play(self, video, _id):
if not video:
- print >>self.stderr, 'Video not found: %s' % _id
+ print('Video not found: %s' % _id, file=self.stderr)
return 3
if not video.url:
- print >>self.stderr, 'Error: the direct URL is not available.'
+ print('Error: the direct URL is not available.', file=self.stderr)
return 4
try:
player_name = self.config.get('media_player')
@@ -190,7 +191,7 @@ def play(self, video, _id):
'configuration file.')
self.player.play(video, player_name=player_name, player_args=media_player_args)
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
- print '%s\nVideo URL: %s' % (e, video.url)
+ print('%s\nVideo URL: %s' % (e, video.url))
def complete_info(self, text, line, *ignored):
args = line.split(' ')
@@ -204,14 +205,14 @@ def do_info(self, line):
Get information about a video.
"""
if not line:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
self.start_format()
for _id in line.split(' '):
video = self.get_object(_id, 'get_video')
if not video:
- print >>self.stderr, 'Video not found: %s' % _id
+ print('Video not found: %s' % _id, file=self.stderr)
return 3
self.format(video)
@@ -239,11 +240,11 @@ def do_playlist(self, line):
"""
if not self.interactive:
- print >>self.stderr, 'This command can be used only in interactive mode.'
+ print('This command can be used only in interactive mode.', file=self.stderr)
return 1
if not line:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
+ print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
return 2
cmd, args = self.parse_command_args(line, 2, req_n=1)
@@ -253,11 +254,11 @@ def do_playlist(self, line):
video = self.get_object(_id, 'get_video')
if not video:
- print >>self.stderr, 'Video not found: %s' % _id
+ print('Video not found: %s' % _id, file=self.stderr)
return 3
if not video.url:
- print >>self.stderr, 'Error: the direct URL is not available.'
+ print('Error: the direct URL is not available.', file=self.stderr)
return 4
self.PLAYLIST.append(video)
@@ -267,11 +268,11 @@ def do_playlist(self, line):
video_to_remove = self.get_object(_id, 'get_video')
if not video_to_remove:
- print >>self.stderr, 'Video not found: %s' % _id
+ print('Video not found: %s' % _id, file=self.stderr)
return 3
if not video_to_remove.url:
- print >>self.stderr, 'Error: the direct URL is not available.'
+ print('Error: the direct URL is not available.', file=self.stderr)
return 4
for video in self.PLAYLIST:
@@ -297,7 +298,7 @@ def do_playlist(self, line):
for video in self.PLAYLIST:
self.play(video, video.id)
else:
- print >>self.stderr, 'Playlist command only support "add", "remove", "display", "download" and "export" arguments.'
+ print('Playlist command only support "add", "remove", "display", "download" and "export" arguments.', file=self.stderr)
return 2
def complete_nsfw(self, text, line, begidx, endidx):
@@ -318,10 +319,10 @@ def do_nsfw(self, line):
elif line == 'off':
self.nsfw = False
else:
- print 'Invalid argument "%s".' % line
+ print('Invalid argument "%s".' % line)
return 2
else:
- print "on" if self.nsfw else "off"
+ print("on" if self.nsfw else "off")
@defaultcount()
def do_search(self, pattern):
@@ -331,7 +332,7 @@ def do_search(self, pattern):
Search for videos matching a PATTERN.
"""
if not pattern:
- print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('search', short=True)
+ print('This command takes an argument: %s' % self.get_command_help('search', short=True), file=self.stderr)
return 2
self.change_path([u'search'])
diff --git a/weboob/applications/webcontentedit/webcontentedit.py b/weboob/applications/webcontentedit/webcontentedit.py
index 13df118d4efbd89848f4cd974393d1cfe8f59187..d2a980f77e92165386025527e65a495df7ee260c 100644
--- a/weboob/applications/webcontentedit/webcontentedit.py
+++ b/weboob/applications/webcontentedit/webcontentedit.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import os
import tempfile
@@ -53,7 +54,7 @@ def do_edit(self, line):
contents += [content for backend, content in self.do('get_content', _id, backends=backend_names) if content]
if len(contents) == 0:
- print >>self.stderr, 'No contents found'
+ print('No contents found', file=self.stderr)
return 3
if self.stdin.isatty():
@@ -92,10 +93,10 @@ def do_edit(self, line):
contents.remove(content)
if len(contents) == 0:
- print >>self.stderr, 'No changes. Abort.'
+ print('No changes. Abort.', file=self.stderr)
return 1
- print 'Contents changed:\n%s' % ('\n'.join(' * %s' % content.id for content in contents))
+ print('Contents changed:\n%s' % ('\n'.join(' * %s' % content.id for content in contents)))
message = self.ask('Enter a commit message', default='')
minor = self.ask('Is this a minor edit?', default=False)
@@ -119,7 +120,7 @@ def do_edit(self, line):
# stdin is not a tty
if len(contents) != 1:
- print >>self.stderr, "Multiple ids not supported with pipe"
+ print("Multiple ids not supported with pipe", file=self.stderr)
return 2
message, minor = '', False
@@ -149,7 +150,7 @@ def do_log(self, line):
Display log of a page
"""
if not line:
- print >>self.stderr, 'Error: please give a page ID'
+ print('Error: please give a page ID', file=self.stderr)
return 2
_id, backend_name = self.parse_id(line)
@@ -168,7 +169,7 @@ def do_get(self, line):
Get page contents
"""
if not line:
- print >>self.stderr, 'Error: please give a page ID'
+ print('Error: please give a page ID', file=self.stderr)
return 2
_part_line = line.strip().split(' ')
@@ -181,7 +182,7 @@ def do_get(self, line):
_part_line.remove('-r')
if not _part_line:
- print >>self.stderr, 'Error: please give a page ID'
+ print('Error: please give a page ID', file=self.stderr)
return 2
_id, backend_name = self.parse_id(" ".join(_part_line))
diff --git a/weboob/applications/weboobcfg/weboobcfg.py b/weboob/applications/weboobcfg/weboobcfg.py
index f18f8d4ddacef9e0a9a50189860d549c9456bd36..d38cdcabf63965a7c435cef1fd6c52c263b2a74b 100644
--- a/weboob/applications/weboobcfg/weboobcfg.py
+++ b/weboob/applications/weboobcfg/weboobcfg.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
import os
import re
@@ -52,7 +53,7 @@ def do_add(self, line):
Add a backend.
"""
if not line:
- print >>self.stderr, 'You must specify a module name. Hint: use the "modules" command.'
+ print('You must specify a module name. Hint: use the "modules" command.', file=self.stderr)
return 2
name, options = self.parse_command_args(line, 2, 1)
if options:
@@ -66,7 +67,7 @@ def do_add(self, line):
try:
key, value = option.split('=', 1)
except ValueError:
- print >>self.stderr, 'Parameters have to be formatted "key=value"'
+ print('Parameters have to be formatted "key=value"', file=self.stderr)
return 2
params[key] = value
@@ -96,16 +97,16 @@ def do_confirm(self, backend_name):
try:
backend = self.weboob.get_backend(backend_name)
except KeyError:
- print >>self.stderr, 'Error: backend "%s" not found.' % backend_name
+ print('Error: backend "%s" not found.' % backend_name, file=self.stderr)
return 1
if not backend.has_caps(CapAccount):
- print >>self.stderr, 'Error: backend "%s" does not support accounts management' % backend_name
+ print('Error: backend "%s" does not support accounts management' % backend_name, file=self.stderr)
return 1
mail = self.acquire_input()
if not backend.confirm_account(mail):
- print >>self.stderr, 'Error: Unable to confirm account creation'
+ print('Error: Unable to confirm account creation', file=self.stderr)
return 1
return 0
@@ -141,14 +142,14 @@ def do_remove(self, instance_name):
Remove a backend.
"""
if not self.weboob.backends_config.remove_backend(instance_name):
- print >>self.stderr, 'Backend instance "%s" does not exist' % instance_name
+ print('Backend instance "%s" does not exist' % instance_name, file=self.stderr)
return 1
def _do_toggle(self, name, state):
try:
bname, items = self.weboob.backends_config.get_backend(name)
except KeyError:
- print >>self.stderr, 'Backend instance "%s" does not exist' % name
+ print('Backend instance "%s" does not exist' % name, file=self.stderr)
return 1
self.weboob.backends_config.edit_backend(name, bname, {'_enabled': state})
@@ -177,7 +178,7 @@ def do_edit(self, line):
try:
self.edit_backend(line)
except KeyError:
- print >>self.stderr, 'Error: backend "%s" not found' % line
+ print('Error: backend "%s" not found' % line, file=self.stderr)
return 1
def do_modules(self, line):
@@ -201,12 +202,12 @@ def do_info(self, line):
Display information about a module.
"""
if not line:
- print >>self.stderr, 'You must specify a module name. Hint: use the "modules" command.'
+ print('You must specify a module name. Hint: use the "modules" command.', file=self.stderr)
return 2
minfo = self.weboob.repositories.get_module_info(line)
if not minfo:
- print >>self.stderr, 'Module "%s" does not exist.' % line
+ print('Module "%s" does not exist.' % line, file=self.stderr)
return 1
try:
@@ -214,16 +215,16 @@ def do_info(self, line):
except ModuleLoadError:
module = None
- print '.------------------------------------------------------------------------------.'
- print '| Module %-69s |' % minfo.name
- print "+-----------------.------------------------------------------------------------'"
- print '| Version | %s' % minfo.version
- print '| Maintainer | %s' % minfo.maintainer
- print '| License | %s' % minfo.license
- print '| Description | %s' % minfo.description
- print '| Capabilities | %s' % ', '.join(minfo.capabilities)
- print '| Installed | %s%s' % (('yes' if module else 'no'), ' (new version available)' if self.weboob.repositories.versions.get(minfo.name) > minfo.version else '')
- print '| Location | %s' % (minfo.url or os.path.join(minfo.path, minfo.name))
+ print('.------------------------------------------------------------------------------.')
+ print('| Module %-69s |' % minfo.name)
+ print("+-----------------.------------------------------------------------------------'")
+ print('| Version | %s' % minfo.version)
+ print('| Maintainer | %s' % minfo.maintainer)
+ print('| License | %s' % minfo.license)
+ print('| Description | %s' % minfo.description)
+ print('| Capabilities | %s' % ', '.join(minfo.capabilities))
+ print('| Installed | %s%s' % (('yes' if module else 'no'), ' (new version available)' if self.weboob.repositories.versions.get(minfo.name) > minfo.version else ''))
+ print('| Location | %s' % (minfo.url or os.path.join(minfo.path, minfo.name)))
if module:
first = True
for key, field in module.config.iteritems():
@@ -231,12 +232,12 @@ def do_info(self, line):
if not field.default is None:
value += ' (default: %s)' % field.default
if first:
- print '| | '
- print '| Configuration | %s: %s' % (key, value)
+ print('| | ')
+ print('| Configuration | %s: %s' % (key, value))
first = False
else:
- print '| | %s: %s' % (key, value)
- print "'-----------------'"
+ print('| | %s: %s' % (key, value))
+ print("'-----------------'")
def do_applications(self, line):
"""
@@ -252,7 +253,7 @@ def do_applications(self, line):
m = regexp.match(root)
if m and '__init__.py' in files:
applications.add(m.group(1))
- print ' '.join(sorted(applications)).encode('utf-8')
+ print(' '.join(sorted(applications)).encode('utf-8'))
def do_update(self, line):
"""
diff --git a/weboob/applications/weboobcli/weboobcli.py b/weboob/applications/weboobcli/weboobcli.py
index 3503a88d2839426afab070cd408643648a4b0243..9ce161635e0d29c16dc2a0af3012820a0d6b2aa4 100644
--- a/weboob/applications/weboobcli/weboobcli.py
+++ b/weboob/applications/weboobcli/weboobcli.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
+from __future__ import print_function
from weboob.tools.application.repl import ReplApplication
@@ -41,7 +41,7 @@ def load_default_backends(self):
def main(self, argv):
if len(argv) < 3:
- print >>self.stderr, "Syntax: %s capability method [args ..]" % argv[0]
+ print("Syntax: %s capability method [args ..]" % argv[0], file=self.stderr)
return 2
cap_s = argv[1]
diff --git a/weboob/applications/weboobdebug/weboobdebug.py b/weboob/applications/weboobdebug/weboobdebug.py
index 53b3a45690c794d46e21628142ca4703f32e13e5..d5539e2a5ff28995e5eefd84ae43be0576fac2e6 100644
--- a/weboob/applications/weboobdebug/weboobdebug.py
+++ b/weboob/applications/weboobdebug/weboobdebug.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
+from __future__ import print_function
from optparse import OptionGroup
@@ -48,12 +49,12 @@ def main(self, argv):
try:
backend_name = argv[1]
except IndexError:
- print >>self.stderr, 'Usage: %s BACKEND' % argv[0]
+ print('Usage: %s BACKEND' % argv[0], file=self.stderr)
return 1
try:
backend = self.weboob.load_backends(names=[backend_name])[backend_name]
except KeyError:
- print >>self.stderr, u'Unable to load backend "%s"' % backend_name
+ print(u'Unable to load backend "%s"' % backend_name, file=self.stderr)
return 1
locs = dict(backend=backend, browser=backend.browser, application=self, weboob=self.weboob)
diff --git a/weboob/applications/weboobrepos/weboobrepos.py b/weboob/applications/weboobrepos/weboobrepos.py
index bad843a7741f252062127716cc64004f4817cb7a..6daf3c0861f642291505e4801310191516935e3b 100644
--- a/weboob/applications/weboobrepos/weboobrepos.py
+++ b/weboob/applications/weboobrepos/weboobrepos.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
+from __future__ import print_function
from datetime import datetime
from time import mktime, strptime
@@ -69,14 +69,14 @@ def do_create(self, line):
if not os.path.exists(path):
os.mkdir(path)
elif not os.path.isdir(path):
- print u'"%s" is not a directory' % path
+ print(u'"%s" is not a directory' % path)
return 1
r = Repository('http://')
r.name = name
r.maintainer = self.ask('Enter maintainer of the repository')
r.save(os.path.join(path, r.INDEX))
- print u'Repository "%s" created.' % path
+ print(u'Repository "%s" created.' % path)
def do_build(self, line):
"""
@@ -95,8 +95,8 @@ def do_build(self, line):
with open(index_file, 'r') as fp:
r.parse_index(fp)
except IOError as e:
- print >>self.stderr, 'Unable to open repository: %s' % e
- print >>self.stderr, 'Use the "create" command before.'
+ print('Unable to open repository: %s' % e, file=self.stderr)
+ print('Use the "create" command before.', file=self.stderr)
return 1
r.build_index(source_path, index_file)
@@ -110,13 +110,13 @@ def do_build(self, line):
if os.path.exists(krname):
kr_mtime = int(datetime.fromtimestamp(os.path.getmtime(krname)).strftime('%Y%m%d%H%M'))
if not os.path.exists(krname) or kr_mtime < r.key_update:
- print 'Generate keyring'
+ print('Generate keyring')
# Remove all existing keys
if os.path.exists(krname):
os.remove(krname)
# Add all valid keys
for keyfile in os.listdir(os.path.join(source_path, r.KEYDIR)):
- print 'Adding key %s' % keyfile
+ print('Adding key %s' % keyfile)
keypath = os.path.join(source_path, r.KEYDIR, keyfile)
subprocess.check_call([
gpg,
@@ -134,7 +134,7 @@ def do_build(self, line):
os.chmod(krname, 0o644)
os.utime(krname, (kr_mtime, kr_mtime))
else:
- print 'Keyring is up to date'
+ print('Keyring is up to date')
for name, module in r.modules.iteritems():
tarname = os.path.join(repo_path, '%s.tar.gz' % name)
@@ -146,7 +146,7 @@ def do_build(self, line):
if tar_mtime >= module.version:
continue
- print 'Create archive for %s' % name
+ print('Create archive for %s' % name)
with closing(tarfile.open(tarname, 'w:gz')) as tar:
tar.add(module_path, arcname=name, exclude=self._archive_excludes)
tar_mtime = mktime(strptime(str(module.version), '%Y%m%d%H%M'))
@@ -195,7 +195,7 @@ def do_build(self, line):
if os.path.exists(sigpath):
sig_mtime = int(os.path.getmtime(sigpath))
if not os.path.exists(sigpath) or sig_mtime < file_mtime:
- print 'Signing %s' % filename
+ print('Signing %s' % filename)
if os.path.exists(sigpath):
os.remove(sigpath)
subprocess.check_call([
@@ -207,7 +207,7 @@ def do_build(self, line):
'--output', sigpath,
'--sign', filepath])
os.utime(sigpath, (file_mtime, file_mtime))
- print 'Signatures are up to date'
+ print('Signatures are up to date')
@staticmethod
def _find_gpg():
diff --git a/weboob/applications/weboorrents/weboorrents.py b/weboob/applications/weboorrents/weboorrents.py
index b79ca8fa9b214c0254c982c70229ff67a8eb895e..aacfe5212888d6b9a598e31e80ae987393816131 100644
--- a/weboob/applications/weboorrents/weboorrents.py
+++ b/weboob/applications/weboorrents/weboorrents.py
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see .
-
+from __future__ import print_function
from weboob.capabilities.torrent import CapTorrent, MagnetOnly
from weboob.tools.application.repl import ReplApplication, defaultcount
@@ -116,7 +116,7 @@ def do_info(self, id):
"""
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 @@ def do_getfile(self, line):
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 @@ def do_getfile(self, line):
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)