csc-cia-stne 0.1.14__tar.gz → 0.1.16__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.14 → csc_cia_stne-0.1.16}/PKG-INFO +1 -1
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/pyproject.toml +1 -1
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/gcp_bucket.py +18 -9
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py +22 -6
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne.egg-info/PKG-INFO +1 -1
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/LICENCE +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/README.md +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/README_PYPI.md +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/setup.cfg +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/__init__.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/bc_correios.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/bc_sta.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/email.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/ftp.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/gcp_bigquery.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/google_drive.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/karavela.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/logger_json.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/logger_rich.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/provio.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/servicenow.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/slack.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/stne_admin.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/__init__.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/__init__.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_b64.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_converters.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_datetime.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_delete.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_get_secret.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_recriar_pastas.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_settings.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_titulo.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_validate_json.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/ServiceNowValidator.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/__init__.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/ftp.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/waccess.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/web_validator.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/web_screen/__init__.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/wacess.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/web.py +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne.egg-info/SOURCES.txt +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne.egg-info/dependency_links.txt +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne.egg-info/requires.txt +0 -0
- {csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/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.16"
|
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,7 +1,7 @@
|
|
1
|
+
import base64
|
1
2
|
from google.oauth2 import service_account
|
2
3
|
from google.cloud import storage
|
3
4
|
from pydantic import ValidationError
|
4
|
-
|
5
5
|
from .utilitarios.validations.gcp_bucket import InitParamsValidator,ListFilesValidator,GetFilesValidator,UploadFilesValidator,DeleteFilesValidator
|
6
6
|
|
7
7
|
|
@@ -112,7 +112,7 @@ class GCPBucket():
|
|
112
112
|
}
|
113
113
|
|
114
114
|
# Função para baixar os arquivos de um bucket
|
115
|
-
def get_file(self, bucket_name:str, filename:str, destination:str=None, chunksize:int=256) -> dict:
|
115
|
+
def get_file(self, bucket_name:str, filename:str, destination:str=None, chunksize:int=256, download_as:str='file') -> dict:
|
116
116
|
"""
|
117
117
|
Faz o download de um arquivo de um bucket do Google Cloud Storage para um destino local.
|
118
118
|
Args:
|
@@ -122,6 +122,7 @@ class GCPBucket():
|
|
122
122
|
Se não for especificado, o arquivo será salvo com o mesmo nome do arquivo no bucket.
|
123
123
|
chunksize (int, opcional): Tamanho do chunk em megabytes para o download do arquivo.
|
124
124
|
O padrão é 256 MB.
|
125
|
+
download_as (str, opcional): Define o formato do download.
|
125
126
|
Returns:
|
126
127
|
dict: Um dicionário contendo o status da operação.
|
127
128
|
- 'success' (bool): Indica se a operação foi bem-sucedida.
|
@@ -133,7 +134,7 @@ class GCPBucket():
|
|
133
134
|
|
134
135
|
try:
|
135
136
|
|
136
|
-
GetFilesValidator(bucket_name=bucket_name, filename=filename, destination=destination, chunksize=chunksize)
|
137
|
+
GetFilesValidator(bucket_name=bucket_name, filename=filename, destination=destination, chunksize=chunksize, download_as=download_as)
|
137
138
|
|
138
139
|
except ValidationError as e:
|
139
140
|
|
@@ -144,7 +145,7 @@ class GCPBucket():
|
|
144
145
|
destination = filename
|
145
146
|
|
146
147
|
try:
|
147
|
-
|
148
|
+
|
148
149
|
bucket = self.client.bucket(bucket_name)
|
149
150
|
|
150
151
|
except Exception as e:
|
@@ -161,12 +162,20 @@ class GCPBucket():
|
|
161
162
|
|
162
163
|
blob.chunk_size = chunksize * 1024 * 1024 # 256M
|
163
164
|
|
164
|
-
|
165
|
+
if download_as == 'file':
|
166
|
+
blob.download_to_filename(destination)
|
167
|
+
return {
|
168
|
+
'success':True,
|
169
|
+
'details':f'Arquivo baixado para o diretório: {str(destination)}'
|
170
|
+
}
|
165
171
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
172
|
+
elif download_as == 'bytes':
|
173
|
+
b64_str = base64.b64encode(blob.download_as_bytes()).decode()
|
174
|
+
return {
|
175
|
+
'success':True,
|
176
|
+
'details':f'Arquivo baixado como bytes em base64',
|
177
|
+
'data': b64_str
|
178
|
+
}
|
170
179
|
|
171
180
|
except Exception as e:
|
172
181
|
|
{csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py
RENAMED
@@ -1,7 +1,9 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
-
from pydantic import BaseModel, field_validator, model_validator, ValidationError
|
3
|
-
from typing import Optional, Mapping, Any
|
2
|
+
from pydantic import BaseModel, field_validator, model_validator, ValidationError, Field, ConfigDict
|
3
|
+
from typing import Optional, Mapping, Any, Annotated
|
4
4
|
|
5
|
+
NonEmptyStr = Annotated[str, Field(min_length=1)]
|
6
|
+
PositiveInt = Annotated[int, Field(gt=0)]
|
5
7
|
|
6
8
|
class InitParamsValidator(BaseModel):
|
7
9
|
"""
|
@@ -22,10 +24,6 @@ class InitParamsValidator(BaseModel):
|
|
22
24
|
)
|
23
25
|
return self
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
27
|
class ListFilesValidator(BaseModel):
|
30
28
|
"""
|
31
29
|
Classe ListFilesValidator
|
@@ -47,6 +45,23 @@ class ListFilesValidator(BaseModel):
|
|
47
45
|
return value
|
48
46
|
|
49
47
|
class GetFilesValidator(BaseModel):
|
48
|
+
|
49
|
+
model_config = ConfigDict(strict=True) # não faz coerção: "1024" não vira 1024
|
50
|
+
|
51
|
+
bucket_name: NonEmptyStr
|
52
|
+
filename: NonEmptyStr
|
53
|
+
destination: NonEmptyStr
|
54
|
+
chunksize: PositiveInt
|
55
|
+
download_as: NonEmptyStr = 'file' # 'file' ou 'bytes'
|
56
|
+
|
57
|
+
# Opcional: se você quiser mensagens personalizadas além das do Field
|
58
|
+
@field_validator("bucket_name", "filename", "destination", "download_as")
|
59
|
+
def _not_blank(cls, v, info):
|
60
|
+
if not v.strip():
|
61
|
+
raise ValueError(f"O parametro '{info.field_name}' não pode ser vazio/whitespace.")
|
62
|
+
return v
|
63
|
+
|
64
|
+
class _GetFilesValidator(BaseModel):
|
50
65
|
"""
|
51
66
|
Classe GetFilesValidator
|
52
67
|
Valida os parâmetros necessários para operações relacionadas a arquivos em um bucket GCP.
|
@@ -131,6 +146,7 @@ class UploadFilesValidator(BaseModel):
|
|
131
146
|
f"O parametro '{info.field_name}' deve ser uma string não vazia; recebido {type(value)}"
|
132
147
|
)
|
133
148
|
return value.strip()
|
149
|
+
|
134
150
|
class DeleteFilesValidator(BaseModel):
|
135
151
|
"""
|
136
152
|
Classe DeleteFilesValidator
|
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.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/__init__.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_b64.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_datetime.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_delete.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/functions/func_settings.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/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.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/__init__.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/src/csc_cia_stne/utilitarios/validations/waccess.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.14 → csc_cia_stne-0.1.16}/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
|