2 from librarian.html import transform_abstrakt
3 from slugify import slugify
7 def __init__(self, username, password, publisher_handle):
8 self.username = username
9 self.password = password
10 self.publisher_handle = publisher_handle
15 if self._session is None:
16 self._session = requests.Session()
20 def send_book(self, shop, book, changes=None):
21 raise NotImplementedError()
23 def get_description(self, wlbook, description_add=''):
25 abstract = wlbook.tree.find('.//abstrakt')
26 if abstract is not None:
27 description = transform_abstrakt(abstract)
28 description += description_add
30 description += ', '.join(
31 '<a href="https://wolnelektury.pl/katalog/autor/{}/">{}</a>'.format(
32 slugify(p.readable()),
35 for p in wlbook.meta.authors
37 description += '<a href="https://wolnelektury.pl/katalog/lektura/{}/">{}</a><br>'.format(
41 if wlbook.meta.translators:
42 description += 'tłum. ' + ', '.join(p.readable() for p in wlbook.meta.translators) + '<br>'
43 description += 'Epoka: ' + ', '.join(
44 '<a href="https://wolnelektury.pl/katalog/epoka/{}/">{}</a>'.format(
48 for p in wlbook.meta.epochs
50 description += 'Rodzaj: ' + ', '.join(
51 '<a href="https://wolnelektury.pl/katalog/rodzaj/{}/">{}</a>'.format(
55 for p in wlbook.meta.kinds
57 description += 'Gatunek: ' + ', '.join(
58 '<a href="https://wolnelektury.pl/katalog/gatunek/{}/">{}</a>'.format(
62 for p in wlbook.meta.genres
65 # TODO: Move away from using audiences for this.
66 if wlbook.meta.audience in ('L', 'SP1', 'SP2', 'SP3', 'SP4'):
67 description += '<p><em>{}</em> to lektura szkolna.'.format(wlbook.meta.title)
68 if wlbook.tree.find('//pe') is not None:
69 description += '<br>Ebook <em>{title}</em> zawiera przypisy opracowane specjalnie dla uczennic i uczniów {school}.'.format(
70 title=wlbook.meta.title,
71 school='szkoły podstawowej' if wlbook.meta.audience.startswith('SP') else 'liceum i technikum'