convert-stream 1.4.1__tar.gz → 2.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of convert-stream might be problematic. Click here for more details.
- {convert_stream-1.4.1 → convert_stream-2.2.1}/PKG-INFO +4 -2
- convert_stream-2.2.1/convert_stream/__init__.py +31 -0
- convert_stream-2.2.1/convert_stream/__main__.py +25 -0
- {convert_stream-1.4.1 → convert_stream-2.2.1}/convert_stream/_version.py +4 -2
- convert_stream-2.2.1/convert_stream/enum_libs/enums.py +70 -0
- convert_stream-2.2.1/convert_stream/enum_libs/modules.py +128 -0
- convert_stream-2.2.1/convert_stream/image/__init__.py +7 -0
- convert_stream-2.2.1/convert_stream/image/img_object.py +584 -0
- convert_stream-2.2.1/convert_stream/pdf/__init__.py +14 -0
- convert_stream-2.2.1/convert_stream/pdf/image_to_pdf.py +350 -0
- convert_stream-2.2.1/convert_stream/pdf/pdf_document.py +520 -0
- convert_stream-2.2.1/convert_stream/pdf/pdf_page.py +357 -0
- convert_stream-2.2.1/convert_stream/pdf/pdf_to_image.py +157 -0
- convert_stream-2.2.1/convert_stream/sheets/__init__.py +8 -0
- convert_stream-2.2.1/convert_stream/sheets/load.py +349 -0
- convert_stream-2.2.1/convert_stream/sheets/parse.py +71 -0
- convert_stream-2.2.1/convert_stream/sheets/save.py +29 -0
- convert_stream-2.2.1/convert_stream/stream.py +180 -0
- convert_stream-2.2.1/convert_stream/table_files.py +431 -0
- convert_stream-2.2.1/convert_stream/text/__init__.py +6 -0
- convert_stream-2.2.1/convert_stream/text/date.py +216 -0
- convert_stream-2.2.1/convert_stream/text/string.py +377 -0
- {convert_stream-1.4.1 → convert_stream-2.2.1}/convert_stream.egg-info/PKG-INFO +4 -2
- convert_stream-2.2.1/convert_stream.egg-info/SOURCES.txt +28 -0
- {convert_stream-1.4.1 → convert_stream-2.2.1}/convert_stream.egg-info/requires.txt +3 -1
- {convert_stream-1.4.1 → convert_stream-2.2.1}/pyproject.toml +9 -4
- convert_stream-1.4.1/convert_stream/__init__.py +0 -27
- convert_stream-1.4.1/convert_stream/__main__.py +0 -41
- convert_stream-1.4.1/convert_stream/convert.py +0 -551
- convert_stream-1.4.1/convert_stream/image_to_pdf.py +0 -270
- convert_stream-1.4.1/convert_stream/imagelib.py +0 -533
- convert_stream-1.4.1/convert_stream/models/__init__.py +0 -12
- convert_stream-1.4.1/convert_stream/models/m_text.py +0 -472
- convert_stream-1.4.1/convert_stream/models/models_image.py +0 -104
- convert_stream-1.4.1/convert_stream/models/models_pdf.py +0 -104
- convert_stream-1.4.1/convert_stream/pdf_compress.py +0 -136
- convert_stream-1.4.1/convert_stream/pdf_document.py +0 -837
- convert_stream-1.4.1/convert_stream/pdf_page.py +0 -308
- convert_stream-1.4.1/convert_stream/pdf_to_images.py +0 -166
- convert_stream-1.4.1/convert_stream/progress/__init__.py +0 -1
- convert_stream-1.4.1/convert_stream/progress/progress_bar.py +0 -24
- convert_stream-1.4.1/convert_stream/table_files.py +0 -208
- convert_stream-1.4.1/convert_stream/text.py +0 -8
- convert_stream-1.4.1/convert_stream.egg-info/SOURCES.txt +0 -25
- {convert_stream-1.4.1 → convert_stream-2.2.1}/README.md +0 -0
- {convert_stream-1.4.1 → convert_stream-2.2.1}/convert_stream.egg-info/dependency_links.txt +0 -0
- {convert_stream-1.4.1 → convert_stream-2.2.1}/convert_stream.egg-info/top_level.txt +0 -0
- {convert_stream-1.4.1 → convert_stream-2.2.1}/setup.cfg +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: convert_stream
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Manipulação de documentos PDF e Imagens. Converter, Ler, rotacionar exportar etc.
|
|
5
5
|
Author: Bruno Chaves
|
|
6
6
|
Requires-Python: >=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: soup_files
|
|
8
|
+
Requires-Dist: soup_files>=1.4
|
|
9
9
|
Requires-Dist: PyMuPDF
|
|
10
|
+
Requires-Dist: scipy
|
|
10
11
|
Requires-Dist: reportlab
|
|
11
12
|
Requires-Dist: openpyxl
|
|
13
|
+
Requires-Dist: odfpy
|
|
12
14
|
Requires-Dist: pandas
|
|
13
15
|
Requires-Dist: Pillow>=11.3.0
|
|
14
16
|
Requires-Dist: opencv-python
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from ._version import (
|
|
4
|
+
__module_name__, __author__, __license__, __modify_date__, __version__
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
from convert_stream.enum_libs.enums import *
|
|
8
|
+
from convert_stream.enum_libs.modules import (
|
|
9
|
+
LibPDF, LibDate, LibImage, LibPdfToImage, LibImageToPdf,
|
|
10
|
+
DEFAULT_LIB_PDF, DEFAULT_LIB_IMAGE, DEFAULT_LIB_PDF_TO_IMG,
|
|
11
|
+
DEFAULT_LIB_IMAGE_TO_PDF, ModPdfToImage, ModulePagePdf, ModuleImage,
|
|
12
|
+
ModImageToPdf, MOD_FITZ, MOD_PYPDF, MOD_CANVAS, MOD_IMG_PIL, MOD_IMG_OPENCV,
|
|
13
|
+
)
|
|
14
|
+
from .text.string import (
|
|
15
|
+
FindText, ArrayString, print_line, print_title, MapText
|
|
16
|
+
)
|
|
17
|
+
from .text.date import ConvertStringDate
|
|
18
|
+
from convert_stream.image.img_object import (
|
|
19
|
+
ImageObject, Image, MatLike, get_hash_from_bytes, CollectionImages,
|
|
20
|
+
)
|
|
21
|
+
from convert_stream.pdf import (
|
|
22
|
+
PageDocumentPdf, DocumentPdf, ConvertImageToPdf, ConvertPdfToImages,
|
|
23
|
+
ModImageToPdf, ModuleDocPdf, CollectionPagePdf, DEFAULT_LIB_PDF,
|
|
24
|
+
DEFAULT_LIB_IMAGE_TO_PDF, DEFAULT_LIB_PDF_TO_IMG
|
|
25
|
+
)
|
|
26
|
+
from .stream import PdfStream, SplitPdf
|
|
27
|
+
from .sheets import save_data, ReadFileSheet
|
|
28
|
+
from .table_files import (
|
|
29
|
+
get_void_df, create_df_from_file_pdf, create_map_from_values,
|
|
30
|
+
FileToTable, ColumnsTable, PdfFinder, SearchableTextPdf
|
|
31
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Configuração instalação:
|
|
5
|
+
$ pip3 install -r requirements.txt
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
this_file = os.path.abspath(os.path.relpath(__file__))
|
|
12
|
+
dir_of_project = os.path.dirname(this_file)
|
|
13
|
+
sys.path.insert(0, dir_of_project)
|
|
14
|
+
|
|
15
|
+
from convert_stream import (
|
|
16
|
+
__version__, __module_name__, __modify_date__
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def main():
|
|
21
|
+
print(f' {__module_name__} V{__version__} {__modify_date__}')
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == '__main__':
|
|
25
|
+
main()
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ColumnsTable(Enum):
|
|
7
|
+
|
|
8
|
+
NUM_LINHA = 'NUM_LINHA'
|
|
9
|
+
NUM_PAGE = 'NUM_PÁGINA'
|
|
10
|
+
TEXT = 'TEXTO'
|
|
11
|
+
FILE = 'ARQUIVO'
|
|
12
|
+
FILENAME = 'NOME_ARQUIVO'
|
|
13
|
+
DIR = 'PASTA'
|
|
14
|
+
FILETYPE = 'TIPO_ARQUIVO'
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def to_list(cls) -> list[str]:
|
|
18
|
+
return [
|
|
19
|
+
cls.NUM_LINHA.value,
|
|
20
|
+
cls.NUM_PAGE.value,
|
|
21
|
+
cls.TEXT.value,
|
|
22
|
+
cls.FILE.value,
|
|
23
|
+
cls.FILENAME.value,
|
|
24
|
+
cls.FILETYPE.value,
|
|
25
|
+
cls.DIR.value,
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class LibPdfToImage(Enum):
|
|
30
|
+
|
|
31
|
+
PDF_TO_IMG_FITZ = 'fitz'
|
|
32
|
+
NOT_IMPLEMENTED = 'null'
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class LibImageToPdf(Enum):
|
|
36
|
+
|
|
37
|
+
IMAGE_TO_PDF_FITZ = 'fitz'
|
|
38
|
+
IMAGE_TO_PDF_CANVAS = 'canvas'
|
|
39
|
+
IMAGE_TO_PDF_PIL = 'pil'
|
|
40
|
+
NOT_IMPLEMENTED = 'null'
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class LibPDF(Enum):
|
|
44
|
+
|
|
45
|
+
PYPDF = 'pypdf'
|
|
46
|
+
FITZ = 'fitz'
|
|
47
|
+
NOT_IMPLEMENTED = 'null'
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class LibImage(Enum):
|
|
51
|
+
|
|
52
|
+
PIL = 'pil'
|
|
53
|
+
OPENCV = 'opencv'
|
|
54
|
+
NOT_IMPLEMENTED = 'null'
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class LibDate(Enum):
|
|
58
|
+
D_M_Y = '%d-%m-%Y'
|
|
59
|
+
DMY = '%d/%m/%Y'
|
|
60
|
+
dmy = '%d/%m/%y'
|
|
61
|
+
d_m_y = '%d-%m-%y'
|
|
62
|
+
YMD = '%Y/%m/%d'
|
|
63
|
+
Y_M_D = '%Y-%m-%d'
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class RotationAngle(Enum):
|
|
67
|
+
|
|
68
|
+
ROTATION_90 = 90
|
|
69
|
+
ROTATION_180 = 180
|
|
70
|
+
ROTATION_270 = 270
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from typing import Union, TypeAlias
|
|
5
|
+
from convert_stream.enum_libs.enums import *
|
|
6
|
+
|
|
7
|
+
MOD_IMG_PIL: bool = False
|
|
8
|
+
MOD_IMG_OPENCV: bool = False
|
|
9
|
+
MOD_PYPDF: bool = False
|
|
10
|
+
MOD_FITZ: bool = False
|
|
11
|
+
MOD_CANVAS: bool = False
|
|
12
|
+
|
|
13
|
+
#=================================================================#
|
|
14
|
+
# Módulos de Imagen, PIL e opencv
|
|
15
|
+
#=================================================================#
|
|
16
|
+
try:
|
|
17
|
+
import cv2
|
|
18
|
+
from cv2.typing import MatLike
|
|
19
|
+
MOD_IMG_OPENCV = True
|
|
20
|
+
except ImportError:
|
|
21
|
+
cv2.typing.MatLike = object
|
|
22
|
+
MatLike = None
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
from PIL import Image
|
|
26
|
+
from PIL import ImageOps, ImageFilter
|
|
27
|
+
MOD_IMG_PIL = True
|
|
28
|
+
except ImportError:
|
|
29
|
+
Image = None
|
|
30
|
+
Image.Image = None
|
|
31
|
+
|
|
32
|
+
if MOD_IMG_OPENCV and MOD_IMG_PIL:
|
|
33
|
+
ModuleImage: TypeAlias = Union[MatLike, Image.Image]
|
|
34
|
+
DEFAULT_LIB_IMAGE = LibImage.OPENCV
|
|
35
|
+
elif MOD_IMG_OPENCV:
|
|
36
|
+
ModuleImage: TypeAlias = Union[MatLike]
|
|
37
|
+
DEFAULT_LIB_IMAGE = LibImage.OPENCV
|
|
38
|
+
elif MOD_IMG_PIL:
|
|
39
|
+
ModuleImage: TypeAlias = Union[Image.Image]
|
|
40
|
+
DEFAULT_LIB_IMAGE = LibImage.PIL
|
|
41
|
+
else:
|
|
42
|
+
DEFAULT_LIB_IMAGE = LibImage.NOT_IMPLEMENTED
|
|
43
|
+
ModuleImage = None # fallback para runtime
|
|
44
|
+
|
|
45
|
+
#=================================================================#
|
|
46
|
+
# Módulos para PDF fitz e pypdf
|
|
47
|
+
#=================================================================#
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
import fitz
|
|
51
|
+
MOD_FITZ = True
|
|
52
|
+
except ImportError:
|
|
53
|
+
try:
|
|
54
|
+
import pymupdf as fitz
|
|
55
|
+
MOD_FITZ = True
|
|
56
|
+
except ImportError:
|
|
57
|
+
fitz = None
|
|
58
|
+
fitz.Page = None
|
|
59
|
+
fitz.TextPage = None
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
from pypdf import PdfWriter, PdfReader, PageObject
|
|
63
|
+
MOD_PYPDF = True
|
|
64
|
+
except ImportError:
|
|
65
|
+
PageObject = None
|
|
66
|
+
PdfReader = None
|
|
67
|
+
PdfWriter = None
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if MOD_FITZ and MOD_PYPDF:
|
|
71
|
+
ModulePagePdf: TypeAlias = Union[PageObject, fitz.Page]
|
|
72
|
+
ModuleDocPdf: TypeAlias = Union[fitz.Document, PdfWriter]
|
|
73
|
+
DEFAULT_LIB_PDF = LibPDF.FITZ
|
|
74
|
+
elif MOD_FITZ:
|
|
75
|
+
ModulePagePdf: TypeAlias = Union[fitz.Page]
|
|
76
|
+
ModuleDocPdf: TypeAlias = Union[fitz.Document]
|
|
77
|
+
DEFAULT_LIB_PDF = LibPDF.FITZ
|
|
78
|
+
elif MOD_PYPDF:
|
|
79
|
+
ModulePagePdf: TypeAlias = Union[PageObject]
|
|
80
|
+
ModuleDocPdf: TypeAlias = Union[PdfWriter]
|
|
81
|
+
DEFAULT_LIB_PDF = LibPDF.PYPDF
|
|
82
|
+
else:
|
|
83
|
+
ModulePagePdf = None # fallback para runtime
|
|
84
|
+
ModuleDocPdf: TypeAlias = None
|
|
85
|
+
DEFAULT_LIB_PDF = LibPDF.NOT_IMPLEMENTED
|
|
86
|
+
|
|
87
|
+
#=================================================================#
|
|
88
|
+
# Módulos para converter imagem em PDF.
|
|
89
|
+
#=================================================================#
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
from reportlab.pdfgen import canvas
|
|
93
|
+
from reportlab.pdfgen.canvas import Canvas
|
|
94
|
+
from reportlab.lib.pagesizes import letter
|
|
95
|
+
from reportlab.lib.utils import ImageReader
|
|
96
|
+
MOD_CANVAS = True
|
|
97
|
+
except ImportError:
|
|
98
|
+
canvas = None
|
|
99
|
+
Canvas = None
|
|
100
|
+
letter = (612, 792)
|
|
101
|
+
ImageReader = None
|
|
102
|
+
|
|
103
|
+
if MOD_CANVAS and MOD_FITZ and MOD_IMG_PIL:
|
|
104
|
+
ModImageToPdf: TypeAlias = Union[canvas, fitz.Page, Image]
|
|
105
|
+
DEFAULT_LIB_IMAGE_TO_PDF = LibImageToPdf.IMAGE_TO_PDF_FITZ
|
|
106
|
+
elif MOD_FITZ:
|
|
107
|
+
ModImageToPdf: TypeAlias = Union[fitz.Page]
|
|
108
|
+
DEFAULT_LIB_IMAGE_TO_PDF = LibImageToPdf.IMAGE_TO_PDF_FITZ
|
|
109
|
+
elif MOD_CANVAS:
|
|
110
|
+
ModImageToPdf: TypeAlias = Union[canvas]
|
|
111
|
+
DEFAULT_LIB_IMAGE_TO_PDF = LibImageToPdf.IMAGE_TO_PDF_CANVAS
|
|
112
|
+
elif MOD_IMG_PIL:
|
|
113
|
+
ModImageToPdf: TypeAlias = Union[Image]
|
|
114
|
+
DEFAULT_LIB_IMAGE_TO_PDF = LibImageToPdf.IMAGE_TO_PDF_PIL
|
|
115
|
+
else:
|
|
116
|
+
ModImageToPdf = None
|
|
117
|
+
DEFAULT_LIB_IMAGE_TO_PDF = LibImageToPdf.NOT_IMPLEMENTED
|
|
118
|
+
|
|
119
|
+
#=================================================================#
|
|
120
|
+
# Módulos para converter PDF em imagem
|
|
121
|
+
#=================================================================#
|
|
122
|
+
|
|
123
|
+
if MOD_FITZ:
|
|
124
|
+
DEFAULT_LIB_PDF_TO_IMG = LibPdfToImage.PDF_TO_IMG_FITZ
|
|
125
|
+
ModPdfToImage: TypeAlias = Union[fitz]
|
|
126
|
+
else:
|
|
127
|
+
DEFAULT_LIB_PDF_TO_IMG = LibPdfToImage.NOT_IMPLEMENTED
|
|
128
|
+
ModPdfToImage = None
|