Пример #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
    if args.zen:
        import this
        exit()

    settings.DB = args.db
    settings.USE_PROXY = args.use_proxy or args.proxy is not None
    if settings.USE_PROXY and args.proxy:
        settings.PROXY = args.proxy

    is_console = False
    try:
        init = not os.path.exists(settings.DB)
        models.init_connection(init=init)
        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()
            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)
Пример #4
0
    if args.zen:
        import this
        exit()

    settings.DB = args.db
    settings.USE_PROXY = args.use_proxy or args.proxy is not None
    if settings.USE_PROXY and args.proxy:
        settings.PROXY = args.proxy

    is_console = False
    try:
        init = not os.path.exists(settings.DB)
        models.init_connection(init=init)
        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:
Пример #5
0
 def add_author(self, event=None):
     if core.create_author(self.url.get()):
         authors = models.Author.get()
         self.authors_updated(authors)
Пример #6
0
 def add_author(self, event=None):
     if core.create_author(self.url.get()):
         authors = models.Author.get()
         self.authors_updated(authors)