Use the print function everywhere
python modernize.py --no-six -f libmodernize.fixes.fix_print -w With manual fixes as the import was put always on top.
This commit is contained in:
parent
d22656308a
commit
74a4ef6723
43 changed files with 499 additions and 442 deletions
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
import re
|
||||
|
|
@ -119,7 +120,7 @@ class Event(object):
|
|||
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 @@ class Event(object):
|
|||
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 @@ class Event(object):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
|
||||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
"""
|
||||
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 @@ class Boobathon(ReplApplication):
|
|||
"""
|
||||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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 @@ class Boobathon(ReplApplication):
|
|||
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):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2013 Bezleputh
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from datetime import time, datetime
|
||||
|
||||
from weboob.tools.date import parse_date
|
||||
|
|
@ -178,10 +180,10 @@ class Boobcoming(ReplApplication):
|
|||
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 @@ class Boobcoming(ReplApplication):
|
|||
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 @@ class Boobcoming(ReplApplication):
|
|||
"""
|
||||
|
||||
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 @@ class Boobcoming(ReplApplication):
|
|||
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 @@ class Boobcoming(ReplApplication):
|
|||
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 @@ class Boobcoming(ReplApplication):
|
|||
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 @@ class Boobcoming(ReplApplication):
|
|||
"""
|
||||
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
#
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
|
@ -86,9 +87,9 @@ class Boobill(ReplApplication):
|
|||
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 @@ class Boobill(ReplApplication):
|
|||
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 @@ class Boobill(ReplApplication):
|
|||
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 @@ class Boobill(ReplApplication):
|
|||
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
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from weboob.capabilities.lyrics import CapLyrics
|
||||
from weboob.capabilities.base import empty
|
||||
|
|
@ -84,7 +83,7 @@ class Booblyrics(ReplApplication):
|
|||
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import datetime
|
||||
|
|
@ -288,14 +289,14 @@ class Boobmsg(ReplApplication):
|
|||
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 @@ class Boobmsg(ReplApplication):
|
|||
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 @@ class Boobmsg(ReplApplication):
|
|||
"""
|
||||
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 @@ class Boobmsg(ReplApplication):
|
|||
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 @@ class Boobmsg(ReplApplication):
|
|||
"""
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from weboob.capabilities.library import CapBook, Book
|
||||
from weboob.tools.application.repl import ReplApplication
|
||||
from weboob.tools.application.formatters.iformatter import PrettyFormatter
|
||||
|
|
@ -62,7 +64,7 @@ class Boobooks(ReplApplication):
|
|||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from weboob.capabilities.base import empty
|
||||
from weboob.capabilities.gauge import CapGauge, SensorNotFound
|
||||
|
|
@ -110,7 +111,7 @@ class Boobsize(ReplApplication):
|
|||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from datetime import timedelta
|
||||
from email import message_from_string, message_from_file
|
||||
|
|
@ -156,7 +157,7 @@ class BoobTracker(ReplApplication):
|
|||
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 @@ class BoobTracker(ReplApplication):
|
|||
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 @@ class BoobTracker(ReplApplication):
|
|||
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 @@ class BoobTracker(ReplApplication):
|
|||
|
||||
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 @@ Weboob Team
|
|||
--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 @@ Weboob Team
|
|||
_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 @@ Weboob Team
|
|||
|
||||
Attach a file to an issue (Not implemented yet).
|
||||
"""
|
||||
print >>self.stderr, 'Not implemented yet.'
|
||||
print('Not implemented yet.', file=self.stderr)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
|
@ -230,11 +230,11 @@ class Cineoob(ReplApplication):
|
|||
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
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 @@ class Cineoob(ReplApplication):
|
|||
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 @@ class Cineoob(ReplApplication):
|
|||
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
"""
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
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 @@ class Cineoob(ReplApplication):
|
|||
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
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 @@ class Cineoob(ReplApplication):
|
|||
"""
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
|
||||
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 @@ class Cineoob(ReplApplication):
|
|||
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 @@ class Cineoob(ReplApplication):
|
|||
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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
||||
|
||||
|
||||
from .comparoob import Comparoob
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from weboob.capabilities.pricecomparison import CapPriceComparison
|
||||
from weboob.tools.html import html2text
|
||||
|
|
@ -108,18 +106,18 @@ class Comparoob(ReplApplication):
|
|||
|
||||
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 @@ class Comparoob(ReplApplication):
|
|||
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()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import codecs
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ class Cookboob(ReplApplication):
|
|||
"""
|
||||
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 @@ class Cookboob(ReplApplication):
|
|||
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 @@ class Cookboob(ReplApplication):
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from weboob.capabilities.housing import CapHousing, Query
|
||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||
|
|
@ -104,7 +105,7 @@ class Flatboob(ReplApplication):
|
|||
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 @@ class Flatboob(ReplApplication):
|
|||
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 @@ class Flatboob(ReplApplication):
|
|||
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 @@ class Flatboob(ReplApplication):
|
|||
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 @@ class Flatboob(ReplApplication):
|
|||
|
||||
_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 @@ class Flatboob(ReplApplication):
|
|||
"""
|
||||
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 @@ class Flatboob(ReplApplication):
|
|||
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()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
from re import search, sub
|
||||
|
|
@ -67,7 +67,7 @@ class Galleroob(ReplApplication):
|
|||
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 @@ class Galleroob(ReplApplication):
|
|||
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 @@ class Galleroob(ReplApplication):
|
|||
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 @@ class Galleroob(ReplApplication):
|
|||
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 @@ class Galleroob(ReplApplication):
|
|||
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
#
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from weboob.capabilities.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]):
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from weboob.capabilities.job import CapJob
|
||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||
|
|
@ -122,13 +123,13 @@ class Handjoob(ReplApplication):
|
|||
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()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from copy import copy
|
||||
|
||||
|
|
@ -87,11 +88,11 @@ class HaveDate(Boobmsg):
|
|||
_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 @@ class HaveDate(Boobmsg):
|
|||
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 @@ class HaveDate(Boobmsg):
|
|||
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 @@ class HaveDate(Boobmsg):
|
|||
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):
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue