rpa-suite 0.9.4__tar.gz → 1.0.1__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.
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/PKG-INFO +5 -4
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/README.md +3 -2
- rpa_suite-1.0.1/rpa_suite/log/__create_log_dir.py +81 -0
- rpa_suite-1.0.1/rpa_suite/log/_variables.py +8 -0
- rpa_suite-1.0.1/rpa_suite/log/_variables_uru.py +9 -0
- rpa_suite-1.0.1/rpa_suite/log/functions_logger.py +94 -0
- rpa_suite-1.0.1/rpa_suite/log/functions_logger_uru.py +170 -0
- rpa_suite-0.9.4/rpa_suite/log/loggin.py → rpa_suite-1.0.1/rpa_suite/log/log_decorator.py +5 -5
- rpa_suite-1.0.1/rpa_suite/log/logger.py +111 -0
- rpa_suite-1.0.1/rpa_suite/log/logger_uru.py +110 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/suite.py +24 -3
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite.egg-info/PKG-INFO +5 -4
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite.egg-info/SOURCES.txt +8 -1
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite.egg-info/requires.txt +1 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/setup.py +2 -3
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/LICENSE +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/__init__.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/clock/__init__.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/clock/exec_at.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/clock/scheduler.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/clock/waiter.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/date/__init__.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/date/date.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/email/__init__.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/email/sender_smtp.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/file/__init__.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/file/counter.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/file/temp_dir.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/log/__init__.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/log/printer.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/regex/__init__.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/regex/list_from_text.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/validate/__init__.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/validate/mail_validator.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite/validate/string_validator.py +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite.egg-info/dependency_links.txt +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/rpa_suite.egg-info/top_level.txt +0 -0
- {rpa_suite-0.9.4 → rpa_suite-1.0.1}/setup.cfg +0 -0
@@ -1,13 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: rpa_suite
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.1
|
4
4
|
Summary: Conjunto de ferramentas essenciais para Automação RPA com Python, que facilitam o dia a dia de desenvolvimento.
|
5
5
|
Author: Camilo Costa de Carvalho
|
6
6
|
Author-email: camilo.carvalho@triasoftware.com.br
|
7
7
|
License: MIT
|
8
8
|
Keywords: basic-tools,email-tools,email-validation,file-tools,simple-functions,rpa-tools,rpa-functions,Tools,Rpa,Automation,RPA,Automação,Python,Ferramentas de RPA,Automação de Processos,Biblioteca Python para RPA
|
9
9
|
Classifier: Development Status :: 3 - Alpha
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
11
10
|
Classifier: Programming Language :: Python :: 3.11
|
12
11
|
Classifier: Programming Language :: Python :: 3.12
|
13
12
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -22,6 +21,7 @@ License-File: LICENSE
|
|
22
21
|
Requires-Dist: loguru
|
23
22
|
Requires-Dist: colorama
|
24
23
|
Requires-Dist: email_validator
|
24
|
+
Requires-Dist: colorlog
|
25
25
|
|
26
26
|

|
27
27
|
|
@@ -126,6 +126,7 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
|
|
126
126
|
- colorama
|
127
127
|
- loguru
|
128
128
|
- email-validator
|
129
|
+
- colorlog
|
129
130
|
|
130
131
|
## Estrutura do módulo
|
131
132
|
O módulo principal do rpa-suite é dividido em categorias. Cada categoria contém módulos com funções destinadas a cada tipo de tarefa
|
@@ -141,7 +142,7 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
141
142
|
- **counter** - Funções para contagem de arquivos
|
142
143
|
- **temp_dir** - Funções para diretórios temporários
|
143
144
|
- **log**
|
144
|
-
- **
|
145
|
+
- **logger** - Objeto de log, cria diretório/arquivo de log integrado aos prints
|
145
146
|
- **printer** - Funções print personalizados (alerta, erro, sucesso, informativo)
|
146
147
|
- **regex**
|
147
148
|
- **list_from_text** - Funções para gerar listas, dividindo texto usando padrão regex
|
@@ -150,7 +151,7 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
150
151
|
- **string_validator** - Funções para validação/varredura (strings, substrings, palavras)
|
151
152
|
|
152
153
|
## Release
|
153
|
-
Versão: **
|
154
|
+
Versão: **Beta 1.0.1**
|
154
155
|
|
155
156
|
Lançamento: *20/02/2024*
|
156
157
|
|
@@ -101,6 +101,7 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
|
|
101
101
|
- colorama
|
102
102
|
- loguru
|
103
103
|
- email-validator
|
104
|
+
- colorlog
|
104
105
|
|
105
106
|
## Estrutura do módulo
|
106
107
|
O módulo principal do rpa-suite é dividido em categorias. Cada categoria contém módulos com funções destinadas a cada tipo de tarefa
|
@@ -116,7 +117,7 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
116
117
|
- **counter** - Funções para contagem de arquivos
|
117
118
|
- **temp_dir** - Funções para diretórios temporários
|
118
119
|
- **log**
|
119
|
-
- **
|
120
|
+
- **logger** - Objeto de log, cria diretório/arquivo de log integrado aos prints
|
120
121
|
- **printer** - Funções print personalizados (alerta, erro, sucesso, informativo)
|
121
122
|
- **regex**
|
122
123
|
- **list_from_text** - Funções para gerar listas, dividindo texto usando padrão regex
|
@@ -125,7 +126,7 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
125
126
|
- **string_validator** - Funções para validação/varredura (strings, substrings, palavras)
|
126
127
|
|
127
128
|
## Release
|
128
|
-
Versão: **
|
129
|
+
Versão: **Beta 1.0.1**
|
129
130
|
|
130
131
|
Lançamento: *20/02/2024*
|
131
132
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import os
|
2
|
+
from typing import Union
|
3
|
+
from rpa_suite.log.printer import error_print, alert_print, success_print
|
4
|
+
|
5
|
+
|
6
|
+
def _create_log_dir(path_to_create: str = 'default', name_log_dir: str='logs') -> dict[str, Union[bool, str, None]]:
|
7
|
+
|
8
|
+
"""
|
9
|
+
Function responsible for creating a logger directory to work with files ``.log``. \n
|
10
|
+
|
11
|
+
Parameters:
|
12
|
+
----------
|
13
|
+
``path_to_create: str`` - should be a string with the full path pointing to the folder where the logger folder should be created, if it is empty the ``default`` value will be used which will create a folder in the current directory where the file containing this function was called.
|
14
|
+
|
15
|
+
``name_log_dir: str`` - should be a string representing the name of the logger directory to be created. If it is empty, the ``temp`` value will be used as the default directory name.
|
16
|
+
|
17
|
+
Return:
|
18
|
+
----------
|
19
|
+
>>> type:dict
|
20
|
+
* 'success': bool - represents case the action was performed successfully
|
21
|
+
* 'path_created': str - path of the directory that was created on the process
|
22
|
+
|
23
|
+
Description: pt-br
|
24
|
+
----------
|
25
|
+
Função responsavel por criar diretório de logger para trabalhar com arquivos de log. \n
|
26
|
+
|
27
|
+
Parametros:
|
28
|
+
----------
|
29
|
+
``path_to_create: str`` - deve ser uma string com o path completo apontando para a pasta onde deve ser criada a pasta temporaria, se estiver vazio sera usado valor ``default`` que criará pasta no diretório atual onde o arquivo contendo esta função foi chamada.
|
30
|
+
|
31
|
+
``name_log_dir: str`` - deve ser uma string representando o nome do diretório de logger a ser criado. Se estiver vazio, o valor ``temp`` será usado como o nome padrão do diretório.
|
32
|
+
|
33
|
+
Retorno:
|
34
|
+
----------
|
35
|
+
>>> type:dict
|
36
|
+
* 'success': bool - representa se ação foi realizada com sucesso
|
37
|
+
* 'path_created': str - path do diretório que foi criado no processo
|
38
|
+
"""
|
39
|
+
|
40
|
+
# Local Variables
|
41
|
+
result: dict = {
|
42
|
+
'success': bool,
|
43
|
+
'path_created': str,
|
44
|
+
}
|
45
|
+
|
46
|
+
try:
|
47
|
+
# by 'default', defines path to local script execution path
|
48
|
+
if path_to_create == 'default':
|
49
|
+
path_to_create: str = os.getcwd()
|
50
|
+
|
51
|
+
# Build path to new dir
|
52
|
+
full_path: str = os.path.join(path_to_create, name_log_dir)
|
53
|
+
|
54
|
+
# Create dir in this block
|
55
|
+
try:
|
56
|
+
|
57
|
+
# Successefully created
|
58
|
+
os.makedirs(full_path, exist_ok=False)
|
59
|
+
|
60
|
+
result['success'] = True
|
61
|
+
result['path_created'] = fr'{full_path}'
|
62
|
+
|
63
|
+
success_print(f"Diretório:'{full_path}' foi criado com sucesso.")
|
64
|
+
|
65
|
+
except FileExistsError:
|
66
|
+
result['success'] = False
|
67
|
+
result['path_created'] = full_path
|
68
|
+
# alert_print(f"Diretório:'{full_path}' já existe.")
|
69
|
+
|
70
|
+
except PermissionError:
|
71
|
+
result['success'] = False
|
72
|
+
result['path_created'] = None
|
73
|
+
alert_print(f"Permissão negada: não é possível criar o diretório '{full_path}'.")
|
74
|
+
|
75
|
+
except Exception as e:
|
76
|
+
result['success'] = False
|
77
|
+
result['path_created'] = None
|
78
|
+
error_print(f'Error capturing current path to create logger directory! Error: {str(e)}')
|
79
|
+
|
80
|
+
finally:
|
81
|
+
return result
|
@@ -0,0 +1,8 @@
|
|
1
|
+
from logging import FileHandler, StreamHandler
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
# Variável global para o manipulador de arquivo
|
5
|
+
file_handler: Optional[FileHandler] = None
|
6
|
+
|
7
|
+
# Variável global para o manipulador de stream stdout/stdin/buffer
|
8
|
+
stream_handler: Optional[StreamHandler] = None
|
@@ -0,0 +1,9 @@
|
|
1
|
+
from loguru import logger
|
2
|
+
from typing import Optional
|
3
|
+
from typing import Any
|
4
|
+
|
5
|
+
# Variável global para o manipulador de arquivo
|
6
|
+
file_handler: Optional[str] = None
|
7
|
+
|
8
|
+
# Variável global para o manipulador de stream stdout/stdin/buffer
|
9
|
+
stream_handler: Optional[Any] = logger
|
@@ -0,0 +1,94 @@
|
|
1
|
+
import logging
|
2
|
+
from .logger import file_handler
|
3
|
+
from rpa_suite.log.printer import error_print, success_print
|
4
|
+
|
5
|
+
|
6
|
+
def log_start_run_debug(msg_start_loggin: str) -> None: # represent start application
|
7
|
+
|
8
|
+
"""
|
9
|
+
Function responsable to generate ``start run log level debug``, in file and print on terminal the same log captured on this call.
|
10
|
+
"""
|
11
|
+
|
12
|
+
try:
|
13
|
+
global file_handler
|
14
|
+
file_handler.stream.write(f'\n{msg_start_loggin}\n')
|
15
|
+
success_print(f'{msg_start_loggin}')
|
16
|
+
|
17
|
+
except Exception as e:
|
18
|
+
error_print(f'Erro durante a função: {log_start_run_debug.__name__}! Error: {str(e)}')
|
19
|
+
|
20
|
+
|
21
|
+
def log_debug(msg) -> None:
|
22
|
+
|
23
|
+
"""
|
24
|
+
Function responsable to generate log level ``debug``, in file and print on terminal the same log captured on this call.
|
25
|
+
"""
|
26
|
+
|
27
|
+
try:
|
28
|
+
logging.debug(msg)
|
29
|
+
|
30
|
+
except Exception as e:
|
31
|
+
error_print(f'Erro durante a função: {log_debug.__name__}! Error: {str(e)}')
|
32
|
+
|
33
|
+
def log_info(msg) -> None:
|
34
|
+
|
35
|
+
"""
|
36
|
+
Function responsable to generate log level ``info``, in file and print on terminal the same log captured on this call.
|
37
|
+
"""
|
38
|
+
|
39
|
+
try:
|
40
|
+
logging.info(msg)
|
41
|
+
|
42
|
+
except Exception as e:
|
43
|
+
error_print(f'Erro durante a função: {log_debug.__name__}! Error: {str(e)}')
|
44
|
+
|
45
|
+
def log_info(msg) -> None:
|
46
|
+
|
47
|
+
"""
|
48
|
+
Function responsable to generate log level ``info``, in file and print on terminal the same log captured on this call.
|
49
|
+
"""
|
50
|
+
|
51
|
+
try:
|
52
|
+
logging.info(msg)
|
53
|
+
|
54
|
+
except Exception as e:
|
55
|
+
error_print(f'Erro durante a função: {log_info.__name__}! Error: {str(e)}')
|
56
|
+
|
57
|
+
|
58
|
+
def log_warning(msg) -> None:
|
59
|
+
|
60
|
+
"""
|
61
|
+
Function responsable to generate log level ``warning``, in file and print on terminal the same log captured on this call.
|
62
|
+
"""
|
63
|
+
|
64
|
+
try:
|
65
|
+
logging.warning(msg)
|
66
|
+
|
67
|
+
except Exception as e:
|
68
|
+
error_print(f'Erro durante a função: {log_warning.__name__}! Error: {str(e)}')
|
69
|
+
|
70
|
+
|
71
|
+
def log_error(msg) -> None:
|
72
|
+
|
73
|
+
"""
|
74
|
+
Function responsable to generate log level ``error``, in file and print on terminal the same log captured on this call.
|
75
|
+
"""
|
76
|
+
|
77
|
+
try:
|
78
|
+
logging.error(msg)
|
79
|
+
|
80
|
+
except Exception as e:
|
81
|
+
error_print(f'Erro durante a função: {log_error.__name__}! Error: {str(e)}')
|
82
|
+
|
83
|
+
|
84
|
+
def log_critical(msg) -> None:
|
85
|
+
|
86
|
+
"""
|
87
|
+
Function responsable to generate log level ``critical``, in file and print on terminal the same log captured on this call.
|
88
|
+
"""
|
89
|
+
|
90
|
+
try:
|
91
|
+
logging.critical(msg)
|
92
|
+
|
93
|
+
except Exception as e:
|
94
|
+
error_print(f'Erro durante a função: {log_critical.__name__}! Error: {str(e)}')
|
@@ -0,0 +1,170 @@
|
|
1
|
+
from loguru import logger
|
2
|
+
from rpa_suite.log.printer import error_print, alert_print
|
3
|
+
import inspect, os
|
4
|
+
|
5
|
+
def log_start_run_debug(msg_start_loggin: str) -> None: # represent start application
|
6
|
+
|
7
|
+
"""
|
8
|
+
Function responsable to generate ``start run log level debug``, in file and print on terminal the same log captured on this call.
|
9
|
+
"""
|
10
|
+
|
11
|
+
file_h: False
|
12
|
+
|
13
|
+
try:
|
14
|
+
|
15
|
+
from .logger_uru import config_logger
|
16
|
+
file_h = config_logger()
|
17
|
+
|
18
|
+
except Exception as e:
|
19
|
+
|
20
|
+
error_print(f'Para usar o log_start_run_debug é necessario instanciar file_handler usando o arquivo "logger_uru" em algum arquivo de configuração do seu projeto primeiramente! Error: {str(e)}')
|
21
|
+
|
22
|
+
try:
|
23
|
+
try:
|
24
|
+
if file_h:
|
25
|
+
with open(file_h, 'a') as f:
|
26
|
+
f.write('\n')
|
27
|
+
|
28
|
+
except Exception as e:
|
29
|
+
alert_print(f'Não foi possivel gerar break_row para log inicial!')
|
30
|
+
|
31
|
+
# logger.debug(f'{msg_start_loggin}')
|
32
|
+
frame = inspect.currentframe().f_back
|
33
|
+
full_path_filename = frame.f_code.co_filename
|
34
|
+
|
35
|
+
# Obtenha o nome do arquivo e o nome da pasta
|
36
|
+
filename = os.path.basename(full_path_filename)
|
37
|
+
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
38
|
+
|
39
|
+
# Combine o nome da pasta e o nome do arquivo
|
40
|
+
filename = os.path.join(foldername, filename)
|
41
|
+
lineno = frame.f_lineno
|
42
|
+
|
43
|
+
# Vincule o nome do arquivo e a linha à mensagem de log
|
44
|
+
logger.bind(filename=filename, lineno=lineno).debug(f'{msg_start_loggin}')
|
45
|
+
|
46
|
+
except Exception as e:
|
47
|
+
error_print(f'Erro durante a função: {log_start_run_debug.__name__}! Error: {str(e)}')
|
48
|
+
|
49
|
+
|
50
|
+
def log_debug(msg) -> None:
|
51
|
+
|
52
|
+
"""
|
53
|
+
Function responsable to generate log level ``debug``, in file and print on terminal the same log captured on this call.
|
54
|
+
"""
|
55
|
+
|
56
|
+
try:
|
57
|
+
frame = inspect.currentframe().f_back
|
58
|
+
full_path_filename = frame.f_code.co_filename
|
59
|
+
|
60
|
+
# Obtenha o nome do arquivo e o nome da pasta
|
61
|
+
filename = os.path.basename(full_path_filename)
|
62
|
+
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
63
|
+
|
64
|
+
# Combine o nome da pasta e o nome do arquivo
|
65
|
+
filename = os.path.join(foldername, filename)
|
66
|
+
lineno = frame.f_lineno
|
67
|
+
|
68
|
+
# Vincule o nome do arquivo e a linha à mensagem de log
|
69
|
+
logger.bind(filename=filename, lineno=lineno).debug(msg)
|
70
|
+
|
71
|
+
except Exception as e:
|
72
|
+
error_print(f'Erro durante a função: {log_debug.__name__}! Error: {str(e)}')
|
73
|
+
|
74
|
+
def log_info(msg) -> None:
|
75
|
+
|
76
|
+
"""
|
77
|
+
Function responsable to generate log level ``info``, in file and print on terminal the same log captured on this call.
|
78
|
+
"""
|
79
|
+
|
80
|
+
try:
|
81
|
+
frame = inspect.currentframe().f_back
|
82
|
+
full_path_filename = frame.f_code.co_filename
|
83
|
+
|
84
|
+
# Obtenha o nome do arquivo e o nome da pasta
|
85
|
+
filename = os.path.basename(full_path_filename)
|
86
|
+
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
87
|
+
|
88
|
+
# Combine o nome da pasta e o nome do arquivo
|
89
|
+
filename = os.path.join(foldername, filename)
|
90
|
+
lineno = frame.f_lineno
|
91
|
+
|
92
|
+
# Vincule o nome do arquivo e a linha à mensagem de log
|
93
|
+
logger.bind(filename=filename, lineno=lineno).info(msg)
|
94
|
+
|
95
|
+
except Exception as e:
|
96
|
+
error_print(f'Erro durante a função: {log_info.__name__}! Error: {str(e)}')
|
97
|
+
|
98
|
+
def log_warning(msg) -> None:
|
99
|
+
|
100
|
+
"""
|
101
|
+
Function responsable to generate log level ``warning``, in file and print on terminal the same log captured on this call.
|
102
|
+
"""
|
103
|
+
|
104
|
+
try:
|
105
|
+
frame = inspect.currentframe().f_back
|
106
|
+
full_path_filename = frame.f_code.co_filename
|
107
|
+
|
108
|
+
# Obtenha o nome do arquivo e o nome da pasta
|
109
|
+
filename = os.path.basename(full_path_filename)
|
110
|
+
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
111
|
+
|
112
|
+
# Combine o nome da pasta e o nome do arquivo
|
113
|
+
filename = os.path.join(foldername, filename)
|
114
|
+
lineno = frame.f_lineno
|
115
|
+
|
116
|
+
# Vincule o nome do arquivo e a linha à mensagem de log
|
117
|
+
logger.bind(filename=filename, lineno=lineno).warning(msg)
|
118
|
+
|
119
|
+
except Exception as e:
|
120
|
+
error_print(f'Erro durante a função: {log_warning.__name__}! Error: {str(e)}')
|
121
|
+
|
122
|
+
|
123
|
+
def log_error(msg) -> None:
|
124
|
+
|
125
|
+
"""
|
126
|
+
Function responsable to generate log level ``error``, in file and print on terminal the same log captured on this call.
|
127
|
+
"""
|
128
|
+
|
129
|
+
try:
|
130
|
+
frame = inspect.currentframe().f_back
|
131
|
+
full_path_filename = frame.f_code.co_filename
|
132
|
+
|
133
|
+
# Obtenha o nome do arquivo e o nome da pasta
|
134
|
+
filename = os.path.basename(full_path_filename)
|
135
|
+
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
136
|
+
|
137
|
+
# Combine o nome da pasta e o nome do arquivo
|
138
|
+
filename = os.path.join(foldername, filename)
|
139
|
+
lineno = frame.f_lineno
|
140
|
+
|
141
|
+
# Vincule o nome do arquivo e a linha à mensagem de log
|
142
|
+
logger.bind(filename=filename, lineno=lineno).error(msg)
|
143
|
+
|
144
|
+
except Exception as e:
|
145
|
+
error_print(f'Erro durante a função: {log_error.__name__}! Error: {str(e)}')
|
146
|
+
|
147
|
+
|
148
|
+
def log_critical(msg) -> None:
|
149
|
+
|
150
|
+
"""
|
151
|
+
Function responsable to generate log level ``critical``, in file and print on terminal the same log captured on this call.
|
152
|
+
"""
|
153
|
+
|
154
|
+
try:
|
155
|
+
frame = inspect.currentframe().f_back
|
156
|
+
full_path_filename = frame.f_code.co_filename
|
157
|
+
|
158
|
+
# Obtenha o nome do arquivo e o nome da pasta
|
159
|
+
filename = os.path.basename(full_path_filename)
|
160
|
+
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
161
|
+
|
162
|
+
# Combine o nome da pasta e o nome do arquivo
|
163
|
+
filename = os.path.join(foldername, filename)
|
164
|
+
lineno = frame.f_lineno
|
165
|
+
|
166
|
+
# Vincule o nome do arquivo e a linha à mensagem de log
|
167
|
+
logger.bind(filename=filename, lineno=lineno).critical(msg)
|
168
|
+
|
169
|
+
except Exception as e:
|
170
|
+
error_print(f'Erro durante a função: {log_critical.__name__}! Error: {str(e)}')
|
@@ -8,28 +8,28 @@ def logging_decorator(
|
|
8
8
|
"""
|
9
9
|
Function responsible for displaying log message in the console for functions that are called. \n
|
10
10
|
Displays function name, and the result of the function in case of return, without return returns None.
|
11
|
-
|
11
|
+
|
12
12
|
Return:
|
13
13
|
----------
|
14
14
|
A ``wrapper`` function with python decoration ``@logger.catch`` that received:
|
15
15
|
* ``*args and **kwargs`` in the call parameters as an argument to result in the Log.
|
16
|
-
|
16
|
+
|
17
17
|
Description: pt-br
|
18
18
|
----------
|
19
19
|
Função responsavel por exibir mensagem de log no console para funções que são chamadas. \n
|
20
20
|
Exibe nome da função, e o resultado da função em caso de retorno, sem retorno devolve None.
|
21
|
-
|
21
|
+
|
22
22
|
Retorno:
|
23
23
|
----------
|
24
24
|
Uma função ``wrapper`` com decoração ``@logger.catch`` do python que recebeu:
|
25
25
|
* ``*args e **kwargs`` nos parametros de chamada como argumento para resultar no Log.
|
26
26
|
"""
|
27
|
-
|
27
|
+
|
28
28
|
@logger.catch
|
29
29
|
def wrapper(*args, **kwargs):
|
30
30
|
logger.info('Function Called: {}', fn.__name__)
|
31
31
|
result = fn(*args, **kwargs)
|
32
32
|
logger.info('Function {} returned: {}', fn.__name__, result)
|
33
33
|
return result
|
34
|
-
|
34
|
+
|
35
35
|
return wrapper
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import logging
|
2
|
+
from logging import DEBUG
|
3
|
+
from logging import FileHandler, StreamHandler, Filter
|
4
|
+
from colorlog import ColoredFormatter
|
5
|
+
from typing import Optional as Op
|
6
|
+
from ._variables import file_handler, stream_handler
|
7
|
+
from .__create_log_dir import _create_log_dir
|
8
|
+
from rpa_suite.log.printer import error_print
|
9
|
+
|
10
|
+
|
11
|
+
class Filters(Filter):
|
12
|
+
|
13
|
+
word_filter: Op[list[str]]
|
14
|
+
|
15
|
+
def filter(self, record):
|
16
|
+
|
17
|
+
if len(self.word_filter) > 0:
|
18
|
+
|
19
|
+
for words in self.word_filter:
|
20
|
+
|
21
|
+
|
22
|
+
string_words: list[str] = [str(word) for word in words]
|
23
|
+
"""print(words)
|
24
|
+
print(type(words))
|
25
|
+
print(string_words)
|
26
|
+
print(type(string_words))
|
27
|
+
input()"""
|
28
|
+
for word in string_words:
|
29
|
+
if word in record.msg:
|
30
|
+
record.msg = 'Log Alterado devido a palavra Filtrada!'
|
31
|
+
return True
|
32
|
+
|
33
|
+
return True
|
34
|
+
|
35
|
+
|
36
|
+
def config_logger(name_app:str = 'Logger', path_dir:str = None, name_log_dir:str = None, name_file_log: str = 'log', use_default_path_and_name: bool = True, filter_words: list[str] = None) -> Op[FileHandler]:
|
37
|
+
|
38
|
+
"""
|
39
|
+
Function responsible for create a object logger with fileHandler and streamHandler
|
40
|
+
"""
|
41
|
+
|
42
|
+
global file_handler, stream_handler
|
43
|
+
|
44
|
+
try:
|
45
|
+
|
46
|
+
|
47
|
+
if not use_default_path_and_name:
|
48
|
+
result_tryed: dict = _create_log_dir(path_dir, name_log_dir)
|
49
|
+
path_dir = result_tryed['path_created']
|
50
|
+
else:
|
51
|
+
if path_dir == None and name_log_dir == None:
|
52
|
+
result_tryed: dict = _create_log_dir()
|
53
|
+
path_dir = result_tryed['path_created']
|
54
|
+
|
55
|
+
|
56
|
+
# configuração de objetos logger
|
57
|
+
file_handler = FileHandler(
|
58
|
+
filename=fr'{path_dir}\{name_file_log}.log',
|
59
|
+
mode='a',
|
60
|
+
encoding='utf-8'
|
61
|
+
)
|
62
|
+
stream_handler = StreamHandler()
|
63
|
+
|
64
|
+
# Crie um formatador
|
65
|
+
formatter = ColoredFormatter(
|
66
|
+
"%(log_color)s%(levelname)s ->%(reset)s %(log_color)s%(message)s%(reset)s",
|
67
|
+
datefmt=None,
|
68
|
+
reset=True,
|
69
|
+
log_colors={
|
70
|
+
'DEBUG': 'cyan',
|
71
|
+
'INFO': 'green',
|
72
|
+
'WARNING': 'yellow',
|
73
|
+
'ERROR': 'red',
|
74
|
+
'CRITICAL': 'red',
|
75
|
+
},
|
76
|
+
force_color=True
|
77
|
+
)
|
78
|
+
stream_handler.setFormatter(formatter)
|
79
|
+
|
80
|
+
# ATRIBUIÇÕES
|
81
|
+
new_filter: Op[Filters] = None
|
82
|
+
if filter_words is not None:
|
83
|
+
new_filter: Filters = Filters()
|
84
|
+
new_filter.word_filter = [filter_words]
|
85
|
+
|
86
|
+
if new_filter is not None:
|
87
|
+
file_handler.addFilter(new_filter)
|
88
|
+
|
89
|
+
file_handler.setLevel(DEBUG)
|
90
|
+
|
91
|
+
# Obtenha o logger
|
92
|
+
logger = logging.getLogger(__name__)
|
93
|
+
|
94
|
+
# Adicione o manipulador de stream ao logger
|
95
|
+
logger.addHandler(stream_handler)
|
96
|
+
|
97
|
+
# terminando de inplementar configuração para o logger
|
98
|
+
FORMAT = '%(levelname)s!%(asctime)s: %(message)s'
|
99
|
+
logging.basicConfig(
|
100
|
+
level=DEBUG, # level from stream_handler
|
101
|
+
#format='%(levelname)s - %(asctime)s - %(message)s',
|
102
|
+
format=FORMAT,
|
103
|
+
handlers=[file_handler, stream_handler],
|
104
|
+
datefmt='%d.%m.%y %H:%M',
|
105
|
+
)
|
106
|
+
return file_handler
|
107
|
+
|
108
|
+
except Exception as e:
|
109
|
+
|
110
|
+
error_print(f'Houve um erro durante a execução da função: {config_logger.__name__}! Error: {str(e)}.')
|
111
|
+
return None
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# /logger_uru.py
|
2
|
+
|
3
|
+
from typing import Optional as Op
|
4
|
+
from .__create_log_dir import _create_log_dir
|
5
|
+
from rpa_suite.log.printer import error_print
|
6
|
+
from loguru import logger
|
7
|
+
import sys, os, inspect
|
8
|
+
|
9
|
+
class Filters:
|
10
|
+
word_filter: Op[list[str]]
|
11
|
+
|
12
|
+
def __call__(self, record):
|
13
|
+
|
14
|
+
if len(self.word_filter) > 0:
|
15
|
+
|
16
|
+
for words in self.word_filter:
|
17
|
+
|
18
|
+
string_words: list[str] = [str(word) for word in words]
|
19
|
+
|
20
|
+
for word in string_words:
|
21
|
+
if word in record["message"]:
|
22
|
+
record["message"] = 'Log Alterado devido a palavra Filtrada!'
|
23
|
+
return True
|
24
|
+
|
25
|
+
return True
|
26
|
+
|
27
|
+
|
28
|
+
class CustomHandler:
|
29
|
+
def __init__(self, formatter):
|
30
|
+
self.formatter = formatter
|
31
|
+
|
32
|
+
def write(self, message):
|
33
|
+
frame = inspect.currentframe().f_back.f_back
|
34
|
+
log_msg = self.formatter.format(message, frame)
|
35
|
+
sys.stderr.write(log_msg)
|
36
|
+
|
37
|
+
|
38
|
+
class CustomFormatter:
|
39
|
+
def format(self, record):
|
40
|
+
|
41
|
+
frame = inspect.currentframe().f_back
|
42
|
+
full_path_filename = frame.f_code.co_filename
|
43
|
+
|
44
|
+
# Obtenha o nome do arquivo e o nome da pasta
|
45
|
+
filename = os.path.basename(full_path_filename)
|
46
|
+
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
47
|
+
|
48
|
+
# Combine o nome da pasta e o nome do arquivo
|
49
|
+
filename = os.path.join(foldername, filename)
|
50
|
+
lineno = frame.f_lineno
|
51
|
+
|
52
|
+
# Formate a mensagem de log TERMINAL
|
53
|
+
format_string = "<green>{time:DD.MM.YY.HH:mm}</green> <level>{level: <8}</level> <level>{message}</level>\n"
|
54
|
+
|
55
|
+
log_msg = format_string.format(
|
56
|
+
time=record["time"],
|
57
|
+
level=record["level"].name,
|
58
|
+
filename=filename,
|
59
|
+
lineno=lineno,
|
60
|
+
message=record["message"]
|
61
|
+
)
|
62
|
+
return log_msg
|
63
|
+
|
64
|
+
def config_logger(path_dir:str = None, name_log_dir:str = None, name_file_log: str = 'log', use_default_path_and_name: bool = True, filter_words: list[str] = None):
|
65
|
+
|
66
|
+
"""
|
67
|
+
Function responsible for create a object logger with fileHandler and streamHandler
|
68
|
+
"""
|
69
|
+
|
70
|
+
try:
|
71
|
+
|
72
|
+
if not use_default_path_and_name:
|
73
|
+
result_tryed: dict = _create_log_dir(path_dir, name_log_dir)
|
74
|
+
path_dir = result_tryed['path_created']
|
75
|
+
else:
|
76
|
+
if path_dir == None and name_log_dir == None:
|
77
|
+
result_tryed: dict = _create_log_dir()
|
78
|
+
path_dir = result_tryed['path_created']
|
79
|
+
|
80
|
+
|
81
|
+
# ATRIBUIÇÕES
|
82
|
+
new_filter: Op[Filters] = None
|
83
|
+
if filter_words is not None:
|
84
|
+
new_filter: Filters = Filters()
|
85
|
+
new_filter.word_filter = [filter_words]
|
86
|
+
|
87
|
+
|
88
|
+
# configuração de objetos logger
|
89
|
+
file_handler = fr'{path_dir}\{name_file_log}.log'
|
90
|
+
logger.remove()
|
91
|
+
|
92
|
+
# Formate a mensagem de log FILE
|
93
|
+
log_format: str = "<green>{time:DD.MM.YY.HH:mm}</green> <level>{level: <8}</level> <green>{extra[filename]}</green>:{extra[lineno]: <4} <level>{message}</level>"
|
94
|
+
|
95
|
+
|
96
|
+
formatter = CustomFormatter()
|
97
|
+
if new_filter is not None:
|
98
|
+
logger.add(file_handler, filter=new_filter, level="DEBUG", format=log_format)
|
99
|
+
else:
|
100
|
+
logger.add(file_handler, level="DEBUG", format=log_format)
|
101
|
+
|
102
|
+
# Adicione sys.stderr como um manipulador
|
103
|
+
logger.add(sys.stderr, level="DEBUG", format=formatter.format)
|
104
|
+
|
105
|
+
return file_handler
|
106
|
+
|
107
|
+
except Exception as e:
|
108
|
+
|
109
|
+
error_print(f'Houve um erro durante a execução da função: {config_logger.__name__}! Error: {str(e)}.')
|
110
|
+
return None
|
@@ -1,29 +1,41 @@
|
|
1
|
+
|
1
2
|
"""MODULE CLOCK"""
|
2
3
|
from .clock.waiter import wait_for_exec, exec_and_wait
|
3
4
|
from .clock.exec_at import exec_at_hour
|
4
5
|
|
6
|
+
|
5
7
|
"""MODULE DATE"""
|
6
8
|
from .date.date import get_hms, get_dma
|
7
9
|
|
10
|
+
|
8
11
|
"""MODULE EMAIL"""
|
9
12
|
from .email.sender_smtp import send_email
|
10
13
|
|
14
|
+
|
11
15
|
"""MODULE FILE"""
|
12
16
|
from .file.counter import count_files
|
13
17
|
from .file.temp_dir import create_temp_dir, delete_temp_dir
|
14
18
|
|
19
|
+
|
15
20
|
"""MODULE LOG"""
|
16
21
|
# from .log.loggin import logging_decorator
|
17
22
|
from .log.printer import alert_print, success_print, error_print, info_print, print_call_fn, print_retur_fn, magenta_print, blue_print
|
18
23
|
|
24
|
+
from .log.logger import config_logger
|
25
|
+
from .log.functions_logger import log_start_run_debug, log_debug, log_info, log_warning, log_error, log_critical
|
26
|
+
|
27
|
+
|
19
28
|
"""MODULE REGEX"""
|
20
29
|
from .regex.list_from_text import create_list_using_regex
|
21
30
|
|
31
|
+
|
22
32
|
"""MODULE VALIDATE"""
|
23
33
|
from .validate.mail_validator import valid_emails
|
24
34
|
from .validate.string_validator import search_in
|
25
35
|
|
36
|
+
|
26
37
|
class Rpa_suite():
|
38
|
+
|
27
39
|
"""
|
28
40
|
The ``Rpa_suite`` class is a generic representation of the modules, with the aim of centralizing all submodules for access through an instance of this representational Object. It contains variables pointed to the functions of the submodules present in the rpa-site.
|
29
41
|
|
@@ -66,7 +78,7 @@ class Rpa_suite():
|
|
66
78
|
delete_temp_dir = delete_temp_dir
|
67
79
|
#clear_temp_dir = clear_temp_dir
|
68
80
|
|
69
|
-
# log
|
81
|
+
# log - printer
|
70
82
|
alert_print = alert_print
|
71
83
|
success_print = success_print
|
72
84
|
error_print = error_print
|
@@ -75,6 +87,15 @@ class Rpa_suite():
|
|
75
87
|
print_retur_fn = print_retur_fn
|
76
88
|
magenta_print = magenta_print
|
77
89
|
blue_print = blue_print
|
90
|
+
|
91
|
+
# log - logger with file and prints
|
92
|
+
config_logger = config_logger
|
93
|
+
log_start_run_debug = log_start_run_debug
|
94
|
+
log_debug = log_debug
|
95
|
+
log_info = log_info
|
96
|
+
log_warning = log_warning
|
97
|
+
log_error = log_error
|
98
|
+
log_critical = log_critical
|
78
99
|
|
79
100
|
# regex
|
80
101
|
create_list_using_regex = create_list_using_regex
|
@@ -88,10 +109,10 @@ class Rpa_suite():
|
|
88
109
|
|
89
110
|
# Define function to return this instance
|
90
111
|
def invoke() -> Rpa_suite:
|
91
|
-
|
112
|
+
|
92
113
|
"""
|
93
114
|
Function responsible for return a object Rpa_suite with access all modules by .name_module or use 'from rpa_suite import suite' to >>> suite.functions_avaliable()
|
94
115
|
"""
|
95
|
-
|
116
|
+
|
96
117
|
suite = Rpa_suite()
|
97
118
|
return suite
|
@@ -1,13 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: rpa-suite
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.1
|
4
4
|
Summary: Conjunto de ferramentas essenciais para Automação RPA com Python, que facilitam o dia a dia de desenvolvimento.
|
5
5
|
Author: Camilo Costa de Carvalho
|
6
6
|
Author-email: camilo.carvalho@triasoftware.com.br
|
7
7
|
License: MIT
|
8
8
|
Keywords: basic-tools,email-tools,email-validation,file-tools,simple-functions,rpa-tools,rpa-functions,Tools,Rpa,Automation,RPA,Automação,Python,Ferramentas de RPA,Automação de Processos,Biblioteca Python para RPA
|
9
9
|
Classifier: Development Status :: 3 - Alpha
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
11
10
|
Classifier: Programming Language :: Python :: 3.11
|
12
11
|
Classifier: Programming Language :: Python :: 3.12
|
13
12
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -22,6 +21,7 @@ License-File: LICENSE
|
|
22
21
|
Requires-Dist: loguru
|
23
22
|
Requires-Dist: colorama
|
24
23
|
Requires-Dist: email_validator
|
24
|
+
Requires-Dist: colorlog
|
25
25
|
|
26
26
|

|
27
27
|
|
@@ -126,6 +126,7 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
|
|
126
126
|
- colorama
|
127
127
|
- loguru
|
128
128
|
- email-validator
|
129
|
+
- colorlog
|
129
130
|
|
130
131
|
## Estrutura do módulo
|
131
132
|
O módulo principal do rpa-suite é dividido em categorias. Cada categoria contém módulos com funções destinadas a cada tipo de tarefa
|
@@ -141,7 +142,7 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
141
142
|
- **counter** - Funções para contagem de arquivos
|
142
143
|
- **temp_dir** - Funções para diretórios temporários
|
143
144
|
- **log**
|
144
|
-
- **
|
145
|
+
- **logger** - Objeto de log, cria diretório/arquivo de log integrado aos prints
|
145
146
|
- **printer** - Funções print personalizados (alerta, erro, sucesso, informativo)
|
146
147
|
- **regex**
|
147
148
|
- **list_from_text** - Funções para gerar listas, dividindo texto usando padrão regex
|
@@ -150,7 +151,7 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
150
151
|
- **string_validator** - Funções para validação/varredura (strings, substrings, palavras)
|
151
152
|
|
152
153
|
## Release
|
153
|
-
Versão: **
|
154
|
+
Versão: **Beta 1.0.1**
|
154
155
|
|
155
156
|
Lançamento: *20/02/2024*
|
156
157
|
|
@@ -19,8 +19,15 @@ rpa_suite/email/sender_smtp.py
|
|
19
19
|
rpa_suite/file/__init__.py
|
20
20
|
rpa_suite/file/counter.py
|
21
21
|
rpa_suite/file/temp_dir.py
|
22
|
+
rpa_suite/log/__create_log_dir.py
|
22
23
|
rpa_suite/log/__init__.py
|
23
|
-
rpa_suite/log/
|
24
|
+
rpa_suite/log/_variables.py
|
25
|
+
rpa_suite/log/_variables_uru.py
|
26
|
+
rpa_suite/log/functions_logger.py
|
27
|
+
rpa_suite/log/functions_logger_uru.py
|
28
|
+
rpa_suite/log/log_decorator.py
|
29
|
+
rpa_suite/log/logger.py
|
30
|
+
rpa_suite/log/logger_uru.py
|
24
31
|
rpa_suite/log/printer.py
|
25
32
|
rpa_suite/regex/__init__.py
|
26
33
|
rpa_suite/regex/list_from_text.py
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='rpa_suite',
|
5
|
-
version='0.
|
5
|
+
version='1.0.1',
|
6
6
|
packages=find_packages(),
|
7
7
|
description='Conjunto de ferramentas essenciais para Automação RPA com Python, que facilitam o dia a dia de desenvolvimento.',
|
8
8
|
long_description_content_type='text/markdown',
|
@@ -12,7 +12,6 @@ setup(
|
|
12
12
|
license='MIT',
|
13
13
|
classifiers=[
|
14
14
|
'Development Status :: 3 - Alpha',
|
15
|
-
'Programming Language :: Python :: 3.10',
|
16
15
|
'Programming Language :: Python :: 3.11',
|
17
16
|
'Programming Language :: Python :: 3.12',
|
18
17
|
'License :: OSI Approved :: MIT License',
|
@@ -24,5 +23,5 @@ setup(
|
|
24
23
|
'Topic :: Software Development :: Libraries :: Python Modules'
|
25
24
|
],
|
26
25
|
keywords='basic-tools, email-tools, email-validation, file-tools, simple-functions, rpa-tools, rpa-functions, Tools, Rpa, Automation, RPA, Automação, Python, Ferramentas de RPA, Automação de Processos, Biblioteca Python para RPA',
|
27
|
-
install_requires=['loguru', 'colorama', 'email_validator'],
|
26
|
+
install_requires=['loguru', 'colorama', 'email_validator', 'colorlog'],
|
28
27
|
)
|
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
|
File without changes
|