pdfminer.six optional

This commit is contained in:
mousebot 2020-04-30 17:17:19 -03:00
parent a8f34b2e06
commit b6bc9c8470
2 changed files with 13 additions and 7 deletions

View File

@ -5,11 +5,6 @@ import markovify
import sys import sys
import html2text import html2text
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from io import StringIO
fnf = ": error: file not found. please provide a path to a really-existing file!" fnf = ": error: file not found. please provide a path to a really-existing file!"
@ -144,6 +139,17 @@ def dir_cat(matchlist, bulkfile):
# extract full text from a pdf: # extract full text from a pdf:
def convert_pdf(path): def convert_pdf(path):
try:
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from io import StringIO
except ModuleNotFoundError as exc:
print(
f": there was trouble: {exc}.\n: install 'pdfminer.six' with pip to convert a pdf."
)
sys.exit()
print(": converting pdf file...") print(": converting pdf file...")
try: try:
rsrcmgr = PDFResourceManager() rsrcmgr = PDFResourceManager()

View File

@ -9,7 +9,7 @@ with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
setup( setup(
name="mkv-this", name="mkv-this",
version="0.2.4", version="0.2.5",
description="cli wrapper for markovify: take a text file, directory, pdf or url, markovify, save the results.", description="cli wrapper for markovify: take a text file, directory, pdf or url, markovify, save the results.",
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
@ -24,6 +24,6 @@ setup(
"mkv-this-dir = mkv_this.mkv_this_dir:main", "mkv-this-dir = mkv_this.mkv_this_dir:main",
] ]
}, },
install_requires=["markovify", "argparse", "html2text", "requests", "pdfminer.six",], install_requires=["markovify", "argparse", "html2text", "requests",],
zip_safe=False, zip_safe=False,
) )