csc-cia-stne 0.1.11__py3-none-any.whl → 0.1.13__py3-none-any.whl

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.
@@ -7,7 +7,7 @@ from requests.auth import HTTPBasicAuth
7
7
  from datetime import timedelta, datetime, time
8
8
  from typing import List, Tuple, Union, Optional
9
9
  from pydantic import BaseModel
10
-
10
+ log = logging.getLogger(__name__)
11
11
  class PastasAutorizadas(BaseModel):
12
12
  MensagemErro: Optional[str] = None
13
13
  OcorreuErro: bool
@@ -218,7 +218,7 @@ class BC_Correios:
218
218
  break
219
219
 
220
220
  for correio in correios:
221
-
221
+
222
222
  item_de_lista_de_correios = ItemListaCorreio(
223
223
  Assunto=correio.Assunto,
224
224
  Data=correio.Data,
@@ -248,17 +248,18 @@ class BC_Correios:
248
248
 
249
249
  if len(correios_filtrados) >= proxima_centena:
250
250
 
251
- logging.info(f"Página #{pagina_atual}: {len(correios_filtrados)} correios armazenados no total")
251
+ log.info(f"Página #{pagina_atual}: {len(correios_filtrados)} correios armazenados no total")
252
252
  proxima_centena = proxima_centena + 100
253
253
 
254
254
  # Avança para a próxima página
255
255
  pagina_atual += 1
256
256
 
257
- return True, correios_filtrados
258
-
257
+ #return True, correios_filtrados
258
+ return {"success": True, "data": correios_filtrados, "error": None}
259
+
259
260
  except Exception as e:
260
-
261
- return False, e
261
+
262
+ return {"success": False, "data": None, "error": str(e)}
262
263
 
263
264
  def ler_correio(self, numero:int,data_rebimento:datetime,tipo:str,transicao:int,versao:int,pasta:str)-> Tuple[bool, Union[ItemMsgCorreio, Exception]]:
264
265
  """
@@ -425,7 +426,8 @@ class BC_Correios:
425
426
  #novo end
426
427
 
427
428
  #return True, response
428
- return True, msg_detail
429
+ #return True, msg_detail
430
+ return {"success": True, "data": msg_detail, "error": None}
429
431
 
430
432
  # Serializa o objeto SOAP em um dicionário Python
431
433
  #serialized_response = serialize_object(response)
@@ -437,7 +439,8 @@ class BC_Correios:
437
439
 
438
440
  except Exception as e:
439
441
 
440
- return False, e
442
+ #return False, e
443
+ return {"success": False, "data": None, "error": str(e)}
441
444
 
442
445
  def obter_anexo(self, numero:int, versao:int, transicao:int,pasta:str,anexo_id:int,file_name:str,conteudo:str)-> Tuple[bool,Union[dict, Exception]]:
443
446
  """
@@ -504,17 +507,20 @@ class BC_Correios:
504
507
  conteudo_anexo = response.Anexo.Conteudo
505
508
 
506
509
  # Retorna os dados capturados como um dicionário
507
- return True, {
508
- 'IdAnexo': id_anexo,
509
- 'NomeAnexo': nome_anexo,
510
- 'Conteudo': conteudo_anexo
511
- }
510
+ #return True, {
511
+ # 'IdAnexo': id_anexo,
512
+ # 'NomeAnexo': nome_anexo,
513
+ # 'Conteudo': conteudo_anexo
514
+ #}
515
+ return {"success": True, "error": None, "data": conteudo_anexo}
512
516
  else:
513
- return False, Exception("Correio não possui anexo")
517
+ return {"success": True, "error": "Correio não possui anexo", "data": None}
518
+ #return False, Exception("Correio não possui anexo")
514
519
 
515
520
  except Exception as e:
516
521
 
517
- return False, e
522
+ return {"success": False, "error": str(e), "data": None}
523
+ #return False, e
518
524
 
519
525
  def encerrar(self):
520
526
  """Fecha o cliente e libera a sessão."""
@@ -1,37 +1,31 @@
1
- from pydantic import BaseModel, field_validator, model_validator
1
+ from __future__ import annotations
2
+ from pydantic import BaseModel, field_validator, model_validator, ValidationError
3
+ from typing import Optional, Mapping, Any
4
+
2
5
 
3
6
  class InitParamsValidator(BaseModel):
4
7
  """
5
- Classe InitParamsValidator
6
- Valida os parâmetros de inicialização para garantir que pelo menos um dos
7
- parâmetros 'creds_dict' ou 'creds_file' seja fornecido.
8
- Atributos:
9
- creds_dict (dict): Um dicionário contendo as credenciais.
10
- creds_file (str): Um caminho para o arquivo contendo as credenciais.
11
- Métodos:
12
- check_others_input(cls, model):
13
- Valida se pelo menos um dos parâmetros 'creds_dict' ou 'creds_file'
14
- foi fornecido. Levanta um ValueError caso ambos estejam ausentes ou
15
- inválidos.
8
+ Garante que ao menos um entre `creds_dict` e `creds_file` foi informado.
16
9
  """
17
-
18
- creds_dict:dict
19
- creds_file:str
10
+ creds_dict: Optional[Mapping[str, Any]] = None
11
+ creds_file: Optional[str] = None
20
12
 
21
13
  @model_validator(mode="after")
22
- def check_others_input(cls, model):
23
- creds_dict = model.creds_dict
24
- creds_file = model.creds_file
14
+ def check_others_input(self):
15
+ has_dict = isinstance(self.creds_dict, Mapping) and bool(self.creds_dict)
16
+ has_file = isinstance(self.creds_file, str) and bool(self.creds_file.strip())
17
+
18
+ if not (has_dict or has_file):
19
+ raise ValueError(
20
+ "Pelo menos um dos parâmetros 'creds_dict' (dict não vazio) "
21
+ "ou 'creds_file' (caminho/string não vazia) deve ser fornecido."
22
+ )
23
+ return self
24
+
25
+
25
26
 
26
- if isinstance(creds_dict, dict):
27
- return model
28
27
 
29
- elif isinstance(creds_file, str) and creds_file.strip():
30
- return model
31
28
 
32
- else:
33
- raise ValueError("Pelo menos um dos parâmetros 'creds_dict' ou 'creds_file' deve ser fornecido.")
34
-
35
29
  class ListFilesValidator(BaseModel):
36
30
  """
37
31
  Classe ListFilesValidator
@@ -123,12 +117,20 @@ class UploadFilesValidator(BaseModel):
123
117
  raise ValueError(f"O parametro '{info.field_name}' deve ser uma string e não um {type(value)} e não vazio")
124
118
  return value
125
119
 
120
+ #@field_validator("destination")
121
+ #def check_destination(cls, value, info):
122
+ # if not isinstance(value, str) or value is not None:
123
+ # raise ValueError(f"O parametro '{info.field_name}' deve ser uma string e não um {type(value)}")
124
+ # return value
125
+
126
126
  @field_validator("destination")
127
127
  def check_destination(cls, value, info):
128
- if not isinstance(value, str) or value is not None:
129
- raise ValueError(f"O parametro '{info.field_name}' deve ser uma string e não um {type(value)}")
130
- return value
131
-
128
+ # CORREÇÃO: checar None e vazio (antes estava 'value is not None')
129
+ if value is None or not isinstance(value, str) or not value.strip():
130
+ raise ValueError(
131
+ f"O parametro '{info.field_name}' deve ser uma string não vazia; recebido {type(value)}"
132
+ )
133
+ return value.strip()
132
134
  class DeleteFilesValidator(BaseModel):
133
135
  """
134
136
  Classe DeleteFilesValidator
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csc_cia_stne
3
- Version: 0.1.11
3
+ Version: 0.1.13
4
4
  Summary: Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs
5
5
  License: MIT
6
6
  Keywords: karavela,csc,cia,stone,rpa,botcity,stne
@@ -1,5 +1,5 @@
1
1
  csc_cia_stne/__init__.py,sha256=jwLhGpOwFCow_6cqzwLn31WcIrMzutMZtEQpLL4bQtM,2638
2
- csc_cia_stne/bc_correios.py,sha256=pQAnRrcXEMrx3N1MWydZVIhEQLerh3x8-0B045zZIzk,24174
2
+ csc_cia_stne/bc_correios.py,sha256=s2XjJ0iokMlcUv0mAy9saU3pc_G-6X8wltb_lFHIL6o,24717
3
3
  csc_cia_stne/bc_sta.py,sha256=sE-aU-ZVSAqryQrT1-nor9eAFM5npNAKF1QSm-ChhGU,28945
4
4
  csc_cia_stne/email.py,sha256=y4xyPAe6_Mga5Wf6qAsDzYgn0f-zf2KshfItlWe58z8,8481
5
5
  csc_cia_stne/ftp.py,sha256=M9WCaq2hm56jGyszNaPinliFaZS0BNrT7VrVPMjkMg4,10988
@@ -31,15 +31,15 @@ csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py,sha256=Q1oZTae4hDJ2
31
31
  csc_cia_stne/utilitarios/validations/ServiceNowValidator.py,sha256=yleKUIo1ZfyloP9fDPNjv3JJXdLcocT81WIgRSYmqEA,14423
32
32
  csc_cia_stne/utilitarios/validations/__init__.py,sha256=O_qyEU2ji3u6LHUXZCXvUFsMpoMWL625qqHTXyXivTA,106
33
33
  csc_cia_stne/utilitarios/validations/ftp.py,sha256=LNYyS2c8eou3ML23bBtn87xJFIKSrb8w-2acG0Zugog,4988
34
- csc_cia_stne/utilitarios/validations/gcp_bucket.py,sha256=vqj70jBAkazydUCPXIdE3zzgoz8Te2cCJNX_rICX1aM,6096
34
+ csc_cia_stne/utilitarios/validations/gcp_bucket.py,sha256=E94UCoph9FPo0y2y6UnGOO-zqJFfaHqRAXHWXee7FtM,6229
35
35
  csc_cia_stne/utilitarios/validations/waccess.py,sha256=8yfOrmIPUSLzbCt6P0F6vj3FkSgU_RgrJpJlRhlLyV0,7352
36
36
  csc_cia_stne/utilitarios/validations/web_validator.py,sha256=HYKYSpDv1RvRjZIuwTPt-AbEz-9392MxM_O329iYuSA,5722
37
37
  csc_cia_stne/utilitarios/web_screen/__init__.py,sha256=5QcOPXKd95SvP2DoZiHS0gaU68GlyFD9pQ9kae_9D1Q,100
38
38
  csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py,sha256=PjL8Vgfj_JdKidia7RFyCkro3avYLQu4RZRos41sh3w,3241
39
39
  csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py,sha256=Xi5YJjl2pcxlX3OimqcBWRNXZEpAE7asyUjDJ4Oho5U,12297
40
40
  csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py,sha256=JLIcPJE9ZX3Pd6zG6oTRMqqUAY063UzLY3ReRlxmiSM,15581
41
- csc_cia_stne-0.1.11.dist-info/licenses/LICENCE,sha256=LPGMtgKki2C3KEZP7hDhA1HBrlq5JCHkIeStUCLEMx4,1073
42
- csc_cia_stne-0.1.11.dist-info/METADATA,sha256=QKmQOPFva5ax0o61P-BH8zX7l9JAeAjgWLKOEb4YFg8,1464
43
- csc_cia_stne-0.1.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
44
- csc_cia_stne-0.1.11.dist-info/top_level.txt,sha256=ldo7GVv3tQx5KJvwBzdZzzQmjPys2NDVVn1rv0BOF2Q,13
45
- csc_cia_stne-0.1.11.dist-info/RECORD,,
41
+ csc_cia_stne-0.1.13.dist-info/licenses/LICENCE,sha256=LPGMtgKki2C3KEZP7hDhA1HBrlq5JCHkIeStUCLEMx4,1073
42
+ csc_cia_stne-0.1.13.dist-info/METADATA,sha256=U9YlaEJ11OOOncYpnAmoxkoLezq5ZIeK6EzokvVdbdo,1464
43
+ csc_cia_stne-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
44
+ csc_cia_stne-0.1.13.dist-info/top_level.txt,sha256=ldo7GVv3tQx5KJvwBzdZzzQmjPys2NDVVn1rv0BOF2Q,13
45
+ csc_cia_stne-0.1.13.dist-info/RECORD,,