diff --git a/mglib/mime.py b/mglib/mime.py index dd03eec..73e001b 100644 --- a/mglib/mime.py +++ b/mglib/mime.py @@ -31,10 +31,15 @@ class Mime(wrapper.Wrapper): * image/png * image/jpg """ - return self.guess() in ('image/png', 'image/jpg') + return self.guess() in ('image/png', 'image/jpg', 'image/jpeg') def guess(self): cmd = self.get_cmd() complete = self.run(cmd) return complete.stdout.strip() + + def __str__(self): + + mime_type = self.guess() + return f"Mime({self.filepath}, {mime_type})" diff --git a/mglib/utils.py b/mglib/utils.py index 95174d0..2aefdb0 100644 --- a/mglib/utils.py +++ b/mglib/utils.py @@ -13,6 +13,7 @@ SAFE_EXTENSIONS = [ '.png', '.hocr', '.pdf', + '.tiff' ] diff --git a/setup.py b/setup.py index 6e399c9..6b1da2d 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md", "r") as fh: setup( name="mglib", - version="1.2.1", + version="1.2.2", author="Eugen Ciur", author_email="eugen@papermerge.com", url="https://github.com/papermerge/mglib", diff --git a/test/test_path.py b/test/test_path.py index 09f9a08..ad10dd1 100644 --- a/test/test_path.py +++ b/test/test_path.py @@ -76,16 +76,16 @@ class TestDocumentPath(unittest.TestCase): class TestPagePath(unittest.TestCase): def test_versioned_page_ep(self): - doc_ep = DocumentPath( + doc_path = DocumentPath( user_id=1, document_id=3, file_name="x.pdf" ) # document's version incremented - doc_ep.inc_version() + doc_path.inc_version() page_ep = PagePath( - document_ep=doc_ep, + document_path=doc_path, page_num=1, page_count=3 ) @@ -105,7 +105,7 @@ class TestPagePath(unittest.TestCase): file_name="x.pdf" ) page_ep = PagePath( - document_ep=doc_ep, + document_path=doc_ep, page_num=1, step=Step(1), page_count=3 @@ -122,7 +122,7 @@ class TestPagePath(unittest.TestCase): file_name="x.pdf" ) page_url = PagePath( - document_ep=doc_ep, + document_path=doc_ep, page_num=1, step=Step(1), page_count=3 diff --git a/test/test_storage.py b/test/test_storage.py index 37be6d2..5c3dd84 100644 --- a/test/test_storage.py +++ b/test/test_storage.py @@ -35,7 +35,7 @@ class TestStorage(unittest.TestCase): f1.exists() ) - storage.delete_document(doc_path) + storage.delete_doc(doc_path) self.assertFalse( f1.exists()