csc-cia-stne 0.1.19__tar.gz → 0.1.20__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.19 → csc_cia_stne-0.1.20}/PKG-INFO +1 -1
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/pyproject.toml +1 -1
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/bc_sta.py +76 -72
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne.egg-info/PKG-INFO +1 -1
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/LICENCE +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/README.md +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/README_PYPI.md +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/setup.cfg +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/__init__.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/bc_correios.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/email.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/ftp.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/gcp_bigquery.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/gcp_bucket.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/google_drive.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/karavela.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/logger_json.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/logger_rich.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/provio.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/servicenow.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/slack.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/stne_admin.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/__init__.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/__init__.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_b64.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_converters.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_datetime.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_delete.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_get_secret.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_recriar_pastas.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_settings.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_titulo.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_validate_json.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/ServiceNowValidator.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/__init__.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/ftp.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/waccess.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/web_validator.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/web_screen/__init__.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/wacess.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/web.py +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne.egg-info/SOURCES.txt +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne.egg-info/dependency_links.txt +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne.egg-info/requires.txt +0 -0
- {csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/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.20"
|
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"]
|
@@ -6,7 +6,7 @@ import xml.etree.ElementTree as ET
|
|
6
6
|
from xml.dom.minidom import parseString
|
7
7
|
from pydantic import BaseModel, ValidationError, field_validator, Field, HttpUrl
|
8
8
|
from typing import Literal, Dict, Union, Optional, List
|
9
|
-
from datetime import datetime
|
9
|
+
from datetime import datetime, timedelta
|
10
10
|
|
11
11
|
log = logging.getLogger('__main__')
|
12
12
|
|
@@ -499,90 +499,95 @@ class BC_STA:
|
|
499
499
|
#return f"Failed to create protocol. Status code: {response.status_code}, Reason: {response.reason}"
|
500
500
|
return resposta
|
501
501
|
|
502
|
-
def listar_arquivos(self,
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
identificadorDocumento (Optional[str], optional): Identificador documento. Default=None (Todos).
|
511
|
-
qtd (int, optional): Quantidade de arquivos na resposta. Default=100 (máximo=100).
|
512
|
-
tipo_arquivo (list, optional): Tipo de arquivo para fazer download. Default=None (Todos). Opções: ['ACCS002', 'ACCS003', 'AJUD301', 'AJUD302', 'AJUD303', 'AJUD304', 'AJUD305', 'AJUD308', 'AJUD309', 'AJUD310', 'AJUD331', 'AMES102', 'AMTF102', 'ASVR9810', 'ATXB001'].
|
513
|
-
|
514
|
-
Returns:
|
515
|
-
list: Lista de arquivos do STA
|
516
|
-
"""
|
502
|
+
def listar_arquivos(self,
|
503
|
+
nivel: Literal['RES', 'BAS', 'COMPL'],
|
504
|
+
inicio: str,
|
505
|
+
fim: str = None,
|
506
|
+
situacao: Optional[Literal['REC', 'A_REC']] = None,
|
507
|
+
identificadorDocumento: Optional[str] = None,
|
508
|
+
qtd: int = 100,
|
509
|
+
tipo_arquivo: list = None):
|
517
510
|
resultados = []
|
518
|
-
|
511
|
+
|
512
|
+
# Parse seguro para datetime (assume formato ISO 'AAAA-MM-DDTHH:MM:SS')
|
513
|
+
dt_inicio = datetime.fromisoformat(inicio)
|
514
|
+
dt_fim = datetime.fromisoformat(fim) if fim else None
|
515
|
+
ultima_dt = dt_inicio
|
519
516
|
|
520
517
|
while True:
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
url
|
518
|
+
# Se já passamos do fim, encerra antes de chamar a API
|
519
|
+
if dt_fim and ultima_dt >= dt_fim:
|
520
|
+
break
|
521
|
+
|
522
|
+
# Monta a URL usando a data atual do cursor
|
523
|
+
_inicio_str = ultima_dt.strftime("%Y-%m-%dT%H:%M:%S")
|
524
|
+
url = f"{self.base_url}/arquivos?tipoConsulta=AVANC&nivelDetalhe={nivel}"
|
525
|
+
url += f"&dataHoraInicio={_inicio_str}"
|
526
|
+
if situacao:
|
527
|
+
url += f"&situacaoTransmissao={situacao}"
|
528
|
+
if identificadorDocumento:
|
529
|
+
url += f"&identificadorDocumento={identificadorDocumento}"
|
530
|
+
if dt_fim:
|
531
|
+
_fim_str = dt_fim.strftime("%Y-%m-%dT%H:%M:%S")
|
532
|
+
url += f"&dataHoraFim={_fim_str}"
|
533
|
+
url += f"&qtdMaxResultados={qtd}"
|
528
534
|
|
529
535
|
response = requests.get(
|
530
|
-
url,
|
531
|
-
headers=self.headers,
|
532
|
-
auth=self.auth,
|
533
|
-
timeout=60,
|
536
|
+
url, headers=self.headers, auth=self.auth, timeout=60,
|
534
537
|
)
|
535
538
|
|
536
|
-
if response.status_code
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
dados = xml_response_to_json(response.text)
|
541
|
-
|
542
|
-
if not dados: # Verifica se a lista está vazia
|
543
|
-
|
544
|
-
break # Sai do loop se não houver mais dados
|
545
|
-
|
546
|
-
# Filtra apenas os arquivos do tipo 'AJUD308'
|
547
|
-
if tipo_arquivo is not None:
|
548
|
-
|
549
|
-
if isinstance(dados, list):
|
550
|
-
dados_filtrados = [arquivo for arquivo in dados if arquivo.get("TipoArquivo") in tipo_arquivo]
|
551
|
-
elif dados.get("TipoArquivo") in tipo_arquivo:
|
552
|
-
dados_filtrados = [dados]
|
553
|
-
|
554
|
-
resultados.extend(dados_filtrados)
|
555
|
-
|
556
|
-
else:
|
557
|
-
|
558
|
-
resultados.extend(dados)
|
539
|
+
if response.status_code != 200:
|
540
|
+
log.error(f"Erro ao listar arquivos: response code {response.status_code}\n{response.text}")
|
541
|
+
return False
|
559
542
|
|
560
|
-
|
561
|
-
|
543
|
+
try:
|
544
|
+
dados = xml_response_to_json(response.text)
|
545
|
+
if not dados:
|
546
|
+
break # sem mais resultados
|
547
|
+
|
548
|
+
# Normaliza dados para lista
|
549
|
+
itens = dados if isinstance(dados, list) else [dados]
|
550
|
+
|
551
|
+
# (opcional) filtra por tipo_arquivo
|
552
|
+
if tipo_arquivo is not None:
|
553
|
+
itens = [a for a in itens if a.get("TipoArquivo") in tipo_arquivo]
|
554
|
+
|
555
|
+
resultados.extend(itens)
|
556
|
+
|
557
|
+
# Atualiza o cursor a partir do último item retornado
|
558
|
+
# Busca o último com DataHoraDisponibilizacao
|
559
|
+
ultimo = None
|
560
|
+
for cand in reversed(itens):
|
561
|
+
if "DataHoraDisponibilizacao" in cand and cand["DataHoraDisponibilizacao"]:
|
562
|
+
ultimo = cand["DataHoraDisponibilizacao"]
|
563
|
+
break
|
564
|
+
|
565
|
+
if not ultimo:
|
566
|
+
# fallback: se o JSON bruto vier como dict/list diferente, tente no original
|
567
|
+
if isinstance(dados, list) and dados and "DataHoraDisponibilizacao" in dados[-1]:
|
568
|
+
ultimo = dados[-1]["DataHoraDisponibilizacao"]
|
569
|
+
elif isinstance(dados, dict) and "DataHoraDisponibilizacao" in dados:
|
570
|
+
ultimo = dados["DataHoraDisponibilizacao"]
|
571
|
+
|
572
|
+
if not ultimo:
|
573
|
+
log.error("Campo 'DataHoraDisponibilizacao' não encontrado ou estrutura inesperada.")
|
574
|
+
return False
|
562
575
|
|
563
|
-
|
576
|
+
# Cursor: último + 1s para evitar repetir o mesmo registro
|
577
|
+
proxima_dt = datetime.fromisoformat(ultimo) + timedelta(seconds=1)
|
564
578
|
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
else:
|
570
|
-
|
571
|
-
log.error("Campo 'DataHoraDisponibilizacao' não encontrado ou estrutura inesperada.")
|
572
|
-
return False
|
579
|
+
# Se a próxima dt já ultrapassa o fim, encerramos sem nova chamada
|
580
|
+
if dt_fim and proxima_dt > dt_fim:
|
581
|
+
break
|
573
582
|
|
574
|
-
|
583
|
+
ultima_dt = proxima_dt
|
575
584
|
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
else:
|
580
|
-
|
581
|
-
log.error(f"Erro ao listar arquivos: response code {response.status_code}\n{response.text}")
|
585
|
+
except ET.ParseError as e:
|
586
|
+
log.error(f"Erro ao processar XML: {e}")
|
582
587
|
return False
|
583
|
-
|
588
|
+
|
584
589
|
return resultados
|
585
|
-
|
590
|
+
|
586
591
|
def download_arquivo(self,protocolo:str,filename:str=None):
|
587
592
|
"""Faz o download de um arquivo de um protocolo especifico
|
588
593
|
|
@@ -631,7 +636,6 @@ class BC_STA:
|
|
631
636
|
|
632
637
|
return {"success": False, "status_code": int(response.status_code), "content": response.text}
|
633
638
|
|
634
|
-
|
635
639
|
def qs_gerar_xml_string_responder_nao_cliente(self,protocolo_inicial_ordem:str,numctrlccs:str,cnpj_cpf:str,numctrlenvio:str,numprocjud:str,identdemissor:str,identddestinatario:str,domsist:str,nuop:str,dtmovto:datetime,cnpjbaseentrespons:str):
|
636
640
|
|
637
641
|
"""Gera a string do arquivo XML de resposta para nao-cliente para ser enviado ao STA
|
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.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/__init__.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_b64.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_datetime.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_delete.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/functions/func_settings.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/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.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/__init__.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/src/csc_cia_stne/utilitarios/validations/waccess.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.19 → csc_cia_stne-0.1.20}/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
|