Skip to content

Commit 497f7ad

Browse files
Isort, reformat and refactor
1 parent 9671ce0 commit 497f7ad

File tree

5 files changed

+10
-38
lines changed

5 files changed

+10
-38
lines changed

blog2epub/Blog2EpubCli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import sys
22
from urllib import parse
33

4-
from blog2epub.Blog2Epub import Blog2Epub, BadUrlException, NotEnoughCommandsException
4+
from blog2epub.Blog2Epub import (BadUrlException, Blog2Epub,
5+
NotEnoughCommandsException)
56
from blog2epub.crawlers.Crawler import EmptyInterface
67

78

blog2epub/Blog2EpubKivy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from kivy.uix.popup import Popup
2727
from kivy.uix.textinput import TextInput
2828

29-
from blog2epub.Blog2Epub import Blog2Epub, BadUrlException
29+
from blog2epub.Blog2Epub import BadUrlException, Blog2Epub
3030
from blog2epub.Common import asset_path
3131
from blog2epub.crawlers.Crawler import EmptyInterface
3232

@@ -193,7 +193,6 @@ def save_settings(self):
193193

194194
def about_popup(self, instance):
195195
about_content = BoxLayout(orientation="vertical")
196-
self.interface.print(asset_path("blog2epub.png"))
197196
about_content.add_widget(
198197
Image(
199198
source=asset_path("blog2epub.png"),

blog2epub/Common.py

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,10 @@
1-
import logging
21
import os
3-
import platform
42
import sys
5-
from pathlib import Path
63

74

85
def asset_path(filename: str) -> str:
9-
# TODO: this needs refactor
10-
result = None
11-
if platform.system() == "Windows":
12-
try:
13-
base_path = sys._MEIPASS
14-
except AttributeError:
15-
base_path = os.path.abspath("./assets/")
16-
result = os.path.join(base_path, filename)
17-
elif platform.system() == "Darwin":
18-
in_osx_app = os.path.join(
19-
os.path.dirname(sys.executable).replace(
20-
"/Contents/MacOS", "/Contents/Resources"
21-
),
22-
filename,
23-
)
24-
in_sources = os.path.join(
25-
Path(__file__).parent.resolve(), "..", "assets", filename
26-
)
27-
if os.path.isfile(in_osx_app):
28-
result = in_osx_app
29-
if os.path.isfile(in_sources):
30-
result = in_sources
31-
else:
32-
in_sources = os.path.join(
33-
Path(__file__).parent.resolve(), "..", "assets", filename
34-
)
35-
if os.path.isfile(in_sources):
36-
result = in_sources
37-
logging.info(f"Loading asset: {result}")
38-
return result
6+
try:
7+
base_path = sys._MEIPASS
8+
except AttributeError:
9+
base_path = os.path.abspath("./assets/")
10+
return os.path.join(base_path, filename)

blog2epub/crawlers/Crawler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
import atoma
1717
import dateutil.parser
1818
import requests
19-
from PIL import Image
2019
from lxml.ElementInclude import etree
2120
from lxml.html.soupparser import fromstring
21+
from PIL import Image
2222

2323
import blog2epub
2424
from blog2epub.Book import Book

blog2epub/crawlers/CrawlerWordpress.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from lxml.ElementInclude import etree
99
from lxml.html.soupparser import fromstring
1010

11-
from blog2epub.crawlers.Crawler import Crawler, Article
11+
from blog2epub.crawlers.Crawler import Article, Crawler
1212

1313

1414
class CrawlerWordpress(Crawler):

0 commit comments

Comments
 (0)