Skip to content

Commit 977e8c2

Browse files
committed
flake8 79 line length & changed String to Text in database & using pathlib for file paths & removed Legacy catalogs & removed unused code
1 parent d8110a0 commit 977e8c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+935
-418
lines changed

.flake8

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[flake8]
22
inline-quotes=double
33
import-order-style=google
4-
max-line-length = 120
4+
max-line-length = 79
55
extend-ignore = R503,R502,F401,N802
66
exclude =
77
.git,

main.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ def load_translator(self):
3535
self.translator.load(get_locale(QLocale().language()))
3636
self.installTranslator(self.translator)
3737

38-
def get_accent_color(self):
39-
return self.palette().color(QPalette.ColorRole.Highlight)
40-
4138
def update_style(self):
4239
setTheme(Theme.DARK if darkdetect.isDark() else Theme.LIGHT)
4340

@@ -73,12 +70,18 @@ def check_for_updates(self):
7370
return version
7471

7572
def show_update_info(self, result):
76-
info_bar_title = translate("Message", "Check for updates.")
73+
info_bar_title = translate(
74+
"Message",
75+
"Check for updates.",
76+
)
7777
info_bar_duration = 3500
7878
if result is None:
7979
InfoBar.error(
8080
title=info_bar_title,
81-
content=translate("Message", "Error checking for updates."),
81+
content=translate(
82+
"Message",
83+
"Error checking for updates.",
84+
),
8285
duration=info_bar_duration,
8386
parent=self,
8487
)
@@ -98,8 +101,7 @@ def show_update_info(self, result):
98101
@staticmethod
99102
def theme_listener():
100103
theme = darkdetect.theme()
101-
accent_color = app.get_accent_color()
102-
while darkdetect.theme() == theme and accent_color == app.get_accent_color():
104+
while darkdetect.theme() == theme:
103105
time.sleep(1)
104106

105107
def update_style(self):
@@ -118,15 +120,21 @@ def closeEvent(self, event):
118120
logging.basicConfig(
119121
level=logging.WARNING, filename="latest.log", filemode="w",
120122
)
123+
121124
QApplication.setHighDpiScaleFactorRoundingPolicy(
122125
Qt.HighDpiScaleFactorRoundingPolicy.RoundPreferFloor,
123126
)
124127
QApplication.setStyle("Fusion")
125128
QThreadPool.globalInstance().setMaxThreadCount(32)
126129
app = App(sys.argv)
127-
Path(f"{platformdirs.user_data_dir()}/{APP_NAME}").mkdir(parents=True, exist_ok=True)
130+
131+
Path(
132+
platformdirs.user_data_path() / APP_NAME,
133+
).mkdir(parents=True, exist_ok=True)
134+
128135
httpd = HTTPServer(("localhost", 8000), KodikHTTPRequestHandler)
129136
PyThread(target=httpd.serve_forever, daemon=True).start()
137+
130138
window = MainWindow()
131139
window.show()
132140
sys.exit(app.exec())

nlightreader/consts/enums.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import logging
22
from enum import Enum, unique
33

4-
LIB_LISTS = ("planned", "completed", "reading", "re-reading", "on hold", "dropped")
4+
LIB_LISTS = (
5+
"planned",
6+
"completed",
7+
"reading",
8+
"re-reading",
9+
"on hold",
10+
"dropped",
11+
)
512

613

714
class Nl:
@@ -29,7 +36,13 @@ def from_str(cls, string: str):
2936
return cls.undefined
3037

3138
def to_str(self) -> str:
32-
names = ["Undefined", "English", "Russian", "Ukrainian", "Japanese"]
39+
names = [
40+
"Undefined",
41+
"English",
42+
"Russian",
43+
"Ukrainian",
44+
"Japanese",
45+
]
3346
return names[self.value]
3447

3548
@unique

nlightreader/consts/paths/paths.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
from nlightreader.consts.app import APP_NAME
44

5-
TOKEN_PATH = f"{platformdirs.user_data_dir()}/{APP_NAME}/tokens"
5+
TOKEN_PATH = platformdirs.user_data_path() / APP_NAME / "tokens"

nlightreader/consts/urls.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
URL_MANGA_DEX = "https://mangadex.org"
99
URL_MANGA_DEX_API = "https://api.mangadex.org"
10-
URL_MANGA_DEX_TOKEN = "https://auth.mangadex.org/realms/mangadex/protocol/openid-connect/token"
10+
URL_MANGA_DEX_TOKEN = (
11+
"https://auth.mangadex.org/"
12+
"realms/mangadex/protocol/openid-connect/token"
13+
)
1114

1215
URL_RULATE = "https://tl.rulate.ru"
1316
URL_EROLATE = "https://erolate.com"
@@ -35,7 +38,8 @@
3538

3639
DEFAULT_HEADERS = {
3740
"User-Agent":
38-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0",
41+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0)"
42+
"Gecko/20100101 Firefox/99.0",
3943
}
4044
DESU_HEADERS = {"User-Agent": "Nlight"}
4145
SHIKIMORI_HEADERS = {"User-Agent": "Nlight"}

nlightreader/contexts/HistoryNote.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def __init__(self):
1717

1818
def set_mode(self, mode: int):
1919
"""
20-
Sets the mode of this object and adds the appropriate actions based on the mode.
20+
Sets the mode of this object and
21+
adds the appropriate actions based on the mode.
2122
2223
Args:
2324
mode (int): The mode to set. Valid values are 0, 1.

nlightreader/contexts/LibraryManga.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def __init__(self):
2929

3030
def set_mode(self, mode: int):
3131
"""
32-
Sets the mode of this object and adds the appropriate actions based on the mode.
32+
Sets the mode of this object and
33+
adds the appropriate actions based on the mode.
3334
3435
Args:
3536
mode: The mode to set. Valid values are 0, 1, 2.

nlightreader/contexts/ReadMark.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def __init__(self):
2121

2222
def set_mode(self, mode: int):
2323
"""
24-
Sets the mode of this object and adds the appropriate actions based on the mode.
24+
Sets the mode of this object and
25+
adds the appropriate actions based on the mode.
2526
2627
Args:
2728
mode (int): The mode to set. Valid values are 0, 1, 2.

nlightreader/dialogs/Auth.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def __init__(self, catalog, parent):
4040
self.getCodeButton.clicked.connect(self.__open_login_page)
4141

4242
self.tokenLineEdit = LineEdit(self)
43-
self.tokenLineEdit.setPlaceholderText(translate("Dialog", "Authorization code"))
43+
self.tokenLineEdit.setPlaceholderText(
44+
translate("Dialog", "Authorization code"),
45+
)
4446
self.tokenLineEdit.setClearButtonEnabled(True)
4547
self.tokenLineEdit.textChanged.connect(self.verify_user_data)
4648

@@ -63,12 +65,16 @@ class UserDataAuthMessageBox(AbstractAuthDialog):
6365
def __init__(self, catalog, parent):
6466
super().__init__(catalog, parent)
6567
self.loginLineEdit = LineEdit(self)
66-
self.loginLineEdit.setPlaceholderText(translate("Dialog", "Login"))
68+
self.loginLineEdit.setPlaceholderText(
69+
translate("Dialog", "Login"),
70+
)
6771
self.loginLineEdit.setClearButtonEnabled(True)
6872
self.loginLineEdit.textChanged.connect(self.verify_user_data)
6973

7074
self.passwordLineEdit = PasswordLineEdit(self)
71-
self.passwordLineEdit.setPlaceholderText(translate("Dialog", "Password"))
75+
self.passwordLineEdit.setPlaceholderText(
76+
translate("Dialog", "Password"),
77+
)
7278
self.passwordLineEdit.setClearButtonEnabled(True)
7379
self.passwordLineEdit.textChanged.connect(self.verify_user_data)
7480

@@ -77,7 +83,11 @@ def __init__(self, catalog, parent):
7783

7884
def verify_user_data(self):
7985
self.yesButton.setEnabled(
80-
bool(self.loginLineEdit.text()) and bool(self.passwordLineEdit.text()),
86+
bool(
87+
self.loginLineEdit.text(),
88+
) and bool(
89+
self.passwordLineEdit.text(),
90+
),
8191
)
8292

8393
def get_user_data(self):

nlightreader/dialogs/Genres.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ def __init__(self, parent=None):
1919
@Slot()
2020
def accept_genres(self):
2121
self.selected_genres = [
22-
self.genres_items.get(i) for i in self.genres_items if i.isChecked()
22+
self.genres_items.get(i)
23+
for i in self.genres_items
24+
if i.isChecked()
2325
]
2426
self.accept()
2527

nlightreader/items/BaseItem.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33

44
class BaseItem:
5-
def __init__(self, content_id: str, catalog_id: int, name: str, russian: str):
5+
def __init__(
6+
self,
7+
content_id: str,
8+
catalog_id: int,
9+
name: str,
10+
russian: str,
11+
):
612
self.__id = f"|{catalog_id}|_|{content_id}|"
713
self.__content_id = content_id
814
self.__catalog_id = catalog_id

nlightreader/items/manga_items.py

+32-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import re
23

34
from PySide6.QtCore import QLocale
@@ -55,12 +56,23 @@ def descriptions_to_str(self) -> str:
5556
desc_str = ""
5657
for key in self._description:
5758
if self._description.get(key):
58-
desc_str += f"<lang={key.name}>{self._description.get(key)}<end>"
59+
desc_str += (
60+
f"<lang={key.name}>"
61+
f"{self._description.get(key)}"
62+
f"<end>"
63+
)
5964
return desc_str
6065

6166
def set_description_from_str(self, desc: str):
62-
for lang, text in re.findall(r"<lang=(\w+)>(.+?)<end>", desc, re.DOTALL):
63-
self.add_description(Nl.Language.from_str(lang), text)
67+
for lang, text in re.findall(
68+
r"<lang=(\w+)>(.+?)<end>",
69+
desc,
70+
re.DOTALL,
71+
):
72+
self.add_description(
73+
Nl.Language.from_str(lang),
74+
text,
75+
)
6476

6577
def to_dict(self) -> dict:
6678
return {
@@ -81,8 +93,14 @@ def to_dict(self) -> dict:
8193

8294
class Chapter:
8395
def __init__(
84-
self, content_id: str, catalog_id: int, vol: str, ch: str, title: str,
85-
language: Nl.Language = Nl.Language.undefined):
96+
self,
97+
content_id: str,
98+
catalog_id: int,
99+
vol: str,
100+
ch: str,
101+
title: str,
102+
language: Nl.Language = Nl.Language.undefined,
103+
):
86104
self.id = f"|{catalog_id}|_|{content_id}|"
87105
self.content_id = content_id
88106
self.catalog_id = catalog_id
@@ -128,7 +146,15 @@ def get_empty_instance():
128146

129147

130148
class Character(BaseItem):
131-
def __init__(self, content_id: str, catalog_id: int, name, russian, description, role):
149+
def __init__(
150+
self,
151+
content_id: str,
152+
catalog_id: int,
153+
name,
154+
russian,
155+
description,
156+
role,
157+
):
132158
super().__init__(content_id, catalog_id, name, russian)
133159
self.description = description
134160
self.role = role

nlightreader/parsers/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
LibBase,
1414
)
1515
from .hentai_manga import NHentai, AllHentai
16-
from .manga import Desu, MangaDex, MangaDexLib, Remanga, SlashLib, MangaLib
16+
from .manga import Desu, MangaDex, MangaDexLib, Remanga, SlashLib
1717
from .ranobe import Rulate, Erolate, Ranobehub

nlightreader/parsers/combined/lib/lib_anilib.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class LibAnilib(LibBase, AbstractAnimeCatalog):
1111
CATALOG_NAME = "AniLib"
12-
CATALOG_ID = 15
12+
CATALOG_ID = 14
1313

1414
def __init__(self):
1515
super().__init__()
@@ -26,7 +26,12 @@ def get_chapters(self, manga: Manga) -> list[Chapter]:
2626
if episodes_response:
2727
for i in episodes_response["data"]:
2828
episode = Chapter(
29-
i["id"], self.CATALOG_ID, "", "", f"Episode {i['number']}", Nl.Language.ru,
29+
i["id"],
30+
self.CATALOG_ID,
31+
"",
32+
"",
33+
f"Episode {i['number']}",
34+
Nl.Language.ru,
3035
)
3136
episodes.append(episode)
3237
episodes.reverse()

0 commit comments

Comments
 (0)