Skip to content

Commit

Permalink
generate_epub removal from all crawlers!
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdanbobrowski committed Sep 5, 2024
1 parent 22a4710 commit 52b591c
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 62 deletions.
11 changes: 0 additions & 11 deletions blog2epub/blog2epub_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import time
from datetime import datetime
from itertools import cycle
from pathlib import Path
from threading import Thread
from typing import List
from urllib import parse
Expand Down Expand Up @@ -56,16 +55,6 @@

now = datetime.now()
date_time = now.strftime("%Y-%m-%d[%H.%M.%S]")
logging_filename = os.path.join(
str(Path.home()), ".blog2epub", f"blog2epub_{date_time}.log"
)

logging.basicConfig(
filename=logging_filename,
encoding="utf-8",
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s",
)


class UrlTextInput(MDTextField):
Expand Down
2 changes: 1 addition & 1 deletion blog2epub/common/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(
self._set_locale()
self.chapters: List[Chapter] = []
self.table_of_contents: List[EpubHtml] = []
self.file_name_prefix: str = book_data.file_name_prefix
self.file_name_prefix: Optional[str] = book_data.file_name_prefix
self.file_name: str = self._get_new_file_name()
self.destination_folder = destination_folder

Expand Down
3 changes: 1 addition & 2 deletions blog2epub/common/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from pathlib import Path
from typing import Optional

import yaml
Expand All @@ -8,7 +7,7 @@


class Blog2EpubSettings:
def __init__(self, path: Optional[str]):
def __init__(self, path: str):
self.path = path
self._prepare_path()
self.settings_file = os.path.join(self.path, "blog2epub.yml")
Expand Down
12 changes: 1 addition & 11 deletions blog2epub/crawlers/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
from abc import ABC, abstractmethod
from datetime import datetime
from pathlib import Path
from typing import List, Optional, Dict
import re

Expand All @@ -14,7 +13,7 @@
from blog2epub.common.book import Book
from blog2epub.common.interfaces import EmptyInterface
from blog2epub.common.language_tools import translate_month
from blog2epub.models.book import ArticleModel, DirModel
from blog2epub.models.book import DirModel
from blog2epub.models.configuration import ConfigurationModel
from blog2epub.common.crawler import (
prepare_file_name,
Expand Down Expand Up @@ -80,15 +79,6 @@ def __init__(
def crawl(self):
pass

@abstractmethod
def generate_ebook(
self,
articles: List[ArticleModel],
destination_folder: str = ".",
file_name: Optional[str] = None,
): # TODO: this should be removed I guess crawler's job is just to prepare data
pass


class Article:
"""
Expand Down
30 changes: 2 additions & 28 deletions blog2epub/crawlers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from pydantic import HttpUrl

from blog2epub.crawlers.abstract import AbstractCrawler
from blog2epub.common.book import Book
from blog2epub.models.book import BookModel, DirModel, ArticleModel, ImageModel
from blog2epub.models.configuration import ConfigurationModel


class DefaultCrawler(AbstractCrawler):
Expand Down Expand Up @@ -198,7 +196,8 @@ def _articles_loop(self, content):
):
art.process()
self.images = self.images + art.images
self.interface.print(str(len(self.articles) + 1) + ". " + art.title)
art_no = str(len(self.articles) + 1)
self.interface.print(f"{art_no}. {art.title}")
if self.start:
self.end = art.date
else:
Expand Down Expand Up @@ -240,28 +239,3 @@ def crawl(self):
self._check_limit()
self.active = False
self.subtitle = self._get_subtitle()

def generate_ebook(
self,
articles: List[ArticleModel],
destination_folder: str = ".",
file_name: Optional[str] = None,
):
if articles:
self.book = Book(
book_data=self,
configuration=ConfigurationModel(
language=self.language or "en",
),
interface=self.interface,
destination_folder=destination_folder,
)
self.book.save(
articles=articles,
destination_folder=destination_folder,
file_name=file_name,
)
return True
else:
self.interface.print("No articles found.")
return False
3 changes: 0 additions & 3 deletions blog2epub/crawlers/nrdblog_cmosnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ class NrdblogCmosEuCrawler(AbstractCrawler):

def crawl(self):
pass

def generate_ebook(self, **kwargs):
pass
3 changes: 0 additions & 3 deletions blog2epub/crawlers/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ def _get_sitemap_xml(self):

def crawl(self):
pass

def generate_ebook(self, **kwargs):
pass
3 changes: 0 additions & 3 deletions blog2epub/crawlers/zeissikonveb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ class ZeissIkonVEBCrawler(AbstractCrawler):

def crawl(self):
pass

def generate_ebook(self, **kwargs):
pass

0 comments on commit 52b591c

Please sign in to comment.