Skip to content

Commit

Permalink
🎨 chore(format): fix __init__ import unused
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinNitroG committed Apr 3, 2024
1 parent e2d4a5b commit 254e7d0
Show file tree
Hide file tree
Showing 23 changed files with 76 additions and 83 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ insert_final_newline = true
trim_trailing_whitespace = true

[*.py]
indent_size = 4
end_of_line = crlf
tab_width = 4

[*.{js,ts,tsx,json,yml,yaml,toml}]
[*.{js,ts,tsx,json,yml,yaml,toml,md}]
indent_size = 2
tab_width = 2

Expand Down
16 changes: 7 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ci:
autoupdate_schedule: weekly
autofix_commit_msg: "🐛 fix: pre-commit auto fix"
autofix_prs: true
autoupdate_commit_msg: "🔧 chore: pre-commit auto update"
autoupdate_commit_msg: "🔧 chore (deps): pre-commit auto update dependencies"

exclude: ^(src/utils/update.py)

Expand Down Expand Up @@ -60,19 +60,17 @@ repos:
hooks:
- id: yesqa

# - repo: https://github.com/psf/black
# rev: 24.2.0
# hooks:
# - id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
# Run the linter.
# - id: ruff
# Run the formatter.
- id: ruff
- id: ruff-format

# - repo: https://github.com/PyCQA/isort
# rev: "5.13.2"
# hooks:
# - id: isort

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
Expand Down
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Python CLI tool download sách từ <strong>VNULIB</strong>
<img src="https://img.shields.io/badge/-selenium-%43B02A?style=for-the-badge&logo=selenium&logoColor=white" alt="Selenium">
<img src="https://img.shields.io/badge/pre--commit-FAB040.svg?style=for-the-badge&logo=precommit&logoColor=white" alt="Pre-commit">
<img src="https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white" alt="GitHub Actions">
<img src="https://img.shields.io/badge/Visual%20Studio%20Code-0078d7.svg?style=for-the-badge&logo=visual-studio-code&logoColor=white" alt="Visual Studio Code">
<br>
<br>
<a href="../../../releases/latest"><img alt="Release" src="https://img.shields.io/github/v/release/KevinNitroG/VNULIB-Downloader?sort=date&display_name=tag&style=for-the-badge&color=eed49f"></a>
Expand Down Expand Up @@ -254,13 +253,14 @@ python main.py
## 👨‍💻 DEVELOP / CONTRIBUTE

- Python:
- [`ruff`](https://docs.astral.sh/ruff/formatter/) - Ruff Formatter
- [`ruff`](https://docs.astral.sh/ruff/formatter/) - Ruff Formatter & Linter
- [`isort`](https://pycqa.github.io/isort/) - Isort formatter
- [`black`](https://github.com/psf/black) - Black Formatter _(alternatives)_
- Docstring: Google format
- [Ex 1](https://github.com/NilsJPWerner/autoDocstring/blob/master/docs/google.md#google-docstring-format)
- [Ex 2](https://gist.github.com/Raxy45/98de280aec506e7168cbb5955242ec3f/#file-google_docstrings)
- Package manager: Pip - Need specific version
- Linter: [Pylance](vscode:extension/ms-python.vscode-pylance) / Pylint
- Linter: [Pylance](vscode:extension/ms-python.vscode-pylance) / Pylint / Pyright
- [Prettier](https://prettier.io/)

---
Expand Down
25 changes: 5 additions & 20 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,14 @@

from __future__ import annotations


from pprint import pformat
from logging import Logger, getLogger
from multiprocessing import freeze_support
from logging import getLogger, Logger
from pprint import pformat

from urllib3 import disable_warnings as urllib3_disable_warnings
from urllib3.exceptions import InsecureRequestWarning
from src import (
ToolLogger,
Action,
Browser,
Config,
CreatePDF,
CleanIMG,
DownloadIMG,
LinkParse,
Login,
PrintIntro,
UserOptions,
delete_old_meipass,
create_directory,
pause,
print_title,
)

from src import Action, Browser, CleanIMG, Config, CreatePDF, DownloadIMG, LinkParse, Login, PrintIntro, ToolLogger, UserOptions, create_directory, delete_old_meipass, pause, print_title
from src.constants import DOWNLOAD_DIR


Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@ extend-exclude = ["src/utils/update.py"]
[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
select = ["I"]

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]
21 changes: 4 additions & 17 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,7 @@
from __future__ import annotations

from .bot import Action, Browser, Login
from .modules import (
Config,
CreatePDF,
CleanIMG,
DownloadIMG,
LinkParse,
PrintIntro,
UserOptions,
setup_argparse,
)
from .utils import (
ToolLogger,
create_directory,
pause,
print_title,
delete_old_meipass,
)
from .modules import CleanIMG, Config, CreatePDF, DownloadIMG, LinkParse, PrintIntro, UserOptions, setup_argparse
from .utils import ToolLogger, create_directory, delete_old_meipass, pause, print_title

__all__: list[str] = ["Action", "Browser", "Login", "CleanIMG", "Config", "CreatePDF", "DownloadIMG", "LinkParse", "PrintIntro", "UserOptions", "setup_argparse", "ToolLogger", "create_directory", "delete_old_meipass", "pause", "print_title"]
2 changes: 2 additions & 0 deletions src/bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
from .action import Action
from .browser import Browser
from .login import Login

__all__: list[str] = ["Action", "Browser", "Login"]
7 changes: 4 additions & 3 deletions src/bot/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

from __future__ import annotations

from urllib.parse import parse_qs, urlparse
from logging import getLogger
from urllib.parse import parse_qs, urlparse

from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from .utils import wait_element_visible

from ..modules import Link, LinkFile
from ..utils import datetime_name, slugify

from .utils import wait_element_visible

logger = getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion src/bot/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from __future__ import annotations

from logging import getLogger

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.webdriver import WebDriver
from webdriver_manager.chrome import ChromeDriverManager
from src.constants import BROWSER_ARGUMENTS

from src.constants import BROWSER_ARGUMENTS

logger = getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions src/bot/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from __future__ import annotations

from logging import getLogger

from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from .utils import wait_element_clickable
from ..constants import LOGIN_URL

from ..constants import LOGIN_URL
from .utils import wait_element_clickable

logger = getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Constant variables throughout the program."""

from __future__ import annotations
import sys

import sys

if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
BUNDLE_DIR: str = f"{sys._MEIPASS}/" # type: ignore # skipcq: PYL-W0212 # pylint: disable=protected-access # nopep8
Expand Down
6 changes: 4 additions & 2 deletions src/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from __future__ import annotations

from .argpase import setup_argparse
from .clean_img import CleanIMG
from .config import Config
from .create_pdf import CreatePDF
from .clean_img import CleanIMG
from .download_img import DownloadIMG
from .link_parse import LinkParse
from .print_intro import PrintIntro
from .user_options import UserOptions, Link, LinkFile
from .user_options import Link, LinkFile, UserOptions

__all__ = ["setup_argparse", "CleanIMG", "Config", "CreatePDF", "DownloadIMG", "LinkParse", "PrintIntro", "Link", "LinkFile", "UserOptions"]
2 changes: 1 addition & 1 deletion src/modules/clean_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import os
from logging import getLogger
from .link_parse import Link

from .link_parse import Link

logger = getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions src/modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from __future__ import annotations

from logging import getLogger
from os import path
from shutil import copyfile
from logging import getLogger
from ..constants import CONFIG_FILE, CONFIG_SAMPLE_FILE

from ..constants import CONFIG_FILE, CONFIG_SAMPLE_FILE

logger = getLogger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions src/modules/create_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
from __future__ import annotations

import os
from multiprocessing import Queue, Process
from logging import Logger
from multiprocessing import Process, Queue

import img2pdf
from .link_parse import Link

from ..utils import get_subprocess_logger, logger_listener
from .link_parse import Link


class CreatePDF:
Expand Down
11 changes: 6 additions & 5 deletions src/modules/download_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import threading
from concurrent.futures import ThreadPoolExecutor
from itertools import count
from typing import override, Callable
from logging import getLogger
from typing import Callable, override

import requests
from requests.sessions import Session
from requests import Response
from alive_progress import alive_bar
from .link_parse import Link, LinkFile
from requests import Response
from requests.sessions import Session

from ..constants import ERROR_PAGE_IMAGE_PATH
from ..utils import create_directory

from .link_parse import Link, LinkFile

logger = getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions src/modules/link_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from __future__ import annotations

from logging import getLogger
from re import compile as re_compile
from re import search as re_search
from time import sleep
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
from logging import getLogger
from .user_options import Link, LinkFile
from ..utils.utils import datetime_name

from ..utils.utils import datetime_name
from .user_options import Link, LinkFile

logger = getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions src/modules/print_intro.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from print_color import print as printColor

from src.constants import AUTHORS, BANNER, VERSION
from src.utils.prints import TERMINAL_SIZE_COLUMNS

Expand Down
5 changes: 3 additions & 2 deletions src/modules/user_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

from argparse import Namespace
from dataclasses import dataclass
from pprint import pformat
from logging import getLogger
from pprint import pformat

from yaml import safe_load

from ..constants import CONFIG_FILE, USER_INPUT_NO, USER_INPUT_YES
from .argpase import setup_argparse


logger = getLogger(__name__)


Expand Down
6 changes: 4 additions & 2 deletions src/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from .logger import ToolLogger, logger_listener, get_subprocess_logger
from .logger import ToolLogger, get_subprocess_logger, logger_listener
from .prints import print_title
from .utils import pause, create_directory, datetime_name, slugify, delete_old_meipass
from .utils import create_directory, datetime_name, delete_old_meipass, pause, slugify

__all__: list[str] = ["ToolLogger", "get_subprocess_logger", "logger_listener", "print_title", "create_directory", "datetime_name", "delete_old_meipass", "pause", "slugify"]
7 changes: 5 additions & 2 deletions src/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

from __future__ import annotations

from logging import Logger, getLogger, DEBUG, WARNING
from logging import DEBUG, WARNING, Logger, getLogger
from logging.config import dictConfig
from logging.handlers import QueueHandler
from multiprocessing import Queue
from os import makedirs, path, environ as os_environ
from os import environ as os_environ
from os import makedirs, path

from yaml import safe_load

from src.constants import LOGGING_CONFIG_FILE_PATH, LOGGING_PATH


Expand Down
1 change: 1 addition & 0 deletions src/utils/prints.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from os import get_terminal_size

from print_color.print_color import print as print_color


Expand Down
8 changes: 4 additions & 4 deletions src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import re
import sys
import unicodedata
from glob import glob
from datetime import datetime
from time import time
from glob import glob
from logging import getLogger
from os import makedirs, path
from shutil import rmtree
from logging import getLogger
from ..constants import USER_INPUT_YES
from time import time

from ..constants import USER_INPUT_YES

logger = getLogger(__name__)

Expand Down

0 comments on commit 254e7d0

Please sign in to comment.