Skip to content

Commit

Permalink
🎨 Run Pre-commit all files
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinNitroG committed Feb 25, 2024
1 parent d629362 commit cd30973
Show file tree
Hide file tree
Showing 38 changed files with 535 additions and 384 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bugReport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ body:
- type: markdown
attributes:
value: |
Vui lòng giữ emoji "🐛" ở tiêu đề
Vui lòng giữ emoji "🐛" ở tiêu đề
- type: textarea
id: bug-description
attributes:
Expand Down Expand Up @@ -45,4 +45,4 @@ body:
label: 📝 Ghi chú
description: Bạn có ghi chú gì thêm không?
validations:
required: false
required: false
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Facebook
url: https://www.facebook.com/KevinNitro
about: Facebook của tui nè 🤞
- name: Telegram
url: https://t.me/KevinNitro
about: Telegram thầm kín to nhỏ 🤐
- name: Facebook
url: https://www.facebook.com/KevinNitro
about: Facebook của tui nè 🤞
- name: Telegram
url: https://t.me/KevinNitro
about: Telegram thầm kín to nhỏ 🤐
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/featureRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ body:
label: 📝 Ghi chú
placeholder: Bạn có ghi chú gì thêm không?
validations:
required: false
required: false
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ body:
- type: markdown
attributes:
value: |
Vui lòng giữ emoji "❓" ở tiêu đề
Vui lòng giữ emoji "❓" ở tiêu đề
- type: textarea
id: question-description
attributes:
Expand All @@ -19,4 +19,4 @@ body:
label: 📝 Ghi chú
placeholder: Bạn có ghi chú gì thêm không?
validations:
required: false
required: false
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/updateRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ body:
- Co
- Cothedeonaoduoc
validations:
required: true
required: true
2 changes: 1 addition & 1 deletion .github/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ newIssueWelcomeComment: >
Tạo Issue lần đầu hẻ? Okok chắc là sẽ không fix đâu 😳
newPRWelcomeComment: >
Tạo PR lần đầu hả? Có chắc là nó chạy không? 🥴
Tạo PR lần đầu hả? Có chắc là nó chạy không? 🥴
27 changes: 13 additions & 14 deletions .github/label-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ heated:
# Lock the thread
lock: true
# Set a lock reason
lock-reason: 'too heated'
lock-reason: "too heated"
# Additionally, add a label to pull requests
prs:
label: 'pr: on hold'
label: "pr: on hold"

# The `heated` label is removed from issues, pull requests or discussions
-heated:
Expand All @@ -34,40 +34,39 @@ feature:
# Close the issue
close: true
# Set a close reason
close-reason: 'not planned'
close-reason: "not planned"

# The `qa: needed` label is added to pull requests
'qa: needed':
"qa: needed":
prs:
# Add labels
label:
- 'qa: l10n'
- 'pr: on hold'

- "qa: l10n"
- "pr: on hold"

# The `qa: needed` label is removed from pull requests
'-qa: needed':
"-qa: needed":
prs:
# Add label
label: 'qa: verified'
label: "qa: verified"
# Remove labels
unlabel:
- 'qa: l10n'
- 'pr: on hold'
- "qa: l10n"
- "pr: on hold"

# The `solved` label is added to discussions
solved:
discussions:
# Close the discussion
close: true
# Set a close reason
close-reason: 'resolved'
close-reason: "resolved"
# Lock the discussion
lock: true

# The `pizzazz` label is added to issues, pull requests or discussions
pizzazz:
# Post comments
comment:
- '![](https://i.imgur.com/WuduJNk.jpg)'
- '![](https://i.imgur.com/1D8yxOo.gif)'
- "![](https://i.imgur.com/WuduJNk.jpg)"
- "![](https://i.imgur.com/1D8yxOo.gif)"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# THIS PROJECT
**/*test*
**/.?*cache*
**/*log*
VNULIB-Downloader/*
Profiles/
Expand Down
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ repos:
- id: name-tests-test
- id: requirements-txt-fixer
- id: pretty-format-json
args:
- "autofix"

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.5.0
hooks:
- id: setup-cfg-fmt
# - repo: https://github.com/asottile/setup-cfg-fmt
# rev: v2.5.0
# hooks:
# - id: setup-cfg-fmt

- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
Expand All @@ -51,7 +49,6 @@ repos:
rev: 24.2.0
hooks:
- id: black
- id: black-jupyter

- repo: https://github.com/pycqa/isort
rev: 5.13.2
Expand All @@ -63,10 +60,10 @@ repos:
hooks:
- id: yesqa

- repo: https://github.com/pylint-dev/pylint
rev: v3.1.0
hooks:
- id: pylint
# - repo: https://github.com/pylint-dev/pylint
# rev: v3.1.0
# hooks:
# - id: pylint

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
Expand Down
2 changes: 1 addition & 1 deletion .whitesource
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"minSeverityLevel": "LOW",
"issueType": "DEPENDENCY"
}
}
}
4 changes: 2 additions & 2 deletions VNULIB-Downloader/config-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PASSWORD:
# LINKS:
# - LINK1
# - LINK2
# or
# or
# LINKS: [LINK1, LINK2]
LINKS:

Expand All @@ -36,4 +36,4 @@ CREATE_PDF:

# Clean downloaded images
# True, true, on / False, false, off
CLEAN_IMG:
CLEAN_IMG:
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ✨ VNULIB DOWNLOADER ✨

<pre align="center">
██╗ ██╗███╗ ██╗██╗ ██╗██╗ ██╗██████╗
██╗ ██╗███╗ ██╗██╗ ██╗██╗ ██╗██████╗
██║ ██║████╗ ██║██║ ██║██║ ██║██╔══██╗
██║ ██║██╔██╗ ██║██║ ██║██║ ██║██████╔╝
╚██╗ ██╔╝██║╚██╗██║██║ ██║██║ ██║██╔══██╗
╚████╔╝ ██║ ╚████║╚██████╔╝███████╗██║██████╔╝
╚═══╝ ╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝╚═════╝
╚═══╝ ╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝╚═════╝

██████╗ ██████╗ ██╗ ██╗███╗ ██╗██╗ ██████╗ █████╗ ██████╗ ███████╗██████╗
██████╗ ██████╗ ██╗ ██╗███╗ ██╗██╗ ██████╗ █████╗ ██████╗ ███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║████╗ ██║██║ ██╔═══██╗██╔══██╗██╔══██╗██╔════╝██╔══██╗
██║ ██║██║ ██║██║ █╗ ██║██╔██╗ ██║██║ ██║ ██║███████║██║ ██║█████╗ ██████╔╝
██║ ██║██║ ██║██║███╗██║██║╚██╗██║██║ ██║ ██║██╔══██║██║ ██║██╔══╝ ██╔══██╗
Expand All @@ -28,7 +28,7 @@ Python CLI tool download sách từ <strong>VNULIB</strong>
<img src="https://wakatime.com/badge/github/KevinNitroG/VNULIB-Downloader.svg?style=for-the-badge" alt="wakatime of KevinNitroG">
<img src="https://hits.sh/github.com/KevinNitroG/VNULIB-Downloader.svg?view=today-total&style=for-the-badge&label=hits" alt="Hit">
<img src="https://img.shields.io/codefactor/grade/github/KevinNitroG/VNULIB-Downloader?style=for-the-badge" alt="CodeFactor Grade">

<img src="https://app.deepsource.com/gh/KevinNitroG/VNULIB-Downloader.svg/?label=active+issues&show_trend=true&token=CudEDrOLrCKS4df1IaYBoP-G" alt="DeepSource active issues">
<img src="https://app.deepsource.com/gh/KevinNitroG/VNULIB-Downloader.svg/?label=resolved+issues&show_trend=true&token=CudEDrOLrCKS4df1IaYBoP-G" alt="DeepSource resolved issues">
<br>
Expand Down
54 changes: 31 additions & 23 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,54 @@
"""VNULIB Downloader"""

from __future__ import annotations

from pprint import pformat
from src import (Browser, Login, Action,
PrintIntro, Config, UserOptions, LinkParse,
DownloadIMG, CreatePDF, DeleteIMG,
print_title, pause, create_directory,
logger)

from src import (Action, Browser, Config, CreatePDF, DeleteIMG, DownloadIMG,
LinkParse, Login, PrintIntro, UserOptions, create_directory,
logger, pause, print_title)
from src.constants import DOWNLOAD_DIR


def main() -> None:
"""Main function to run VNULIB Downloader"""
PrintIntro()

print_title('USER OPTIONS')
print_title("USER OPTIONS")
Config()
user_options = UserOptions()
user_options.setup()

print_title('PARSE LINKS')
print_title("PARSE LINKS")
link_parse = LinkParse(links=user_options.links)
user_options.links = link_parse.parse()
if link_parse.need_to_process:
logger.info('There is / are some link(s) need to be processed')
print_title('PROCESS LINKS')
with Browser(browser=user_options.browser,
headless=user_options.headless,
timeout=user_options.timeout) as driver:
Login(driver=driver,
username=user_options.username,
password=user_options.password).login()
logger.info("There is / are some link(s) need to be processed")
print_title("PROCESS LINKS")
with Browser(
browser=user_options.browser,
headless=user_options.headless,
timeout=user_options.timeout,
) as driver:
Login(
driver=driver,
username=user_options.username,
password=user_options.password,
).login()
user_options.links = LinkParse(links=user_options.links).parse()
user_options.links = Action(driver=driver,
links=user_options.links).action()
logger.debug(msg=f'LINKS OBJECT:\n{pformat(user_options.links)}')
user_options.links = Action(
driver=driver, links=user_options.links
).action()
logger.debug(msg=f"LINKS OBJECT:\n{pformat(user_options.links)}")

create_directory(DOWNLOAD_DIR, force=False)

print_title('DOWNLOAD')
DownloadIMG(links=user_options.links,
download_directory=DOWNLOAD_DIR,
timeout=user_options.timeout).dowload_images()
print_title("DOWNLOAD")
DownloadIMG(
links=user_options.links,
download_directory=DOWNLOAD_DIR,
timeout=user_options.timeout,
).dowload_images()

# if user_options.create_pdf:
# print_title('PDF')
Expand All @@ -51,6 +59,6 @@ def main() -> None:
# DeleteIMG.delete_jpg(DOWNLOAD_DIR, user_options.links)


if __name__ == '__main__':
if __name__ == "__main__":
main()
pause()
4 changes: 1 addition & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
"extends": ["config:recommended"]
}
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
selenium==4.17.2
webdriver-manager==4.0.1
requests==2.31.0
urllib3==2.2.1
argparse==1.4.0
pyyaml==6.0.1
print-color==0.4.6
alive-progress==3.1.5
argparse==1.4.0
img2pdf==0.5.1
pillow==10.2.0
pillow==10.2.0
print-color==0.4.6
pyyaml==6.0.1
requests==2.31.0
selenium==4.17.2
urllib3==2.2.1
webdriver-manager==4.0.1
2 changes: 1 addition & 1 deletion restyled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ restylers:
- "**/*.py"
- "main.py"
- "!autopep8"
- "!pyment"
- "!pyment"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pep8]
ignore = E501, W505
ignore = E501, W505
9 changes: 5 additions & 4 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Contains classes, function, object to be imported in main
"""

from __future__ import annotations

from .bot import Browser, Login, Action
from .modules import PrintIntro, Config, UserOptions, LinkParse, DownloadIMG, CreatePDF, DeleteIMG
from .modules import setup_argparse
from .utils import logger, print_title, pause, create_directory
from .bot import Action, Browser, Login
from .modules import (Config, CreatePDF, DeleteIMG, DownloadIMG, LinkParse,
PrintIntro, UserOptions, setup_argparse)
from .utils import create_directory, logger, pause, print_title
3 changes: 2 additions & 1 deletion src/bot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Selenium bot"""

from __future__ import annotations

from .action import Action
from .browser import Browser
from .login import Login
from .action import Action
Loading

0 comments on commit cd30973

Please sign in to comment.