rpa-suite 1.5.2__py3-none-any.whl → 1.5.4__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/__init__.py +57 -56
- rpa_suite/core/__init__.py +3 -2
- rpa_suite/core/asyncrun.py +31 -33
- rpa_suite/core/browser.py +110 -81
- rpa_suite/core/clock.py +115 -118
- rpa_suite/core/date.py +36 -40
- rpa_suite/core/dir.py +70 -54
- rpa_suite/core/email.py +55 -53
- rpa_suite/core/file.py +88 -76
- rpa_suite/core/log.py +26 -10
- rpa_suite/core/parallel.py +106 -96
- rpa_suite/core/print.py +42 -70
- rpa_suite/core/regex.py +29 -22
- rpa_suite/core/validate.py +89 -86
- rpa_suite/functions/__create_ss_dir.py +24 -20
- rpa_suite/functions/__init__.py +1 -1
- rpa_suite/functions/_printer.py +20 -20
- rpa_suite/suite.py +71 -101
- rpa_suite/utils/system.py +7 -5
- {rpa_suite-1.5.2.dist-info → rpa_suite-1.5.4.dist-info}/METADATA +76 -59
- rpa_suite-1.5.4.dist-info/RECORD +25 -0
- rpa_suite-1.5.2.dist-info/RECORD +0 -25
- {rpa_suite-1.5.2.dist-info → rpa_suite-1.5.4.dist-info}/WHEEL +0 -0
- {rpa_suite-1.5.2.dist-info → rpa_suite-1.5.4.dist-info}/licenses/LICENSE +0 -0
- {rpa_suite-1.5.2.dist-info → rpa_suite-1.5.4.dist-info}/top_level.txt +0 -0
rpa_suite/core/dir.py
CHANGED
@@ -8,9 +8,7 @@ import os, shutil
|
|
8
8
|
from typing import Union
|
9
9
|
|
10
10
|
|
11
|
-
|
12
|
-
class Directory():
|
13
|
-
|
11
|
+
class Directory:
|
14
12
|
"""
|
15
13
|
Class that provides utilities for directory management, including creating, deleting, and manipulating directories.
|
16
14
|
|
@@ -22,7 +20,7 @@ class Directory():
|
|
22
20
|
|
23
21
|
Methods:
|
24
22
|
create_temp_dir: Creates a temporary directory for file operations.
|
25
|
-
|
23
|
+
|
26
24
|
The Directory class is part of RPA Suite and can be accessed through the rpa object:
|
27
25
|
>>> from rpa_suite import rpa
|
28
26
|
>>> rpa.directory.create_temp_dir(path_to_create='my_folder', name_temp_dir='temp_dir')
|
@@ -43,7 +41,7 @@ class Directory():
|
|
43
41
|
|
44
42
|
Métodos:
|
45
43
|
create_temp_dir: Cria um diretório temporário para operações com arquivos.
|
46
|
-
|
44
|
+
|
47
45
|
A classe Directory é parte do RPA Suite e pode ser acessada através do objeto rpa:
|
48
46
|
>>> from rpa_suite import rpa
|
49
47
|
>>> rpa.directory.create_temp_dir(path_to_create='minha_pasta', name_temp_dir='temp_dir')
|
@@ -53,13 +51,14 @@ class Directory():
|
|
53
51
|
name_temp_dir (str): O nome do diretório temporário a ser criado. O padrão é 'temp'.
|
54
52
|
"""
|
55
53
|
|
56
|
-
def __init__(self):
|
57
|
-
...
|
58
|
-
|
59
|
-
def create_temp_dir(self,
|
60
|
-
path_to_create: str = 'default',
|
61
|
-
name_temp_dir: str='temp') -> dict[str, Union[bool, str, None]]:
|
54
|
+
def __init__(self): ...
|
62
55
|
|
56
|
+
def create_temp_dir(
|
57
|
+
self,
|
58
|
+
path_to_create: str = "default",
|
59
|
+
name_temp_dir: str = "temp",
|
60
|
+
display_message: bool = False,
|
61
|
+
) -> dict[str, Union[bool, str, None]]:
|
63
62
|
"""
|
64
63
|
Function responsible for creating a temporary directory to work with files and etc. \n
|
65
64
|
|
@@ -69,12 +68,14 @@ class Directory():
|
|
69
68
|
|
70
69
|
``name_temp_dir: str`` - should be a string representing the name of the temporary directory to be created. If it is empty, the ``temp`` value will be used as the default directory name.
|
71
70
|
|
71
|
+
``display_message: bool`` - should be a bool to display messages on terminal, by default False.
|
72
|
+
|
72
73
|
Return:
|
73
74
|
----------
|
74
75
|
>>> type:dict
|
75
76
|
* 'success': bool - represents case the action was performed successfully
|
76
77
|
* 'path_created': str - path of the directory that was created on the process
|
77
|
-
|
78
|
+
|
78
79
|
Description: pt-br
|
79
80
|
----------
|
80
81
|
Função responsavel por criar diretório temporário para trabalhar com arquivos e etc. \n
|
@@ -85,22 +86,24 @@ class Directory():
|
|
85
86
|
|
86
87
|
``name_temp_dir: str`` - deve ser uma string representando o nome do diretório temporário a ser criado. Se estiver vazio, o valor ``temp`` será usado como o nome padrão do diretório.
|
87
88
|
|
89
|
+
``display_message: bool`` - deve ser um bool para exibir mensagens no terminal, por padrão False.
|
90
|
+
|
88
91
|
Retorno:
|
89
92
|
----------
|
90
93
|
>>> type:dict
|
91
94
|
* 'success': bool - representa se ação foi realizada com sucesso
|
92
95
|
* 'path_created': str - path do diretório que foi criado no processo
|
93
96
|
"""
|
94
|
-
|
97
|
+
|
95
98
|
# Local Variables
|
96
99
|
result: dict = {
|
97
|
-
|
98
|
-
|
100
|
+
"success": bool,
|
101
|
+
"path_created": str,
|
99
102
|
}
|
100
|
-
|
103
|
+
|
101
104
|
try:
|
102
105
|
# by 'default', defines path to local script execution path
|
103
|
-
if path_to_create ==
|
106
|
+
if path_to_create == "default":
|
104
107
|
path_to_create: str = os.getcwd()
|
105
108
|
|
106
109
|
# Build path to new dir
|
@@ -112,38 +115,45 @@ class Directory():
|
|
112
115
|
# Successefully created
|
113
116
|
os.makedirs(full_path, exist_ok=False)
|
114
117
|
|
115
|
-
result[
|
116
|
-
result[
|
118
|
+
result["success"] = True
|
119
|
+
result["path_created"] = rf"{full_path}"
|
117
120
|
|
118
|
-
|
121
|
+
if display_message:
|
122
|
+
success_print(f"Directory:'{full_path}' successfully created.")
|
119
123
|
|
120
124
|
except FileExistsError:
|
121
|
-
result[
|
122
|
-
result[
|
123
|
-
|
125
|
+
result["success"] = False
|
126
|
+
result["path_created"] = None
|
127
|
+
if display_message:
|
128
|
+
alert_print(f"Directory:'{full_path}' already exists.")
|
124
129
|
|
125
130
|
except PermissionError:
|
126
|
-
result[
|
127
|
-
result[
|
128
|
-
alert_print(
|
131
|
+
result["success"] = False
|
132
|
+
result["path_created"] = None
|
133
|
+
alert_print(
|
134
|
+
f"Permission denied: Not possible to create Directory '{full_path}'."
|
135
|
+
)
|
129
136
|
|
130
137
|
except Exception as e:
|
131
|
-
result[
|
132
|
-
result[
|
133
|
-
error_print(
|
134
|
-
|
138
|
+
result["success"] = False
|
139
|
+
result["path_created"] = None
|
140
|
+
error_print(
|
141
|
+
f"Error capturing current path to create temporary directory! Error: {str(e)}"
|
142
|
+
)
|
143
|
+
|
135
144
|
finally:
|
136
145
|
return result
|
137
146
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
147
|
+
def delete_temp_dir(
|
148
|
+
self,
|
149
|
+
path_to_delete: str = "default",
|
150
|
+
name_temp_dir: str = "temp",
|
151
|
+
delete_files: bool = False,
|
152
|
+
display_message: bool = False,
|
153
|
+
) -> dict[str, Union[bool, str, None]]:
|
144
154
|
"""
|
145
155
|
Function responsible for deleting a temporary directory. \n
|
146
|
-
|
156
|
+
|
147
157
|
Parameters:
|
148
158
|
----------
|
149
159
|
``path_to_delete: str`` - should be a string with the full path pointing to the folder where the temporary folder should be deleted, if it is empty the ``default`` value will be used which will delete a folder in the current directory where the file containing this function was called.
|
@@ -157,7 +167,7 @@ class Directory():
|
|
157
167
|
>>> type:dict
|
158
168
|
* 'success': bool - represents case the action was performed successfully
|
159
169
|
* 'path_deleted': str - path of the directory that was deleted on the process
|
160
|
-
|
170
|
+
|
161
171
|
Description: pt-br
|
162
172
|
----------
|
163
173
|
Função responsavel por deletar diretório temporário. \n
|
@@ -179,13 +189,13 @@ class Directory():
|
|
179
189
|
|
180
190
|
# Local Variables
|
181
191
|
result: dict = {
|
182
|
-
|
183
|
-
|
192
|
+
"success": bool,
|
193
|
+
"path_deleted": str,
|
184
194
|
}
|
185
195
|
|
186
196
|
try:
|
187
197
|
# by 'default', defines path to local script execution path
|
188
|
-
if path_to_delete ==
|
198
|
+
if path_to_delete == "default":
|
189
199
|
path_to_delete: str = os.getcwd()
|
190
200
|
|
191
201
|
# Build path to new dir
|
@@ -206,24 +216,30 @@ class Directory():
|
|
206
216
|
# Delete the directory only
|
207
217
|
os.rmdir(full_path)
|
208
218
|
|
209
|
-
result[
|
210
|
-
result[
|
219
|
+
result["success"] = True
|
220
|
+
result["path_deleted"] = rf"{full_path}"
|
211
221
|
|
212
|
-
|
222
|
+
if display_message:
|
223
|
+
success_print(f"Directory:'{full_path}' successfully delete.")
|
213
224
|
else:
|
214
|
-
result[
|
215
|
-
result[
|
216
|
-
|
225
|
+
result["success"] = False
|
226
|
+
result["path_deleted"] = None
|
227
|
+
if display_message:
|
228
|
+
alert_print(f"Directory:'{full_path}' don't exists.")
|
217
229
|
|
218
230
|
except PermissionError:
|
219
|
-
result[
|
220
|
-
result[
|
221
|
-
alert_print(
|
231
|
+
result["success"] = False
|
232
|
+
result["path_deleted"] = None
|
233
|
+
alert_print(
|
234
|
+
f"Permission denied: Not possible to delete Directory '{full_path}'."
|
235
|
+
)
|
222
236
|
|
223
237
|
except Exception as e:
|
224
|
-
result[
|
225
|
-
result[
|
226
|
-
error_print(
|
227
|
-
|
238
|
+
result["success"] = False
|
239
|
+
result["path_deleted"] = None
|
240
|
+
error_print(
|
241
|
+
f"Error capturing current path to delete temporary directory! Error: {str(e)}"
|
242
|
+
)
|
243
|
+
|
228
244
|
finally:
|
229
245
|
return result
|
rpa_suite/core/email.py
CHANGED
@@ -12,20 +12,19 @@ from email.mime.base import MIMEBase
|
|
12
12
|
from email import encoders
|
13
13
|
|
14
14
|
|
15
|
-
class Email
|
16
|
-
|
15
|
+
class Email:
|
17
16
|
"""
|
18
17
|
Class that provides utilities for sending emails via SMTP protocol.
|
19
|
-
|
18
|
+
|
20
19
|
This class offers functionalities for:
|
21
20
|
- Sending emails with attachments
|
22
21
|
- HTML message formatting
|
23
22
|
- SMTP server configuration
|
24
23
|
- Email validation
|
25
|
-
|
24
|
+
|
26
25
|
Methods:
|
27
26
|
send_smtp: Sends an email through specified SMTP server
|
28
|
-
|
27
|
+
|
29
28
|
The Email class is part of RPA Suite and can be accessed through the rpa object:
|
30
29
|
>>> from rpa_suite import rpa
|
31
30
|
>>> rpa.email.send_smtp(
|
@@ -50,16 +49,16 @@ class Email():
|
|
50
49
|
pt-br
|
51
50
|
----------
|
52
51
|
Classe que fornece utilitários para envio de emails via protocolo SMTP.
|
53
|
-
|
52
|
+
|
54
53
|
Esta classe oferece funcionalidades para:
|
55
54
|
- Envio de emails com anexos
|
56
55
|
- Formatação de mensagens em HTML
|
57
56
|
- Configuração de servidor SMTP
|
58
57
|
- Validação de email
|
59
|
-
|
58
|
+
|
60
59
|
Métodos:
|
61
60
|
send_smtp: Envia um email através do servidor SMTP especificado
|
62
|
-
|
61
|
+
|
63
62
|
A classe Email é parte do RPA Suite e pode ser acessada através do objeto rpa:
|
64
63
|
>>> from rpa_suite import rpa
|
65
64
|
>>> rpa.email.send_smtp(
|
@@ -71,80 +70,76 @@ class Email():
|
|
71
70
|
... )
|
72
71
|
"""
|
73
72
|
|
73
|
+
smtp_server: str = ("smtp.hostinger.com",)
|
74
|
+
smtp_port: str = (465,)
|
75
|
+
email_user: str = ("your_email@email.com",)
|
76
|
+
email_password: str = ("password",)
|
77
|
+
email_to: str = ("to@email.com",)
|
78
|
+
attachments: list[str] = ([],)
|
79
|
+
subject_title: str = ("Test title",)
|
80
|
+
body_message: str = "<p>Testing message body</p>"
|
81
|
+
auth_tls: bool = (False,)
|
74
82
|
|
75
|
-
|
76
|
-
smtp_port:str = 465,
|
77
|
-
email_user:str = "your_email@email.com",
|
78
|
-
email_password:str = "password",
|
79
|
-
email_to: str = "to@email.com",
|
80
|
-
attachments: list[str] = [],
|
81
|
-
subject_title: str = 'Test title',
|
82
|
-
body_message: str = '<p>Testing message body</p>'
|
83
|
-
auth_tls: bool = False,
|
84
|
-
|
85
|
-
|
86
|
-
def __init__(self):
|
87
|
-
...
|
83
|
+
def __init__(self): ...
|
88
84
|
|
89
85
|
def send_smtp(
|
90
86
|
self,
|
91
|
-
email_user:str,
|
92
|
-
email_password:str,
|
87
|
+
email_user: str,
|
88
|
+
email_password: str,
|
93
89
|
email_to: str,
|
94
|
-
subject_title: str =
|
95
|
-
body_message: str =
|
90
|
+
subject_title: str = "Test title",
|
91
|
+
body_message: str = "<p>Testing message body</p>",
|
96
92
|
attachments: list[str] = [],
|
97
|
-
smtp_server:str = "smtp.hostinger.com",
|
98
|
-
smtp_port:str = 465,
|
93
|
+
smtp_server: str = "smtp.hostinger.com",
|
94
|
+
smtp_port: str = 465,
|
99
95
|
auth_tls: bool = False,
|
100
96
|
display_message: bool = True,
|
101
|
-
|
102
|
-
|
97
|
+
):
|
103
98
|
"""
|
104
99
|
Sends an email using the specified SMTP server.
|
105
100
|
|
106
101
|
Args:
|
107
|
-
smtp_server (str, optional): Address of the SMTP server.
|
102
|
+
smtp_server (str, optional): Address of the SMTP server.
|
108
103
|
Default: "smtp.hostinger.com".
|
109
|
-
smtp_port (str, optional): Port of the SMTP server.
|
104
|
+
smtp_port (str, optional): Port of the SMTP server.
|
110
105
|
Default: 465.
|
111
|
-
email_user (str, optional): User (email) for authentication on the SMTP server.
|
106
|
+
email_user (str, optional): User (email) for authentication on the SMTP server.
|
112
107
|
Default: "example@email.com".
|
113
|
-
email_password (str, optional): Password for authentication on the SMTP server.
|
108
|
+
email_password (str, optional): Password for authentication on the SMTP server.
|
114
109
|
Default: "example123".
|
115
|
-
email_to (str, optional): Email address of the recipient.
|
110
|
+
email_to (str, optional): Email address of the recipient.
|
116
111
|
Default: "person@email.com".
|
117
|
-
attachments (list[str], optional): List of file paths to attach to the email.
|
112
|
+
attachments (list[str], optional): List of file paths to attach to the email.
|
118
113
|
Default: [].
|
119
|
-
subject_title (str, optional): Title (subject) of the email.
|
114
|
+
subject_title (str, optional): Title (subject) of the email.
|
120
115
|
Default: 'test title'.
|
121
|
-
body_message (str, optional): Body of the email message, in HTML format.
|
116
|
+
body_message (str, optional): Body of the email message, in HTML format.
|
122
117
|
Default: '<p>test message</p>'.
|
123
118
|
|
124
119
|
Returns:
|
125
120
|
None: This function does not explicitly return any value, but prints success or failure messages when sending the email.
|
126
|
-
|
121
|
+
|
127
122
|
pt-br
|
128
123
|
------
|
129
|
-
|
124
|
+
|
130
125
|
Envia um email usando o servidor SMTP especificado.
|
131
126
|
|
132
127
|
Args:
|
133
|
-
smtp_server (str, opcional): Endereço do servidor SMTP.
|
128
|
+
smtp_server (str, opcional): Endereço do servidor SMTP.
|
134
129
|
Padrão: "smtp.hostinger.com".
|
135
|
-
smtp_port (str, opcional): Porta do servidor SMTP.
|
130
|
+
smtp_port (str, opcional): Porta do servidor SMTP.
|
136
131
|
Padrão: 465.
|
137
|
-
email_user (str, opcional): Usuário (email) para autenticação no servidor SMTP.
|
132
|
+
email_user (str, opcional): Usuário (email) para autenticação no servidor SMTP.
|
138
133
|
Padrão: "example@email.com".
|
139
|
-
email_password (str, opcional): Senha para autenticação no servidor SMTP.
|
134
|
+
email_password (str, opcional): Senha para autenticação no servidor SMTP.
|
140
135
|
Padrão: "example123".
|
141
|
-
email_to (str, opcional): Endereço de email do destinatário.
|
136
|
+
email_to (str, opcional): Endereço de email do destinatário.
|
142
137
|
Padrão: "person@email.com".
|
143
|
-
attachments (list[str], opcional): Lista de caminhos de arquivos para anexar ao email.
|
138
|
+
attachments (list[str], opcional): Lista de caminhos de arquivos para anexar ao email.
|
144
139
|
Padrão: [].
|
145
|
-
subject_title (str, opcional): Título (assunto) do email.
|
140
|
+
subject_title (str, opcional): Título (assunto) do email.
|
146
141
|
Padrão: 'título de teste'.
|
147
|
-
body_message (str, opcional): Corpo da mensagem do email, em formato HTML.
|
142
|
+
body_message (str, opcional): Corpo da mensagem do email, em formato HTML.
|
148
143
|
Padrão: '<p>mensagem de teste</p>'.
|
149
144
|
|
150
145
|
Returns:
|
@@ -164,13 +159,17 @@ class Email():
|
|
164
159
|
|
165
160
|
# Criando a mensagem
|
166
161
|
msg = MIMEMultipart()
|
167
|
-
msg[
|
168
|
-
msg[
|
169
|
-
|
162
|
+
msg["From"] = self.email_user
|
163
|
+
msg["To"] = (
|
164
|
+
", ".join(self.email_to)
|
165
|
+
if isinstance(self.email_to, list)
|
166
|
+
else self.email_to
|
167
|
+
)
|
168
|
+
msg["Subject"] = str(self.subject_title)
|
170
169
|
|
171
170
|
# Corpo do e-mail
|
172
171
|
body = str(self.body_message)
|
173
|
-
msg.attach(MIMEText(body,
|
172
|
+
msg.attach(MIMEText(body, "html"))
|
174
173
|
|
175
174
|
# Anexos (opcional)
|
176
175
|
if self.attachments:
|
@@ -191,7 +190,9 @@ class Email():
|
|
191
190
|
msg.attach(part)
|
192
191
|
|
193
192
|
except Exception as e:
|
194
|
-
error_print(
|
193
|
+
error_print(
|
194
|
+
f"Erro ao anexar o arquivo {attachment_path}: {str(e)}"
|
195
|
+
)
|
195
196
|
|
196
197
|
try:
|
197
198
|
if self.auth_tls:
|
@@ -206,7 +207,8 @@ class Email():
|
|
206
207
|
|
207
208
|
# Enviando o e-mail
|
208
209
|
server.sendmail(self.email_user, self.email_to, msg.as_string())
|
209
|
-
if display_message:
|
210
|
+
if display_message:
|
211
|
+
success_print("E-mail enviado com sucesso!")
|
210
212
|
|
211
213
|
# Encerrando a conexão
|
212
214
|
server.quit()
|