csc-cia-stne 0.1.34__tar.gz → 0.1.35__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.
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/PKG-INFO +1 -1
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/pyproject.toml +1 -1
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_pdf_extract.py +23 -12
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne.egg-info/PKG-INFO +1 -1
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/LICENCE +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/README.md +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/README_PYPI.md +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/setup.cfg +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/__init__.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/bc_correios.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/bc_sta.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/email.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/ftp.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/gcp_bigquery.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/gcp_bucket.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/gcp_document_ai.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/google_drive.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/jerry.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/karavela.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/logger_json.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/logger_rich.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/provio.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/servicenow.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/slack.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/stne_admin.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/__init__.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/__init__.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_b64.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_converters.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_datetime.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_delete.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_get_secret.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_recriar_pastas.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_settings.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_titulo.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_validate_json.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/ServiceNowValidator.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/__init__.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/ftp.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/waccess.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/web_validator.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/web_screen/__init__.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/wacess.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/web.py +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne.egg-info/SOURCES.txt +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne.egg-info/dependency_links.txt +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne.egg-info/requires.txt +0 -0
- {csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne.egg-info/top_level.txt +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "csc_cia_stne"
|
7
|
-
version = "0.1.
|
7
|
+
version = "0.1.35"
|
8
8
|
license = { text = "MIT" }
|
9
9
|
description = "Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs"
|
10
10
|
keywords = ["karavela", "csc", "cia", "stone", "rpa", "botcity", "stne"]
|
@@ -1,29 +1,39 @@
|
|
1
1
|
from PyPDF2 import PdfReader, PdfWriter
|
2
2
|
from io import BytesIO
|
3
|
-
from typing import Optional
|
3
|
+
from typing import Optional, Dict, Any
|
4
4
|
|
5
|
-
def extrair_x_paginas_pdf(file_path: str, pages_limit: int = 15) ->
|
5
|
+
def extrair_x_paginas_pdf(file_path: str, pages_limit: int = 15) -> Dict[str, Any]:
|
6
6
|
"""
|
7
7
|
Extrai as primeiras X páginas de um arquivo PDF e retorna os bytes dessas páginas.
|
8
8
|
|
9
9
|
Args:
|
10
10
|
file_path (str): Caminho completo do arquivo PDF original.
|
11
11
|
pages_limit (int, optional): Número máximo de páginas a serem extraídas.
|
12
|
-
|
12
|
+
Padrão: 15.
|
13
13
|
|
14
14
|
Returns:
|
15
|
-
|
16
|
-
|
15
|
+
Dict[str, Any]: Dicionário contendo:
|
16
|
+
- success (bool): True se a operação foi bem-sucedida, False caso contrário
|
17
|
+
- error (str|None): Mensagem de erro se houver falha, None se sucesso
|
18
|
+
- data (bytes|None): Bytes do PDF extraído se sucesso, None se erro
|
19
|
+
- total_doc_pages (int): Número total de páginas do documento original (apenas se success=True)
|
20
|
+
- extracted_pages (int): Número de páginas efetivamente extraídas (apenas se success=True)
|
17
21
|
|
18
22
|
Note:
|
19
23
|
- Se o PDF tiver menos páginas que pages_limit, todas serão extraídas
|
20
24
|
- Utiliza PyPDF2 para manipulação do arquivo PDF
|
21
|
-
- Retorna
|
25
|
+
- Retorna success=False em caso de erro no processamento
|
22
26
|
|
23
27
|
Example:
|
24
|
-
>>>
|
25
|
-
>>> if
|
26
|
-
... print(f"PDF extraído com {len(
|
28
|
+
>>> resultado = extrair_x_paginas_pdf("documento.pdf", 10)
|
29
|
+
>>> if resultado["success"]:
|
30
|
+
... print(f"PDF extraído com {len(resultado['data'])} bytes")
|
31
|
+
... print(f"Páginas extraídas: {resultado['extracted_pages']}/{resultado['total_doc_pages']}")
|
32
|
+
... else:
|
33
|
+
... print(f"Erro: {resultado['error']}")
|
34
|
+
|
35
|
+
Raises:
|
36
|
+
Não levanta exceções diretamente - erros são capturados e retornados no dicionário.
|
27
37
|
"""
|
28
38
|
try:
|
29
39
|
# Lê o arquivo PDF original
|
@@ -31,20 +41,21 @@ def extrair_x_paginas_pdf(file_path: str, pages_limit: int = 15) -> Optional[byt
|
|
31
41
|
writer = PdfWriter()
|
32
42
|
|
33
43
|
# Extrai as primeiras 'pages_limit' páginas ou menos, caso o PDF tenha menos de 'pages_limit' páginas
|
34
|
-
|
44
|
+
total_doc_pages = len(reader.pages)
|
45
|
+
for page_num in range(min(pages_limit, total_doc_pages)):
|
35
46
|
writer.add_page(reader.pages[page_num])
|
36
47
|
|
37
48
|
# Salva o novo PDF em um objeto BytesIO
|
38
49
|
pdf_bytes = BytesIO()
|
39
50
|
writer.write(pdf_bytes)
|
40
51
|
pdf_bytes.seek(0) # Move o cursor para o início do buffer
|
41
|
-
resposta = {"success": True, "error": None, "data": pdf_bytes.read()}
|
52
|
+
resposta = {"success": True, "error": None, "data": pdf_bytes.read(), "total_doc_pages": total_doc_pages, "extracted_pages": min(pages_limit, total_doc_pages)}
|
42
53
|
return resposta
|
43
54
|
except Exception as e:
|
44
55
|
resposta = {"success": False, "error": f"Erro ao extrair as primeiras {pages_limit} páginas do PDF: {str(e)}", "data": None}
|
45
56
|
return resposta
|
46
57
|
|
47
|
-
def extrair_paginas_intervalo_pdf(file_path: str, page_start: int = 1, pages_limit: int = 15) ->
|
58
|
+
def extrair_paginas_intervalo_pdf(file_path: str, page_start: int = 1, pages_limit: int = 15) -> Dict[str, Any]:
|
48
59
|
"""
|
49
60
|
Extrai um número específico de páginas de um arquivo PDF a partir de uma página inicial.
|
50
61
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/__init__.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_b64.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_datetime.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_delete.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_settings.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/functions/func_titulo.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/__init__.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/validations/waccess.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.34 → csc_cia_stne-0.1.35}/src/csc_cia_stne/utilitarios/web_screen/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|