rpa-suite 1.5.3__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/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,14 +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',
62
- display_message: bool = False) -> dict[str, Union[bool, str, None]]:
54
+ def __init__(self): ...
63
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]]:
64
62
  """
65
63
  Function responsible for creating a temporary directory to work with files and etc. \n
66
64
 
@@ -77,7 +75,7 @@ class Directory():
77
75
  >>> type:dict
78
76
  * 'success': bool - represents case the action was performed successfully
79
77
  * 'path_created': str - path of the directory that was created on the process
80
-
78
+
81
79
  Description: pt-br
82
80
  ----------
83
81
  Função responsavel por criar diretório temporário para trabalhar com arquivos e etc. \n
@@ -96,16 +94,16 @@ class Directory():
96
94
  * 'success': bool - representa se ação foi realizada com sucesso
97
95
  * 'path_created': str - path do diretório que foi criado no processo
98
96
  """
99
-
97
+
100
98
  # Local Variables
101
99
  result: dict = {
102
- 'success': bool,
103
- 'path_created': str,
100
+ "success": bool,
101
+ "path_created": str,
104
102
  }
105
-
103
+
106
104
  try:
107
105
  # by 'default', defines path to local script execution path
108
- if path_to_create == 'default':
106
+ if path_to_create == "default":
109
107
  path_to_create: str = os.getcwd()
110
108
 
111
109
  # Build path to new dir
@@ -117,39 +115,45 @@ class Directory():
117
115
  # Successefully created
118
116
  os.makedirs(full_path, exist_ok=False)
119
117
 
120
- result['success'] = True
121
- result['path_created'] = fr'{full_path}'
118
+ result["success"] = True
119
+ result["path_created"] = rf"{full_path}"
122
120
 
123
- if display_message: success_print(f"Directory:'{full_path}' successfully created.")
121
+ if display_message:
122
+ success_print(f"Directory:'{full_path}' successfully created.")
124
123
 
125
124
  except FileExistsError:
126
- result['success'] = False
127
- result['path_created'] = None
128
- if display_message: alert_print(f"Directory:'{full_path}' already exists.")
125
+ result["success"] = False
126
+ result["path_created"] = None
127
+ if display_message:
128
+ alert_print(f"Directory:'{full_path}' already exists.")
129
129
 
130
130
  except PermissionError:
131
- result['success'] = False
132
- result['path_created'] = None
133
- alert_print(f"Permission denied: Not possible to create Directory '{full_path}'.")
131
+ result["success"] = False
132
+ result["path_created"] = None
133
+ alert_print(
134
+ f"Permission denied: Not possible to create Directory '{full_path}'."
135
+ )
134
136
 
135
137
  except Exception as e:
136
- result['success'] = False
137
- result['path_created'] = None
138
- error_print(f'Error capturing current path to create temporary directory! Error: {str(e)}')
139
-
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
+
140
144
  finally:
141
145
  return result
142
146
 
143
-
144
- def delete_temp_dir(self,
145
- path_to_delete: str = 'default',
146
- name_temp_dir: str='temp',
147
- delete_files: bool = False,
148
- display_message: bool = False) -> dict[str, Union[bool, str, None]]:
149
-
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]]:
150
154
  """
151
155
  Function responsible for deleting a temporary directory. \n
152
-
156
+
153
157
  Parameters:
154
158
  ----------
155
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.
@@ -163,7 +167,7 @@ class Directory():
163
167
  >>> type:dict
164
168
  * 'success': bool - represents case the action was performed successfully
165
169
  * 'path_deleted': str - path of the directory that was deleted on the process
166
-
170
+
167
171
  Description: pt-br
168
172
  ----------
169
173
  Função responsavel por deletar diretório temporário. \n
@@ -185,13 +189,13 @@ class Directory():
185
189
 
186
190
  # Local Variables
187
191
  result: dict = {
188
- 'success': bool,
189
- 'path_deleted': str,
192
+ "success": bool,
193
+ "path_deleted": str,
190
194
  }
191
195
 
192
196
  try:
193
197
  # by 'default', defines path to local script execution path
194
- if path_to_delete == 'default':
198
+ if path_to_delete == "default":
195
199
  path_to_delete: str = os.getcwd()
196
200
 
197
201
  # Build path to new dir
@@ -212,24 +216,30 @@ class Directory():
212
216
  # Delete the directory only
213
217
  os.rmdir(full_path)
214
218
 
215
- result['success'] = True
216
- result['path_deleted'] = fr'{full_path}'
219
+ result["success"] = True
220
+ result["path_deleted"] = rf"{full_path}"
217
221
 
218
- if display_message: success_print(f"Directory:'{full_path}' successfully delete.")
222
+ if display_message:
223
+ success_print(f"Directory:'{full_path}' successfully delete.")
219
224
  else:
220
- result['success'] = False
221
- result['path_deleted'] = None
222
- if display_message: alert_print(f"Directory:'{full_path}' don't exists.")
225
+ result["success"] = False
226
+ result["path_deleted"] = None
227
+ if display_message:
228
+ alert_print(f"Directory:'{full_path}' don't exists.")
223
229
 
224
230
  except PermissionError:
225
- result['success'] = False
226
- result['path_deleted'] = None
227
- alert_print(f"Permission denied: Not possible to delete Directory '{full_path}'.")
231
+ result["success"] = False
232
+ result["path_deleted"] = None
233
+ alert_print(
234
+ f"Permission denied: Not possible to delete Directory '{full_path}'."
235
+ )
228
236
 
229
237
  except Exception as e:
230
- result['success'] = False
231
- result['path_deleted'] = None
232
- error_print(f'Error capturing current path to delete temporary directory! Error: {str(e)}')
233
-
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
+
234
244
  finally:
235
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
- smtp_server:str = "smtp.hostinger.com",
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 = 'Test title',
95
- body_message: str = '<p>Testing message body</p>',
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['From'] = self.email_user
168
- msg['To'] = ', '.join(self.email_to) if isinstance(self.email_to, list) else self.email_to
169
- msg['Subject'] = str(self.subject_title)
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, 'html'))
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(f"Erro ao anexar o arquivo {attachment_path}: {str(e)}")
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: success_print("E-mail enviado com sucesso!")
210
+ if display_message:
211
+ success_print("E-mail enviado com sucesso!")
210
212
 
211
213
  # Encerrando a conexão
212
214
  server.quit()