mirror of https://github.com/papermerge/mglib
Compare commits
4 Commits
4a7099a16b
...
21a9ebb57b
Author | SHA1 | Date |
---|---|---|
Eugen Ciur | 21a9ebb57b | |
Eugen Ciur | 2d7c96be4e | |
Eugen Ciur | 90352965e6 | |
Eugen Ciur | e267f7e98f |
18
README.md
18
README.md
|
@ -1,18 +0,0 @@
|
|||
MgLib
|
||||
=======
|
||||
|
||||
Python Package containing modules shared across all [Papermerge Project](https://github.com/ciur/papermerge) project.
|
||||
|
||||
## Installation
|
||||
|
||||
pip install mglib
|
||||
|
||||
|
||||
## Run tests
|
||||
|
||||
python test/run.py
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
python >= 3.7
|
|
@ -0,0 +1,20 @@
|
|||
MgLib
|
||||
=======
|
||||
|
||||
Python Package containing modules shared across all `Papermerge Project <https://github.com/ciur/papermerge>`_ project.
|
||||
|
||||
Installation
|
||||
##############
|
||||
|
||||
pip install mglib
|
||||
|
||||
Run tests
|
||||
###########
|
||||
|
||||
python test/run.py
|
||||
|
||||
|
||||
Requirements
|
||||
##############
|
||||
|
||||
python >= 3.7
|
|
@ -7,16 +7,34 @@ from .conf import settings
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def convert_tiff2pdf(doc_url):
|
||||
def pdfname_from_tiffname(doc_url):
|
||||
"""
|
||||
Given tiff document url, will return
|
||||
respective pdf file name. Returned
|
||||
file name can be use used as destination
|
||||
for tiff2pdf tool.
|
||||
|
||||
logger.debug(f"convert_tiff2pdf for {doc_url}")
|
||||
Returns a tuple (new_doc_url, new_filename).
|
||||
new_doc_url - is new absolute path to the pdf file
|
||||
new_filename - is new pdf filename
|
||||
"""
|
||||
# basename is filename + ext (no path)
|
||||
|
||||
basename = os.path.basename(doc_url)
|
||||
base_root, base_ext = os.path.splitext(basename)
|
||||
root, ext = os.path.splitext(doc_url)
|
||||
new_doc_url = f"{root}.pdf"
|
||||
|
||||
return new_doc_url, f"{base_root}.pdf"
|
||||
|
||||
|
||||
def convert_tiff2pdf(doc_url):
|
||||
|
||||
logger.debug(f"convert_tiff2pdf for {doc_url}")
|
||||
|
||||
new_doc_url, new_filename = pdfname_from_tiffname(
|
||||
doc_url
|
||||
)
|
||||
|
||||
logger.debug(
|
||||
f"tiff2pdf source={doc_url} dest={new_doc_url}"
|
||||
)
|
||||
|
@ -30,4 +48,4 @@ def convert_tiff2pdf(doc_url):
|
|||
run(cmd)
|
||||
|
||||
# returns new filename
|
||||
return f"{base_root}.pdf"
|
||||
return new_filename
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
[metadata]
|
||||
name = mglib
|
||||
version = 1.3.6
|
||||
description = Common code used across all Papermerge project utilities
|
||||
long_description = file: README.rst
|
||||
url = https://www.papermerge.com/
|
||||
author = Eugen Ciur
|
||||
author_email = eugen@papermerge.com
|
||||
keywords= common, package, shared, papermerge, pdf, ocr, dms
|
||||
license = Apache 2.0 License
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3 :: Only
|
||||
Programming Language :: Python :: 3.7
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: OS Independent
|
19
setup.py
19
setup.py
|
@ -1,25 +1,6 @@
|
|||
from setuptools import find_packages, setup
|
||||
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
|
||||
setup(
|
||||
name="mglib",
|
||||
version="1.3.5",
|
||||
author="Eugen Ciur",
|
||||
author_email="eugen@papermerge.com",
|
||||
url="https://github.com/papermerge/mglib",
|
||||
description="Common code used across all Papermerge project utilities",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
license="Apache 2.0 License",
|
||||
keywords="common, package, shared, papermerge, pdf, ocr, dms",
|
||||
packages=find_packages(),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
python_requires='>=3.7',
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue