Пример #1
0
    def test_author(self):
        urls = (
            ("http://samlib.ru/p/pupkin_wasja_ibragimowich/indexdate.shtml",
             "Ясинский Анджей"),
            ("http://samlib.ru/e/elxterrus_i/", "Эльтеррус Иар"),
            ("http://samlib.ru/x/xgulliver/", "Gulliver"),
            ("http://samlib.ru/m/muhin_d_w/", "Zang"),
            ("http://zhurnal.lib.ru/z/zajcew_aleskandr/", "Зайцев Алескандр"),
        )
        for url, name in urls:
            author = core.create_author(url=url)
            self.assertEqual(author.name, name)

            books = models.Book.get_by_author(author, only_new=True)
            self.assertGreater(len(books), 0)

            core.book_read(books[0])
            new_books = models.Book.get_by_author(author, only_new=True)
            self.assertGreater(len(books), len(new_books))

        core.delete_author(urls[0][0])
        author = models.Author.get_by_url(urls[0][0])
        self.assertIsNone(author)

        self.assertRaises(
            urllib.request.URLError, core.create_author,
            "http://http://samlib.ru/p/pupkin_wasja_ibragimowich")
Пример #2
0
    def test_author(self):
        urls = (
            ("http://samlib.ru/p/pupkin_wasja_ibragimowich/indexdate.shtml", "Ясинский Анджей"),
            ("http://samlib.ru/e/elxterrus_i/", "Эльтеррус Иар"),
            ("http://samlib.ru/x/xgulliver/", "Gulliver"),
            ("http://samlib.ru/m/muhin_d_w/", "Zang"),
            ("http://zhurnal.lib.ru/z/zajcew_aleskandr/", "Зайцев Алескандр"),
        )
        for url, name in urls:
            author = core.create_author(url=url)
            self.assertEqual(author.name, name)

            books = models.Book.get_by_author(author, only_new=True)
            self.assertGreater(len(books), 0)

            core.book_read(books[0])
            new_books = models.Book.get_by_author(author, only_new=True)
            self.assertGreater(len(books), len(new_books))

        core.delete_author(urls[0][0])
        author = models.Author.get_by_url(urls[0][0])
        self.assertIsNone(author)

        self.assertRaises(
            urllib.request.URLError, core.create_author, "http://http://samlib.ru/p/pupkin_wasja_ibragimowich"
        )
Пример #3
0
            core.create_author("http://samlib.ru/p/pupkin_wasja_ibragimowich/"
                               "indexdate.shtml")
        if args.import_xml:
            core.import_from_xml(args.import_xml)

        if args.url_fix:
            #core.authors_urls_to_samlib()
            core.authors_urls_to_zhurnal_lib()
        if args.check:
            is_console = True
            for author in core.check_all_authors():
                pass

        for url in args.remove_authors:
            is_console = True
            core.delete_author(url)

        for url in args.add_authors:
            is_console = True
            core.create_author(url)

        for url in args.exclude_books:
            is_console = True
            core.exclude_book(url)

        if args.show:
            is_console = True
            only_authors = args.show == 'authors'
            only_new = args.show in ['new','updates']
            mark_as_read = args.show in ['all', 'new']
            descriptions = args.verbose
Пример #4
0
        if init:
            core.create_author("http://samlib.ru/p/pupkin_wasja_ibragimowich/"
                               "indexdate.shtml")
        if args.import_xml:
            core.import_from_xml(args.import_xml)

        if args.url_fix:
            core.authors_urls_to_samlib()
        if args.check:
            is_console = True
            for author in core.check_all_authors():
                pass

        for url in args.remove_authors:
            is_console = True
            core.delete_author(url)

        for url in args.add_authors:
            is_console = True
            core.create_author(url)

        for url in args.exclude_books:
            is_console = True
            core.exclude_book(url)

        if args.show:
            is_console = True
            only_authors = args.show == 'authors'
            only_new = args.show == 'new'
            for author in sorted(models.Author.get(),
                key=lambda author: author.name