pyflutter-app 0.2.7__tar.gz → 0.2.8__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.
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/PKG-INFO +5 -1
- pyflutter_app-0.2.8/cartas/__init__.py +17 -0
- pyflutter_app-0.2.8/cartas/_table_toi.py +249 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/cartas/common.py +22 -23
- pyflutter_app-0.2.8/cartas/relatorio.py +453 -0
- pyflutter_app-0.2.8/cartas/util.py +43 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/common.py +58 -43
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/controller_forms.py +41 -19
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/model_forms.py +52 -23
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/mediator.py +51 -34
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/ocrlib/__init__.py +3 -4
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/ocrlib/_common.py +66 -48
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/ocrlib/_pdf_convert.py +319 -234
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/ocrlib/_table_ocr.py +308 -213
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/ocrlib/_tesseract.py +94 -65
- pyflutter_app-0.2.8/ocrlib/erros.py +10 -0
- pyflutter_app-0.2.8/ocrlib/relatorio_ocr.py +622 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/ocrlib/util.py +2 -2
- pyflutter_app-0.2.7/pyproject.toml.back → pyflutter_app-0.2.8/pyproject.toml +1 -1
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/__init__.py +3 -3
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/erros.py +0 -6
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/hash_map.py +104 -52
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/table.py +86 -17
- pyflutter_app-0.2.8/test.py +148 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/uv.lock +237 -1
- pyflutter_app-0.2.8/whatsapp_files/__init__.py +21 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/whatsapp_files/_table_whatsapp.py +143 -138
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/whatsapp_files/common.py +49 -24
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/whatsapp_files/stream_files.py +219 -129
- pyflutter_app-0.2.8/whatsapp_files/util.py +36 -0
- pyflutter_app-0.2.7/cartas/__init__.py +0 -6
- pyflutter_app-0.2.7/cartas/_table_toi.py +0 -151
- pyflutter_app-0.2.7/cartas/relatorio.py +0 -350
- pyflutter_app-0.2.7/ocrlib/erros.py +0 -5
- pyflutter_app-0.2.7/ocrlib/relatorio_ocr.py +0 -578
- pyflutter_app-0.2.7/pyproject.toml +0 -34
- pyflutter_app-0.2.7/test.py +0 -36
- pyflutter_app-0.2.7/whatsapp_files/__init__.py +0 -12
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/.gitignore +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/.idea/.gitignore +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/.idea/inspectionProfiles/Project_Default.xml +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/.idea/misc.xml +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/.idea/modules.xml +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/.idea/pyflutter_app.iml +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/.idea/vcs.xml +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/README.md +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/cartas/erros.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/cartas/find_toi.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/__init__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/__main__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/assets/forms_config.json +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/config_app.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/home_page/__init__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/home_page/_page_edit.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/home_page/controller.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/home_page/model.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/home_page/view.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/lib_toi.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/Diagnorstico.txt +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/__init__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/config.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/diagnose_forms.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/service.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/page_forms/view_forms.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/run_app_convert.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/table_widget.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/util.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/whatsapp/__init__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/converter/whatsapp/model.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/export_app.sh +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/local_build/linux.sh +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/local_build/send.sh +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/main.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/mvc/controller.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/mvc/model.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/mvc/view.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/new-export_app.sh +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/ocrlib/export_ocr.sh +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/__init__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/app.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/file_picker.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/navigator.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/scheduler.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/theme.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/ui/__init__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/ui/buttons.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/ui/container.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/ui/core.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/ui/list_builder.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/ui/progress.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/ui/tables.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/pyflutter_ui/ui/widgets.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/notifier.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/pattner/__init__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/pattner/adapter.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/sheet/__init__.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/sheet/check_mod.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/sheet/load.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/sheet/options.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/sheet/parse.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/sheet/save.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/state.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/sysfiles.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/thread.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/table_stream/workbook.py +0 -0
- {pyflutter_app-0.2.7 → pyflutter_app-0.2.8}/whatsapp_files/erros.py +0 -0
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pyflutter_app
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Bibliotecas Python para conversão de documentos, interface e processamento de tabelas.
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
|
+
Requires-Dist: opencv-python>=5.0.0.93
|
|
6
7
|
Requires-Dist: openpyxl>=3.1.5
|
|
7
8
|
Requires-Dist: pandas-stubs~=3.0.3
|
|
8
9
|
Requires-Dist: pandas>=3.0.0
|
|
10
|
+
Requires-Dist: playwright>=1.63.0
|
|
11
|
+
Requires-Dist: pymupdf>=1.28.2
|
|
12
|
+
Requires-Dist: pytesseract>=0.3.13
|
|
9
13
|
Description-Content-Type: text/markdown
|
|
10
14
|
|
|
11
15
|
# pyflutter
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from ._table_toi import (
|
|
2
|
+
HeaderTOI,
|
|
3
|
+
HeaderCartas,
|
|
4
|
+
TableTOI,
|
|
5
|
+
LocalEntregaCarta,
|
|
6
|
+
TipoCarta,
|
|
7
|
+
BuilderTablesTOI,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from .find_toi import extrair_uc_toi
|
|
11
|
+
from .common import BuilderConfigTOI, ConfigTOI
|
|
12
|
+
|
|
13
|
+
from .relatorio import (
|
|
14
|
+
ControllerTOI,
|
|
15
|
+
ReadWriteTableTOI,
|
|
16
|
+
load_files_toi,
|
|
17
|
+
)
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from enum import StrEnum
|
|
3
|
+
from typing import Any, Callable, TypeVar
|
|
4
|
+
|
|
5
|
+
from pandas import DataFrame
|
|
6
|
+
|
|
7
|
+
from cartas.util import (
|
|
8
|
+
ArrayList,
|
|
9
|
+
HashMapDict,
|
|
10
|
+
Table,
|
|
11
|
+
TableData,
|
|
12
|
+
ColumnV,
|
|
13
|
+
RowH,
|
|
14
|
+
PathElement,
|
|
15
|
+
Directory,
|
|
16
|
+
File,
|
|
17
|
+
concat_tables,
|
|
18
|
+
ColumnNotFoundError,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from table_stream import (
|
|
22
|
+
HeaderMetaData,
|
|
23
|
+
HeadersSizeNotIqualError,
|
|
24
|
+
hashFile,
|
|
25
|
+
load_file_hash,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
from cartas.common import ConfigTOI, BuilderConfigTOI
|
|
29
|
+
import pandas as pd
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class HeaderTOI(StrEnum):
|
|
33
|
+
"""
|
|
34
|
+
Enumerador que representa a relação entre um documento e os dados
|
|
35
|
+
de entrega, como UC, TOI DATA etc...
|
|
36
|
+
a relação/key de uma entrega e a hash do documento.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
UC = "uc"
|
|
40
|
+
TOI = "toi"
|
|
41
|
+
DAY = "day"
|
|
42
|
+
MON = "mon"
|
|
43
|
+
YEAR = "year"
|
|
44
|
+
DATE = "data_entrega"
|
|
45
|
+
HASH_FILE = HeaderMetaData.HASH_FILE.value
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class HeaderCartas(StrEnum):
|
|
49
|
+
"""
|
|
50
|
+
Dados completos de uma entrega TOI, incluindo os metadados e
|
|
51
|
+
caminho absoluto dos arquivos.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
UC = HeaderTOI.UC
|
|
55
|
+
TOI = HeaderTOI.TOI
|
|
56
|
+
DAY = HeaderTOI.DAY
|
|
57
|
+
MON = HeaderTOI.MON
|
|
58
|
+
YEAR = HeaderTOI.YEAR
|
|
59
|
+
DATE = HeaderTOI.DATE
|
|
60
|
+
HASH_FILE = HeaderTOI.HASH_FILE
|
|
61
|
+
|
|
62
|
+
LOCAL_ENTREGA = "local_entrega"
|
|
63
|
+
TIPO_DOC = "tipo_carta"
|
|
64
|
+
|
|
65
|
+
IS_FILE = "arquivo?"
|
|
66
|
+
FULL_PATH = HeaderMetaData.FILE_PATH.value
|
|
67
|
+
SRC = HeaderMetaData.PARENT_DIR.value
|
|
68
|
+
FILE_EXTENSION = HeaderMetaData.FILE_EXTENSION.value
|
|
69
|
+
FILE_BASENAME = "basename"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class TipoCarta(StrEnum):
|
|
73
|
+
|
|
74
|
+
CARTA_CALCULO = "CARTA-CALCULO"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class LocalEntregaCarta(StrEnum):
|
|
78
|
+
|
|
79
|
+
OUTRO = "OUTRO"
|
|
80
|
+
MAOS = "MÃOS"
|
|
81
|
+
CORREIOS = "CORREIOS"
|
|
82
|
+
PORTAO = "PORTÃO"
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class TableTOI(TableData[HeaderTOI]):
|
|
86
|
+
"""
|
|
87
|
+
Tabela para representar dados de das entregas de uma carta TOI. Não inclui meta dados dos arquivos.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
def __init__(self, data: DataFrame | None = None) -> None:
|
|
91
|
+
super().__init__(data)
|
|
92
|
+
|
|
93
|
+
def rows(self) -> ArrayList[RowH[HeaderTOI, Any]]:
|
|
94
|
+
return super().rows()
|
|
95
|
+
|
|
96
|
+
def select_columns(self, header: list[HeaderTOI]) -> TableTOI:
|
|
97
|
+
return TableTOI.create_from_data(super().select_columns(header).to_dataframe())
|
|
98
|
+
|
|
99
|
+
def search(self, h: HeaderTOI, value: Any) -> TableTOI:
|
|
100
|
+
return TableTOI.create_from_data(super().search(h, value).to_dataframe())
|
|
101
|
+
|
|
102
|
+
def drop_duplicates(self) -> TableTOI:
|
|
103
|
+
return TableTOI(super().drop_duplicates().to_dataframe())
|
|
104
|
+
|
|
105
|
+
@classmethod
|
|
106
|
+
def create_from_data(cls, data: DataFrame) -> TableTOI:
|
|
107
|
+
return TableTOI.builder().create_table_toi_from_df(data)
|
|
108
|
+
|
|
109
|
+
@staticmethod
|
|
110
|
+
def builder() -> BuilderTablesTOI:
|
|
111
|
+
return BuilderTablesTOI()
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class BuilderTablesTOI(object):
|
|
115
|
+
|
|
116
|
+
def __init__(self) -> None:
|
|
117
|
+
|
|
118
|
+
self.default_cols_toi = ArrayList[HeaderTOI].from_list(
|
|
119
|
+
[
|
|
120
|
+
HeaderTOI.UC,
|
|
121
|
+
HeaderTOI.TOI,
|
|
122
|
+
HeaderTOI.DATE,
|
|
123
|
+
HeaderTOI.YEAR,
|
|
124
|
+
HeaderTOI.MON,
|
|
125
|
+
HeaderTOI.DAY,
|
|
126
|
+
HeaderTOI.HASH_FILE,
|
|
127
|
+
]
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
self.default_cols_forms = ArrayList[HeaderCartas].from_list(
|
|
131
|
+
[
|
|
132
|
+
HeaderCartas.UC,
|
|
133
|
+
HeaderCartas.TOI,
|
|
134
|
+
HeaderCartas.DATE,
|
|
135
|
+
HeaderCartas.YEAR,
|
|
136
|
+
HeaderCartas.MON,
|
|
137
|
+
HeaderCartas.DAY,
|
|
138
|
+
HeaderCartas.LOCAL_ENTREGA,
|
|
139
|
+
HeaderCartas.TIPO_DOC,
|
|
140
|
+
HeaderCartas.HASH_FILE,
|
|
141
|
+
HeaderCartas.IS_FILE,
|
|
142
|
+
HeaderCartas.FILE_BASENAME,
|
|
143
|
+
HeaderCartas.FILE_EXTENSION,
|
|
144
|
+
HeaderCartas.FULL_PATH,
|
|
145
|
+
HeaderCartas.SRC,
|
|
146
|
+
]
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
def create_table_toi(self) -> TableTOI:
|
|
150
|
+
"""
|
|
151
|
+
Cria uma tabela TOI vazia com todos os itens do cabeçalho HeaderTOI
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
tb = TableTOI()
|
|
155
|
+
self.default_cols_toi.for_each(lambda c: tb.add(ColumnV(c)))
|
|
156
|
+
return tb
|
|
157
|
+
|
|
158
|
+
def create_table_toi_from_df(self, df: pd.DataFrame) -> TableTOI:
|
|
159
|
+
df = df.astype(str)
|
|
160
|
+
df_cols = ArrayList(df.columns.tolist())
|
|
161
|
+
tb = TableTOI()
|
|
162
|
+
|
|
163
|
+
c: HeaderTOI
|
|
164
|
+
for c in self.default_cols_toi:
|
|
165
|
+
if df_cols.contains(c.value):
|
|
166
|
+
tb.add(
|
|
167
|
+
ColumnV.create_from_list(c, df[c.value].astype(str).values.tolist())
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
if tb.header().size() != self.default_cols_toi.size():
|
|
171
|
+
raise HeadersSizeNotIqualError(
|
|
172
|
+
f"DataFrame() de entrega toi com colunas diferente do padrão: \n{tb.header()}"
|
|
173
|
+
)
|
|
174
|
+
return tb
|
|
175
|
+
|
|
176
|
+
def create_table_forms(self) -> TableData[HeaderCartas]:
|
|
177
|
+
"""
|
|
178
|
+
Cria uma tabela com os cabeçalhos de HeaderForms.
|
|
179
|
+
"""
|
|
180
|
+
tb = TableData()
|
|
181
|
+
self.default_cols_forms.for_each(lambda c: tb.add(ColumnV(c)))
|
|
182
|
+
return tb
|
|
183
|
+
|
|
184
|
+
def create_table_forms_from_df(self, df: pd.DataFrame) -> TableData[HeaderCartas]:
|
|
185
|
+
df = df.astype(str)
|
|
186
|
+
df_cols = ArrayList(df.columns.tolist())
|
|
187
|
+
final_table = TableData()
|
|
188
|
+
|
|
189
|
+
c: HeaderCartas
|
|
190
|
+
for c in self.default_cols_forms:
|
|
191
|
+
|
|
192
|
+
if df_cols.contains(c.value):
|
|
193
|
+
final_table.add(
|
|
194
|
+
ColumnV.create_from_list(c, df[c.value].astype(str).values.tolist())
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
if final_table.header().size() != self.default_cols_forms.size():
|
|
198
|
+
msg = "DataFrame() FORMS toi com colunas diferente do padrão:"
|
|
199
|
+
msg_header = f"Cabeçalho FORMS {final_table.header()}"
|
|
200
|
+
raise HeadersSizeNotIqualError(
|
|
201
|
+
f"{msg} \n\n{msg_header}\nCabeçalho externo {df.columns}"
|
|
202
|
+
)
|
|
203
|
+
return final_table
|
|
204
|
+
|
|
205
|
+
def create_table_toi_from_file(self, path: File) -> TableTOI | None:
|
|
206
|
+
if not path.exists():
|
|
207
|
+
return None
|
|
208
|
+
|
|
209
|
+
mp = self.create_map_from_filename(path.name())
|
|
210
|
+
if mp is None:
|
|
211
|
+
return None
|
|
212
|
+
|
|
213
|
+
mp.set_value(HeaderTOI.HASH_FILE, load_file_hash(path))
|
|
214
|
+
tb = TableTOI()
|
|
215
|
+
c: HeaderTOI
|
|
216
|
+
|
|
217
|
+
for c in self.default_cols_toi:
|
|
218
|
+
tb.add(ColumnV.create_from_list(c, [mp.get_value(c)]))
|
|
219
|
+
return tb
|
|
220
|
+
|
|
221
|
+
def create_map_from_filename(
|
|
222
|
+
self, filename: str
|
|
223
|
+
) -> HashMapDict[HeaderTOI, str] | None:
|
|
224
|
+
"""
|
|
225
|
+
Retorna um Map de chave/valor com as seguintes chaves:
|
|
226
|
+
|
|
227
|
+
HeaderDocTOI.UC, HeaderDocTOI.TOI, HeaderDocTOI.DAY,
|
|
228
|
+
HeaderDocTOI.MON, HeaderDocTOI.YEAR e HeaderDocTOI.DATE.
|
|
229
|
+
"""
|
|
230
|
+
|
|
231
|
+
try:
|
|
232
|
+
values = filename.split(" ")
|
|
233
|
+
if len(values) < 5:
|
|
234
|
+
return None
|
|
235
|
+
except:
|
|
236
|
+
return None
|
|
237
|
+
else:
|
|
238
|
+
for x in values:
|
|
239
|
+
if not x.isnumeric():
|
|
240
|
+
return None
|
|
241
|
+
|
|
242
|
+
data = HashMapDict()
|
|
243
|
+
data[HeaderTOI.UC] = values[0] # UC
|
|
244
|
+
data[HeaderTOI.TOI] = values[1] # TOI
|
|
245
|
+
data[HeaderTOI.DAY] = values[2] # DIA
|
|
246
|
+
data[HeaderTOI.MON] = values[3] # MÊS
|
|
247
|
+
data[HeaderTOI.YEAR] = values[4] # ANO
|
|
248
|
+
data[HeaderTOI.DATE] = f"{values[2]}/{values[3]}/{values[4]}"
|
|
249
|
+
return data
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
|
|
4
|
-
from
|
|
4
|
+
from cartas.util import File, Directory, UserFileSystem, BuilderConfigOcr
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
@dataclass
|
|
@@ -10,7 +10,7 @@ class ConfigTOI:
|
|
|
10
10
|
file_relatorio_toi: File
|
|
11
11
|
file_table_toi: File
|
|
12
12
|
dir_base_toi: Directory
|
|
13
|
-
work_dir: Directory
|
|
13
|
+
work_dir: Directory
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class BuilderConfigTOI(object):
|
|
@@ -30,39 +30,38 @@ class BuilderConfigTOI(object):
|
|
|
30
30
|
|
|
31
31
|
super().__init__()
|
|
32
32
|
self._initialized: bool = True
|
|
33
|
-
self.
|
|
34
|
-
UserFileSystem()
|
|
35
|
-
.get_user_documents()
|
|
36
|
-
.concat("RFA", True)
|
|
37
|
-
.concat("Cartas-TOI")
|
|
38
|
-
)
|
|
39
|
-
|
|
33
|
+
self._builder_ocr = BuilderConfigOcr.get_instance()
|
|
40
34
|
self._config = self._create()
|
|
41
35
|
|
|
36
|
+
@property
|
|
37
|
+
def dir_base_work(self) -> Directory:
|
|
38
|
+
return self._builder_ocr.builder().dir_base_work
|
|
39
|
+
|
|
42
40
|
@property
|
|
43
41
|
def dir_retorno_de_campo(self) -> Directory:
|
|
44
|
-
return self.
|
|
42
|
+
return self.dir_base_work.concat("Cartas-TOI", True).concat(
|
|
43
|
+
"Retorno-de-campo", True
|
|
44
|
+
)
|
|
45
45
|
|
|
46
46
|
@property
|
|
47
47
|
def file_relatorio_toi(self) -> File:
|
|
48
|
-
|
|
48
|
+
d = self._builder_ocr.builder().dir_table
|
|
49
|
+
return d.join_file("Relatorio-tois.xlsx")
|
|
49
50
|
|
|
50
51
|
@property
|
|
51
52
|
def file_table_toi(self) -> File:
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
d = self._builder_ocr.builder().dir_table
|
|
54
|
+
return d.join_file("Tabela-tois.xlsx")
|
|
55
|
+
|
|
54
56
|
def _create(self) -> ConfigTOI:
|
|
55
57
|
return ConfigTOI(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def set_work_dir(self, d: Directory) -> BuilderConfigTOI:
|
|
63
|
-
self._work_dir = d
|
|
64
|
-
self._config = self._create()
|
|
65
|
-
return self
|
|
58
|
+
work_dir=self.dir_base_work,
|
|
59
|
+
dir_base_toi=self.dir_retorno_de_campo,
|
|
60
|
+
file_relatorio_toi=self.file_relatorio_toi,
|
|
61
|
+
file_table_toi=self.file_table_toi,
|
|
62
|
+
)
|
|
66
63
|
|
|
67
64
|
def builder(self) -> ConfigTOI:
|
|
65
|
+
if self._config is None:
|
|
66
|
+
self._config = self._create()
|
|
68
67
|
return self._config
|