chore: Remove python-magic dependency
It relies on the libmagic module which is not necessarily installed everywhere. Most of the functionality that we need for our purposes can be recreated with lighter-weight methods.
This commit is contained in:
parent
17c6fefd89
commit
1a4b5e3a70
5 changed files with 33 additions and 12 deletions
|
|
@ -1,10 +1,10 @@
|
|||
# pyright: strict, reportMissingTypeStubs=false, reportUnknownMemberType=false
|
||||
import mimetypes
|
||||
from collections.abc import Generator
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple, cast
|
||||
|
||||
import Levenshtein
|
||||
import magic
|
||||
import papis.config
|
||||
import papis.logging
|
||||
import pymupdf as mu
|
||||
|
|
@ -77,7 +77,7 @@ class PdfExtractor:
|
|||
|
||||
def _is_pdf(self, fname: Path) -> bool:
|
||||
"""Check if file is a pdf, using mime type."""
|
||||
return magic.from_file(fname, mime=True) == "application/pdf"
|
||||
return mimetypes.guess_type(fname)[0] == "application/pdf"
|
||||
|
||||
def _get_annotation_content(
|
||||
self, page: mu.Page, annotation: mu.Annot
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue