rpa-suite 1.0.0__py3-none-any.whl → 1.0.1__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.
- rpa_suite/log/_variables_uru.py +9 -0
- rpa_suite/log/functions_logger_uru.py +170 -0
- rpa_suite/log/logger.py +1 -1
- rpa_suite/log/logger_uru.py +110 -0
- {rpa_suite-1.0.0.dist-info → rpa_suite-1.0.1.dist-info}/METADATA +2 -3
- {rpa_suite-1.0.0.dist-info → rpa_suite-1.0.1.dist-info}/RECORD +9 -6
- {rpa_suite-1.0.0.dist-info → rpa_suite-1.0.1.dist-info}/LICENSE +0 -0
- {rpa_suite-1.0.0.dist-info → rpa_suite-1.0.1.dist-info}/WHEEL +0 -0
- {rpa_suite-1.0.0.dist-info → rpa_suite-1.0.1.dist-info}/top_level.txt +0 -0
@@ -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,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)}')
|
rpa_suite/log/logger.py
CHANGED
@@ -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,13 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: rpa-suite
|
3
|
-
Version: 1.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
|
@@ -152,7 +151,7 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
152
151
|
- **string_validator** - Funções para validação/varredura (strings, substrings, palavras)
|
153
152
|
|
154
153
|
## Release
|
155
|
-
Versão: **Beta 1.0.
|
154
|
+
Versão: **Beta 1.0.1**
|
156
155
|
|
157
156
|
Lançamento: *20/02/2024*
|
158
157
|
|
@@ -14,17 +14,20 @@ rpa_suite/file/temp_dir.py,sha256=F2ZDFLpqHO1BTtJURkiuexQNaO-pngJkk6cvTmp0JSk,71
|
|
14
14
|
rpa_suite/log/__create_log_dir.py,sha256=5pxX7j3vWYQ0Dn2_04UWnfUJvvbzd78DgOpH2IaBFYM,3293
|
15
15
|
rpa_suite/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
16
|
rpa_suite/log/_variables.py,sha256=rt8W9-yDgoonAu93yuPZgPy-rtnJcq4NwzB7EL0TRX4,292
|
17
|
+
rpa_suite/log/_variables_uru.py,sha256=fe2IKhyZzroHO5WIIm_VCKwcdr8lfobOr-VctgpdQhc,279
|
17
18
|
rpa_suite/log/functions_logger.py,sha256=A6z_f6pKClz_PYl3YEM-9px1KShNox5etU3umPqqvyg,2668
|
19
|
+
rpa_suite/log/functions_logger_uru.py,sha256=GvXeAnsevLLVJCO2rhXr81ngmYl6xHfMsnEEin4Viu8,6124
|
18
20
|
rpa_suite/log/log_decorator.py,sha256=K5RhUITcPIHQmnuCZjEYYUbYyK1-WaB7EwZe2V3ugCE,1315
|
19
|
-
rpa_suite/log/logger.py,sha256=
|
21
|
+
rpa_suite/log/logger.py,sha256=JD4mBdfWA_XE5Qq5JMLBf_LLWWonVKNZo-F-GqrRm04,3619
|
22
|
+
rpa_suite/log/logger_uru.py,sha256=HwMHqJs9wKDfGqSny0smwOQK3wq1xLTd3x-nCGQ0IZo,3665
|
20
23
|
rpa_suite/log/printer.py,sha256=sykxCpOyiMe539iXuRq-yN6HpKi1xxWiP7mZ1s8mF6k,3948
|
21
24
|
rpa_suite/regex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
25
|
rpa_suite/regex/list_from_text.py,sha256=gGTNJdnmD1kwJ6oQOMwcEFFKb_U5i4rV-bSCHC-LlKQ,2202
|
23
26
|
rpa_suite/validate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
24
27
|
rpa_suite/validate/mail_validator.py,sha256=PEa_-bON7BYnpaz-p5aEZkpza7qsoBBFKv6GwsjdjCU,2906
|
25
28
|
rpa_suite/validate/string_validator.py,sha256=7eJVTCmzVwgM513NqAAjqvo9iqHmsWQ-6LQ8-oOh_0s,5344
|
26
|
-
rpa_suite-1.0.
|
27
|
-
rpa_suite-1.0.
|
28
|
-
rpa_suite-1.0.
|
29
|
-
rpa_suite-1.0.
|
30
|
-
rpa_suite-1.0.
|
29
|
+
rpa_suite-1.0.1.dist-info/LICENSE,sha256=5D8PIbs31iGd9i1_MDNg4SzaQnp9sEIULALh2y3WyMI,1102
|
30
|
+
rpa_suite-1.0.1.dist-info/METADATA,sha256=pvVGsAISURiGv805OPLQKushyBWds5s3w9zl0fUCo5E,6604
|
31
|
+
rpa_suite-1.0.1.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
32
|
+
rpa_suite-1.0.1.dist-info/top_level.txt,sha256=HYkDtg-kJNAr3F2XAIPyJ-QBbNhk7q6jrqsFt10lz4Y,10
|
33
|
+
rpa_suite-1.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|