pax_global_header 0000666 0000000 0000000 00000000064 13507732167 0014525 g ustar 00root root 0000000 0000000 52 comment=387a3e3cdc31032e63b3c0e660d6629e91b6ccdd
woob-387a3e3cdc31032e63b3c0e660d6629e91b6ccdd-weboob-applications-boobooks/ 0000775 0000000 0000000 00000000000 13507732167 0025316 5 ustar 00root root 0000000 0000000 woob-387a3e3cdc31032e63b3c0e660d6629e91b6ccdd-weboob-applications-boobooks/weboob/ 0000775 0000000 0000000 00000000000 13507732167 0026573 5 ustar 00root root 0000000 0000000 woob-387a3e3cdc31032e63b3c0e660d6629e91b6ccdd-weboob-applications-boobooks/weboob/applications/ 0000775 0000000 0000000 00000000000 13507732167 0031261 5 ustar 00root root 0000000 0000000 boobooks/ 0000775 0000000 0000000 00000000000 13507732167 0033017 5 ustar 00root root 0000000 0000000 woob-387a3e3cdc31032e63b3c0e660d6629e91b6ccdd-weboob-applications-boobooks/weboob/applications __init__.py 0000664 0000000 0000000 00000001431 13507732167 0035127 0 ustar 00root root 0000000 0000000 woob-387a3e3cdc31032e63b3c0e660d6629e91b6ccdd-weboob-applications-boobooks/weboob/applications/boobooks # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Jérémy Monnet
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with weboob. If not, see .
from .boobooks import Boobooks
__all__ = ['Boobooks']
boobooks.py 0000664 0000000 0000000 00000005454 13507732167 0035216 0 ustar 00root root 0000000 0000000 woob-387a3e3cdc31032e63b3c0e660d6629e91b6ccdd-weboob-applications-boobooks/weboob/applications/boobooks # -*- coding: utf-8 -*-
# Copyright(C) 2009-2012 Jeremy Monnet
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser 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
__all__ = ['Boobooks']
class RentedListFormatter(PrettyFormatter):
MANDATORY_FIELDS = ('id', 'date', 'author', 'name', 'late')
RED = '[1;31m'
def get_title(self, obj):
s = u'%s — %s (%s)' % (obj.author, obj.name, obj.date)
if obj.late:
s += u' %sLATE!%s' % (self.RED, self.NC)
return s
class Boobooks(ReplApplication):
APPNAME = 'boobooks'
VERSION = '1.6'
COPYRIGHT = 'Copyright(C) 2012-YEAR Jeremy Monnet'
CAPS = CapBook
DESCRIPTION = "Console application allowing to list your books rented or booked at the library, " \
"book and search new ones, get your booking history (if available)."
SHORT_DESCRIPTION = "manage rented books"
EXTRA_FORMATTERS = {'rented_list': RentedListFormatter,
}
DEFAULT_FORMATTER = 'table'
COMMANDS_FORMATTERS = {'ls': 'rented_list',
'list': 'rented_list',
'rented': 'rented_list',
}
COLLECTION_OBJECTS = (Book, )
def do_renew(self, id):
"""
renew ID
Renew a book
"""
id, backend_name = self.parse_id(id)
if not id:
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
for renew in self.do('renew_book', id, backends=names):
self.format(renew)
def do_rented(self, args):
"""
rented
List rented books
"""
for book in self.do('iter_rented', backends=None):
self.format(book)
def do_search(self, pattern):
"""
search PATTERN
Search books
"""
for book in self.do('search_books', pattern):
self.format(book)