Skip to content

Commit

Permalink
make pdfkit optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Romern committed Jul 6, 2024
1 parent 33908e2 commit 8d4576a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ install_requires =
requests>=2.0.0
beautifulsoup4>=4.0.0
yt-dlp>=2021.12.27
pdfkit>=0.6.0
tqdm>=4.0.0

[options.extras_require]
quiz =
pdfkit>=0.6.0
keyring =
secretstorage>=3.1.0
test =
Expand Down
10 changes: 9 additions & 1 deletion syncmymoodle/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
from time import sleep
from typing import TYPE_CHECKING, List

import pdfkit
try:
import pdfkit
except ImportError:
pdfkit = None

import requests
import yt_dlp
from bs4 import BeautifulSoup as bs
Expand Down Expand Up @@ -1237,6 +1241,10 @@ def main():

logging.basicConfig(level=args.loglevel)

if pdfkit is None and config["used_modules"]["url"]["quiz"]:
config["used_modules"]["url"]["quiz"] = False
logger.warning("pdfkit is not installed. Quiz-PDFs are NOT generated")

if not shutil.which("wkhtmltopdf") and config["used_modules"]["url"]["quiz"]:
config["used_modules"]["url"]["quiz"] = False
logger.warning(
Expand Down

0 comments on commit 8d4576a

Please sign in to comment.