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()),
44 ) if p is not None else ''
45 for p in wlbook.meta.authors
47 if wlbook.meta.url is not None:
48 description += '<a href="https://wolnelektury.pl/katalog/lektura/{}/">{}</a><br>'.format(
52 if wlbook.meta.translators:
53 description += 'tłum. ' + ', '.join(p.readable() for p in wlbook.meta.translators) + '<br>'
54 description += 'Epoka: ' + ', '.join(
55 '<a href="https://wolnelektury.pl/katalog/epoka/{}/">{}</a>'.format(
58 ) if p is not None else ''
59 for p in wlbook.meta.epochs
61 description += 'Rodzaj: ' + ', '.join(
62 '<a href="https://wolnelektury.pl/katalog/rodzaj/{}/">{}</a>'.format(
65 ) if p is not None else ''
66 for p in wlbook.meta.kinds
68 description += 'Gatunek: ' + ', '.join(
69 '<a href="https://wolnelektury.pl/katalog/gatunek/{}/">{}</a>'.format(
72 ) if p is not None else ''
73 for p in wlbook.meta.genres