csc-cia-stne 0.0.17__tar.gz → 0.0.18__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.0.17 → csc_cia_stne-0.0.18}/PKG-INFO +1 -1
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/pyproject.toml +1 -1
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/__init__.py +2 -1
- csc_cia_stne-0.0.18/src/csc_cia_stne/functions.py +126 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/settings.py +3 -3
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne.egg-info/PKG-INFO +1 -1
- csc_cia_stne-0.0.17/src/csc_cia_stne/functions.py +0 -88
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/LICENCE +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/README.md +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/README_PYPI.md +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/setup.cfg +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/bc_correios.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/bc_sta.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/gcp_bigquery.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/karavela.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/logger_json.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/logger_rich.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/servicenow.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/stne_admin.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne/utilitarios.py +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne.egg-info/SOURCES.txt +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne.egg-info/dependency_links.txt +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/src/csc_cia_stne.egg-info/requires.txt +0 -0
- {csc_cia_stne-0.0.17 → csc_cia_stne-0.0.18}/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.0.
|
7
|
+
version = "0.0.18"
|
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"]
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import os
|
2
|
+
import base64
|
3
|
+
import mimetypes
|
4
|
+
from datetime import datetime
|
5
|
+
from rich import print
|
6
|
+
from rich.panel import Panel
|
7
|
+
from rich.style import Style
|
8
|
+
import json
|
9
|
+
import shutil
|
10
|
+
import logging
|
11
|
+
from pydantic import BaseModel
|
12
|
+
from pydantic import ValidationError, field_validator
|
13
|
+
|
14
|
+
# Classe para validar - titulo
|
15
|
+
class TituloSettings(BaseModel):
|
16
|
+
|
17
|
+
# Titulo
|
18
|
+
project_name: str
|
19
|
+
project_version: str
|
20
|
+
project_dev_name: str
|
21
|
+
project_dev_mail: str
|
22
|
+
# Validador para garantir que nenhum campo seja uma string vazia
|
23
|
+
|
24
|
+
@field_validator('project_name', 'project_version', 'project_dev_name', 'project_dev_mail')
|
25
|
+
def check_non_empty_string(cls, value, info):
|
26
|
+
if not isinstance(value, str) or not value.strip():
|
27
|
+
|
28
|
+
raise ValueError(f"O parâmetro '{info.field_name}' deve ser uma string não vazia.")
|
29
|
+
|
30
|
+
return value
|
31
|
+
|
32
|
+
|
33
|
+
# Retorna data de modificação
|
34
|
+
def last_modified()->datetime:
|
35
|
+
"""
|
36
|
+
Retorna a data da última atualização do script
|
37
|
+
|
38
|
+
"""
|
39
|
+
current_file = os.path.abspath(__file__)
|
40
|
+
current_folder = os.path.dirname(current_file)
|
41
|
+
base_dir = os.path.dirname(os.path.dirname(current_file))
|
42
|
+
|
43
|
+
newest_date = None
|
44
|
+
|
45
|
+
for root, _, files in os.walk(base_dir):
|
46
|
+
|
47
|
+
for file in files:
|
48
|
+
|
49
|
+
if file.endswith('.py'):
|
50
|
+
|
51
|
+
file_path = os.path.join(root, file)
|
52
|
+
file_modification_date = os.path.getmtime(file_path)
|
53
|
+
|
54
|
+
if newest_date is None or file_modification_date > newest_date:
|
55
|
+
|
56
|
+
newest_date = file_modification_date
|
57
|
+
|
58
|
+
# Converter o timestamp para um objeto datetime
|
59
|
+
last_modified_date = datetime.fromtimestamp(newest_date)
|
60
|
+
last_modified_date = last_modified_date.strftime("%Y%m%d")
|
61
|
+
|
62
|
+
return last_modified_date
|
63
|
+
|
64
|
+
def titulo(project_name:str,project_version:str,project_dev_name:str,project_dev_mail:str):
|
65
|
+
|
66
|
+
try:
|
67
|
+
settings = TituloSettings(project_name=project_name,project_version=project_version,project_dev_name=project_dev_name,project_dev_mail=project_dev_mail)
|
68
|
+
return settings
|
69
|
+
|
70
|
+
except ValidationError as e:
|
71
|
+
# Extrair os detalhes da exceção
|
72
|
+
errors = e.errors()
|
73
|
+
missing_vars = [error['loc'][0] for error in errors if error['type'] == 'missing']
|
74
|
+
|
75
|
+
# Criar uma mensagem personalizada
|
76
|
+
if missing_vars:
|
77
|
+
missing_vars_str = ', '.join(missing_vars)
|
78
|
+
raise ValueError(
|
79
|
+
f"As seguintes variáveis obrigatórias estão ausentes no arquivo .env ou nas variáveis de ambiente da máquina, impossibi: {missing_vars_str}"
|
80
|
+
)
|
81
|
+
else:
|
82
|
+
|
83
|
+
if os.getenv('ambiente_de_execucao') is None or os.getenv('ambiente_de_execucao') != "karavela":
|
84
|
+
|
85
|
+
estilo_box = Style(bold=True)
|
86
|
+
print(
|
87
|
+
Panel(
|
88
|
+
f"""
|
89
|
+
[bold chartreuse3]CIA [bold white]| [bold chartreuse3]Centro de Inteligência e Automação [bold white]([bold chartreuse3]cia@stone.com.br[bold white])[bold green]\n
|
90
|
+
Projeto[bold white]: [bold green]{os.getenv('project_name')}\n
|
91
|
+
Versão[bold white]: [bold green]{os.getenv('project_version')}\n
|
92
|
+
Dev[bold white]: [bold green]{os.getenv('project_dev_name')} [bold white]([bold green]{os.getenv('project_dev_mail')}[bold white])[bold green]\n
|
93
|
+
Última atualização[bold white]: [bold green]{last_modified()}
|
94
|
+
""",
|
95
|
+
title="Stone",
|
96
|
+
subtitle="CSC-CIA",
|
97
|
+
style=estilo_box,
|
98
|
+
border_style="bold chartreuse3"
|
99
|
+
)
|
100
|
+
)
|
101
|
+
|
102
|
+
else:
|
103
|
+
|
104
|
+
logging.info("CSC | CIA - Centro de Inteligência e Automação")
|
105
|
+
logging.info(f"Projeto: {os.getenv('project_name')}")
|
106
|
+
logging.info(f"\tVersão: {os.getenv('project_version')} (Última modificação: {last_modified()})")
|
107
|
+
logging.info("\tTime: CIA <cia@stone.com.br>")
|
108
|
+
logging.info(f"\tDesenvolvedor: {os.getenv('project_dev_name')} <{os.getenv('project_dev_mail')}>")
|
109
|
+
logging.info("-")
|
110
|
+
|
111
|
+
def recriar_pasta(caminho_pasta):
|
112
|
+
|
113
|
+
try:
|
114
|
+
|
115
|
+
# Se a pasta já existir, remove-a
|
116
|
+
if os.path.exists(caminho_pasta) and os.path.isdir(caminho_pasta):
|
117
|
+
shutil.rmtree(caminho_pasta) # Deleta a pasta e todo o conteúdo
|
118
|
+
|
119
|
+
# Cria a pasta novamente
|
120
|
+
os.makedirs(caminho_pasta)
|
121
|
+
return True, None
|
122
|
+
|
123
|
+
except Exception as e:
|
124
|
+
|
125
|
+
return False, e
|
126
|
+
|
@@ -43,7 +43,7 @@ def load_settings():
|
|
43
43
|
f"As seguintes variáveis obrigatórias estão ausentes no arquivo .env ou nas variáveis de ambiente da máquina: {missing_vars_str}\n"
|
44
44
|
"Outras variáveis, não obrigatórias: 'ambiente_de_execução' ('local' ou 'karavela') e 'log_level' ('DEBUG', 'INFO', etc)"
|
45
45
|
)
|
46
|
-
|
47
|
-
titulo()
|
48
|
-
|
46
|
+
else:
|
47
|
+
titulo()
|
48
|
+
|
49
49
|
settings = load_settings()
|
@@ -1,88 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import base64
|
3
|
-
import mimetypes
|
4
|
-
from datetime import datetime
|
5
|
-
from rich import print
|
6
|
-
from rich.panel import Panel
|
7
|
-
from rich.style import Style
|
8
|
-
import json
|
9
|
-
import shutil
|
10
|
-
import logging
|
11
|
-
|
12
|
-
# Retorna data de modificação
|
13
|
-
def last_modified()->datetime:
|
14
|
-
"""
|
15
|
-
Retorna a data da última atualização do script
|
16
|
-
|
17
|
-
"""
|
18
|
-
current_file = os.path.abspath(__file__)
|
19
|
-
current_folder = os.path.dirname(current_file)
|
20
|
-
base_dir = os.path.dirname(os.path.dirname(current_file))
|
21
|
-
|
22
|
-
newest_date = None
|
23
|
-
|
24
|
-
for root, _, files in os.walk(base_dir):
|
25
|
-
|
26
|
-
for file in files:
|
27
|
-
|
28
|
-
if file.endswith('.py'):
|
29
|
-
|
30
|
-
file_path = os.path.join(root, file)
|
31
|
-
file_modification_date = os.path.getmtime(file_path)
|
32
|
-
|
33
|
-
if newest_date is None or file_modification_date > newest_date:
|
34
|
-
|
35
|
-
newest_date = file_modification_date
|
36
|
-
|
37
|
-
# Converter o timestamp para um objeto datetime
|
38
|
-
last_modified_date = datetime.fromtimestamp(newest_date)
|
39
|
-
last_modified_date = last_modified_date.strftime("%Y%m%d")
|
40
|
-
|
41
|
-
return last_modified_date
|
42
|
-
|
43
|
-
def titulo():
|
44
|
-
|
45
|
-
if os.getenv('ambiente_de_execucao') is None or os.getenv('ambiente_de_execucao') != "karavela":
|
46
|
-
|
47
|
-
estilo_box = Style(bold=True)
|
48
|
-
print(
|
49
|
-
Panel(
|
50
|
-
f"""
|
51
|
-
[bold chartreuse3]CIA [bold white]| [bold chartreuse3]Centro de Inteligência e Automação [bold white]([bold chartreuse3]cia@stone.com.br[bold white])[bold green]\n
|
52
|
-
Projeto[bold white]: [bold green]{os.getenv('project_name')}\n
|
53
|
-
Versão[bold white]: [bold green]{os.getenv('project_version')}\n
|
54
|
-
Dev[bold white]: [bold green]{os.getenv('project_dev_name')} [bold white]([bold green]{os.getenv('project_dev_mail')}[bold white])[bold green]\n
|
55
|
-
Última atualização[bold white]: [bold green]{last_modified()}
|
56
|
-
""",
|
57
|
-
title="Stone",
|
58
|
-
subtitle="CSC-CIA",
|
59
|
-
style=estilo_box,
|
60
|
-
border_style="bold chartreuse3"
|
61
|
-
)
|
62
|
-
)
|
63
|
-
|
64
|
-
else:
|
65
|
-
|
66
|
-
logging.info("CSC | CIA - Centro de Inteligência e Automação")
|
67
|
-
logging.info(f"Projeto: {os.getenv('project_name')}")
|
68
|
-
logging.info(f"\tVersão: {os.getenv('project_version')} (Última modificação: {last_modified()})")
|
69
|
-
logging.info("\tTime: CIA <cia@stone.com.br>")
|
70
|
-
logging.info(f"\tDesenvolvedor: {os.getenv('project_dev_name')} <{os.getenv('project_dev_mail')}>")
|
71
|
-
logging.info("-")
|
72
|
-
|
73
|
-
def recriar_pasta(caminho_pasta):
|
74
|
-
|
75
|
-
try:
|
76
|
-
|
77
|
-
# Se a pasta já existir, remove-a
|
78
|
-
if os.path.exists(caminho_pasta) and os.path.isdir(caminho_pasta):
|
79
|
-
shutil.rmtree(caminho_pasta) # Deleta a pasta e todo o conteúdo
|
80
|
-
|
81
|
-
# Cria a pasta novamente
|
82
|
-
os.makedirs(caminho_pasta)
|
83
|
-
return True, None
|
84
|
-
|
85
|
-
except Exception as e:
|
86
|
-
|
87
|
-
return False, e
|
88
|
-
|
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
|