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, site_book_publish, changes=None):
21 raise NotImplementedError()
23 def get_description(self, wlbook, description_add=''):
26 if wlbook.meta.audience in ('L', 'SP1', 'SP2', 'SP3', 'SP4'):
27 description += '<p><em>{}</em> to lektura szkolna.'.format(wlbook.meta.title)
28 if wlbook.tree.find('//pe') is not None:
29 description += '<br>Ebook <em>{title}</em> zawiera przypisy opracowane specjalnie dla uczennic i uczniów {school}.'.format(
30 title=wlbook.meta.title,
31 school='szkoły podstawowej' if wlbook.meta.audience.startswith('SP') else 'liceum i technikum'
33 description += '</p>\n'
35 abstract = wlbook.tree.find('.//abstrakt')
36 if abstract is not None:
37 description += transform_abstrakt(abstract)
38 description += description_add
40 description += ', '.join(
41 '<a href="https://wolnelektury.pl/katalog/autor/{}/">{}</a>'.format(
42 slugify(p.readable()),
45 for p in wlbook.meta.authors
47 description += '<a href="https://wolnelektury.pl/katalog/lektura/{}/">{}</a><br>'.format(
51 if wlbook.meta.translators:
52 description += 'tłum. ' + ', '.join(p.readable() for p in wlbook.meta.translators) + '<br>'
53 description += 'Epoka: ' + ', '.join(
54 '<a href="https://wolnelektury.pl/katalog/epoka/{}/">{}</a>'.format(
58 for p in wlbook.meta.epochs
60 description += 'Rodzaj: ' + ', '.join(
61 '<a href="https://wolnelektury.pl/katalog/rodzaj/{}/">{}</a>'.format(
65 for p in wlbook.meta.kinds
67 description += 'Gatunek: ' + ', '.join(
68 '<a href="https://wolnelektury.pl/katalog/gatunek/{}/">{}</a>'.format(
72 for p in wlbook.meta.genres