Compare commits

...

4 Commits

Author SHA1 Message Date
Eugen Ciur 21a9ebb57b README and setup.cfg updated 2021-01-19 12:25:21 +01:00
Eugen Ciur 2d7c96be4e update mglib 2021-01-19 12:18:29 +01:00
Eugen Ciur 90352965e6 PEP8 2021-01-19 11:30:01 +01:00
Eugen Ciur e267f7e98f adding pdfname_from_tiffname 2021-01-19 08:37:36 +01:00
5 changed files with 58 additions and 41 deletions

View File

@ -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

20
README.rst Normal file
View File

@ -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

View File

@ -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

16
setup.cfg Normal file
View File

@ -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

View File

@ -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',
)