rpa-suite 1.3.4__py3-none-any.whl → 1.3.5__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.
Files changed (48) hide show
  1. rpa_suite/__init__.py +4 -1
  2. rpa_suite/core/__init__.py +1 -0
  3. rpa_suite/core/clock.py +271 -0
  4. rpa_suite/core/date.py +138 -0
  5. rpa_suite/core/dir.py +182 -0
  6. rpa_suite/core/email.py +343 -0
  7. rpa_suite/core/file.py +209 -0
  8. rpa_suite/core/log.py +304 -0
  9. rpa_suite/core/print.py +197 -0
  10. rpa_suite/core/regex.py +62 -0
  11. rpa_suite/core/validate.py +220 -0
  12. rpa_suite/{log → functions}/__create_log_dir.py +5 -7
  13. rpa_suite/{file → functions}/__create_ss_dir.py +2 -2
  14. rpa_suite/functions/__init__.py +1 -0
  15. rpa_suite/{log → functions}/_functions_logger.py +8 -8
  16. rpa_suite/{log → functions}/_logger.py +3 -3
  17. rpa_suite/suite.py +238 -148
  18. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.5.dist-info}/METADATA +7 -4
  19. rpa_suite-1.3.5.dist-info/RECORD +25 -0
  20. rpa_suite/clock/__init__.py +0 -1
  21. rpa_suite/clock/exec_at.py +0 -133
  22. rpa_suite/clock/scheduler.py +0 -38
  23. rpa_suite/clock/waiter.py +0 -139
  24. rpa_suite/date/__init__.py +0 -1
  25. rpa_suite/date/date.py +0 -124
  26. rpa_suite/email/__init__.py +0 -1
  27. rpa_suite/email/sender_smtp.py +0 -203
  28. rpa_suite/file/__init__.py +0 -1
  29. rpa_suite/file/counter.py +0 -69
  30. rpa_suite/file/file_flag.py +0 -103
  31. rpa_suite/file/screen_shot.py +0 -91
  32. rpa_suite/file/temp_dir.py +0 -176
  33. rpa_suite/log/__init__.py +0 -1
  34. rpa_suite/log/functions_logger_uru.py +0 -172
  35. rpa_suite/log/log_decorator.py +0 -37
  36. rpa_suite/log/logger_uru.py +0 -110
  37. rpa_suite/regex/__init__.py +0 -1
  38. rpa_suite/regex/pattern_in_text.py +0 -58
  39. rpa_suite/validate/__init__.py +0 -1
  40. rpa_suite/validate/mail_validator.py +0 -93
  41. rpa_suite/validate/string_validator.py +0 -120
  42. rpa_suite-1.3.4.dist-info/RECORD +0 -36
  43. /rpa_suite/{log/printer.py → functions/_printer.py} +0 -0
  44. /rpa_suite/{log → functions}/_variables.py +0 -0
  45. /rpa_suite/{log → functions}/_variables_uru.py +0 -0
  46. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.5.dist-info}/WHEEL +0 -0
  47. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.5.dist-info}/licenses/LICENSE +0 -0
  48. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,343 @@
1
+ # /sender_smtp.py
2
+
3
+ import smtplib, os
4
+ from email.mime.image import MIMEImage
5
+ from email.mime.multipart import MIMEMultipart
6
+ from email.mime.text import MIMEText
7
+ from email.mime.base import MIMEBase
8
+ from email import encoders
9
+ from rpa_suite.functions._printer import alert_print, error_print, success_print
10
+ from rpa_suite.core.validate import email_validator
11
+
12
+
13
+ """
14
+ smtp_server:str = "smtp.hostinger.com",
15
+ smtp_port:str = 465,
16
+ email_user:str = "bot@vettracode.com",
17
+ email_password:str = "Bot@#2025",
18
+ email_to: str = "camilo.costa1993@gmail.com",
19
+ attachments: list[str] = [],
20
+ subject_title: str = 'titulo teste',
21
+ body_message: str = '<p>mensagem de teste</p>'
22
+ """
23
+
24
+ class Email():
25
+
26
+ smtp_server:str = "smtp.hostinger.com",
27
+ smtp_port:str = 465,
28
+ email_user:str = "your_email@email.com",
29
+ email_password:str = "password",
30
+ email_to: str = "to@email.com",
31
+ attachments: list[str] = [],
32
+ subject_title: str = 'Test title',
33
+ body_message: str = '<p>Testing message body</p>'
34
+ auth_tls: bool = False,
35
+
36
+ def __init__(self):
37
+ ...
38
+
39
+ def send_smtp(
40
+ self,
41
+ email_user:str,
42
+ email_password:str,
43
+ email_to: str,
44
+ subject_title: str = 'Test title',
45
+ body_message: str = '<p>Testing message body</p>',
46
+ attachments: list[str] = [],
47
+ smtp_server:str = "smtp.hostinger.com",
48
+ smtp_port:str = 465,
49
+ auth_tls: bool = False,
50
+ display_message: bool = True,
51
+ ):
52
+
53
+ """
54
+ Envia um e-mail utilizando o servidor SMTP especificado.
55
+
56
+ Args:
57
+ smtp_server (str, optional): Endereço do servidor SMTP.
58
+ Padrão: "smtp.hostinger.com".
59
+ smtp_port (str, optional): Porta do servidor SMTP.
60
+ Padrão: 465.
61
+ email_user (str, optional): Usuário (e-mail) para autenticação no servidor SMTP.
62
+ Padrão: "bot@vettracode.com".
63
+ email_password (str, optional): Senha para autenticação no servidor SMTP.
64
+ Padrão: "Bot@#2025".
65
+ email_to (str, optional): Endereço de e-mail do destinatário.
66
+ Padrão: "camilo.costa1993@gmail.com".
67
+ attachments (list[str], optional): Lista de caminhos de arquivos para anexar ao e-mail.
68
+ Padrão: [].
69
+ subject_title (str, optional): Título (assunto) do e-mail.
70
+ Padrão: 'titulo teste'.
71
+ body_message (str, optional): Corpo da mensagem do e-mail, em formato HTML.
72
+ Padrão: '<p>mensagem de teste</p>'.
73
+
74
+ Returns:
75
+ None: Esta função não retorna nenhum valor explicitamente, mas imprime mensagens de sucesso ou falha no envio do e-mail.
76
+ """
77
+
78
+ try:
79
+ self.smtp_server = smtp_server
80
+ self.smtp_port = smtp_port
81
+ self.email_user = email_user
82
+ self.email_password = email_password
83
+ self.email_to = email_to
84
+ self.subject_title = subject_title
85
+ self.body_message = body_message
86
+ self.attachments = attachments
87
+ self.auth_tls = auth_tls
88
+
89
+ # Criando a mensagem
90
+ msg = MIMEMultipart()
91
+ msg['From'] = self.email_user
92
+ msg['To'] = ', '.join(self.email_to) if isinstance(self.email_to, list) else self.email_to
93
+ msg['Subject'] = str(self.subject_title)
94
+
95
+ # Corpo do e-mail
96
+ body = str(self.body_message)
97
+ msg.attach(MIMEText(body, 'html'))
98
+
99
+ # Anexos (opcional)
100
+ if self.attachments:
101
+ from email.mime.base import MIMEBase
102
+ from email import encoders
103
+ import os
104
+
105
+ for attachment_path in self.attachments:
106
+ try:
107
+ with open(attachment_path, "rb") as attachment:
108
+ part = MIMEBase("application", "octet-stream")
109
+ part.set_payload(attachment.read())
110
+ encoders.encode_base64(part)
111
+ part.add_header(
112
+ "Content-Disposition",
113
+ f"attachment; filename= {os.path.basename(attachment_path)}",
114
+ )
115
+ msg.attach(part)
116
+
117
+ except Exception as e:
118
+ error_print(f"Erro ao anexar o arquivo {attachment_path}: {str(e)}")
119
+
120
+ try:
121
+ if self.auth_tls:
122
+ # Conectando ao servidor SMTP com TLS
123
+ server = smtplib.SMTP(self.smtp_server, self.smtp_port)
124
+ server.starttls()
125
+ server.login(self.email_user, self.email_password)
126
+ else:
127
+ # Conectando ao servidor SMTP com SSL
128
+ server = smtplib.SMTP_SSL(self.smtp_server, self.smtp_port)
129
+ server.login(self.email_user, self.email_password)
130
+
131
+ # Enviando o e-mail
132
+ server.sendmail(self.email_user, self.email_to, msg.as_string())
133
+ if display_message: success_print("E-mail enviado com sucesso!")
134
+
135
+ # Encerrando a conexão
136
+ server.quit()
137
+
138
+ except Exception as e:
139
+ alert_print(f"Falha ao enviar o e-mail: {str(e)}")
140
+
141
+ except Exception as e:
142
+ error_print(f"Ocorreu um erro geral na função sendmail: {str(e)}")
143
+
144
+
145
+
146
+ def send_by_smtp( self,
147
+ email_from: str,
148
+ pass_from: str,
149
+ email_to: list[str],
150
+ subject_title: str,
151
+ body_message: str,
152
+ image_footer: str = None,
153
+ attachments: list[str] = None,
154
+ type_content: str = 'html',
155
+ smtp_server: str = 'smtp.office365.com',
156
+ smtp_port: int = 587,
157
+ authentication_tls: bool = True,
158
+ display_message: bool = True,
159
+ ) -> dict:
160
+
161
+ """
162
+ Function responsible for sending emails ``(SMTP)``, accepts ``list of recipients`` and possibility
163
+ of ``attaching files``. \n
164
+
165
+ Parameters:
166
+ ----------
167
+ ``email_from: str`` - email from who will send the email.
168
+ ``pass_from: str`` - password of the account used, advised to isolate the password elsewhere.
169
+ ``email_to: list[str]`` - list of emails to which the emails will be sent.
170
+ ``subject_title: str`` - email title.
171
+ ``body_message: str``- body message of the email.
172
+ ``image_footer: str`` - image footer of body message of the email.
173
+ ``attachments: list[str]`` - list with path of attachments if any. (default None).
174
+ ``type_content: str`` - type of message content can be 'plain' or 'html' (default 'html').
175
+ ``smtp_server: str`` - server to be used to connect with the email account (default 'smtp.office365.com')
176
+ ``smtp_port: int`` - port to be used on this server (default 587 - TLS), commum use 465 for SSL authentication
177
+ ``authentication_tls: bool`` - authentication method (default True), if False use SSL authentication
178
+
179
+ Return:
180
+ ----------
181
+ >>> type:dict
182
+ a dictionary with all information that may be necessary about the emails.
183
+ Respectively being:
184
+ * 'success': bool - if there was at least one successful shipment
185
+ * 'all_mails': list - list of all emails parameterized for sending
186
+ * 'valid_mails': list - list of all valid emails for sending
187
+ * 'invalid_mails': list - list of all invalid emails for sending
188
+ * 'qt_mails_sent': int - effective quantity that was sent
189
+ * 'attchament': bool - if there are attachments
190
+ * 'qt_attach': int - how many attachments were inserted
191
+
192
+ Description: pt-br
193
+ ----------
194
+ Função responsavel por enviar emails ``(SMTP)``, aceita ``lista de destinatários`` e possibilidade
195
+ de ``anexar arquivos``. \n
196
+
197
+ Parametros:
198
+ ----------
199
+ ``email_from: str`` - email de quem ira enviar o email.
200
+ ``pass_from: str`` - senha da conta utilizada, aconselhado isolar a senha em outro local.
201
+ ``email_to: list[str]`` - lista de emails para os quais serão enviados os emails.
202
+ ``subject_title: str`` - titulo do email.
203
+ ``body_message: str``- mensagem do corpo do email.
204
+ ``image_footer: str`` - imagem de rodapé do corpo do email.
205
+ ``attachments: list[str]`` - lista com caminho de anexos se houver. (default None).
206
+ ``type_content: str`` - tipo de conteudo da mensagem pode ser 'plain' ou 'html' (default 'html').
207
+ ``smtp_server: str`` - servidor a ser utilizado para conectar com a conta de email (default 'smtp.office365.com')
208
+ ``smtp_port: int`` - porta a ser utilizada nesse servidor (default 587 - TLS), comum usar 465 para autenticação por SSL
209
+ ``authentication_tls: bool`` - metódo de autenticação (default True), caso Falso usa autenticação por SSL
210
+
211
+ Retorno:
212
+ ----------
213
+ >>> type:dict
214
+ um dicionário com todas informações que podem ser necessarias sobre os emails.
215
+ Sendo respectivamente:
216
+ * 'success': bool - se houve pelo menos um envio com sucesso
217
+ * 'all_mails': list - lista de todos emails parametrizados para envio
218
+ * 'valid_mails': list - lista de todos emails validos para envio
219
+ * 'invalid_mails': list - lista de todos emails invalidos para envio
220
+ * 'qt_mails_sent': int - quantidade efetiva que foi realizado envio
221
+ * 'attchament': bool - se há anexos
222
+ * 'qt_attach': int - quantos anexos foram inseridos
223
+ """
224
+
225
+ try:
226
+ # Local Variables
227
+ result: dict = {
228
+ 'success': bool,
229
+ 'all_mails': list,
230
+ 'valid_mails': list,
231
+ 'invalid_mails': list,
232
+ 'qt_mails_sent': int,
233
+ 'attchament': bool,
234
+ 'qt_attach': int
235
+ }
236
+ email_valido = []
237
+ email_invalido = []
238
+
239
+ # Preprocessing
240
+ result['success'] = False
241
+ result['qt_mails_sent'] = 0
242
+ result['attchament'] = False
243
+
244
+ msg = MIMEMultipart()
245
+ msg['From'] = email_from
246
+ msg['Subject'] = subject_title
247
+
248
+ # Email Body Content
249
+ msg.attach(MIMEText(body_message, type_content))
250
+
251
+ # Add image Footer
252
+ if image_footer:
253
+ try:
254
+ with open(image_footer, 'rb') as img:
255
+ msg_image = MIMEImage(img.read())
256
+ msg_image.add_header('Content-ID', '<logo>')
257
+ # Notice: Content-ID correlact at "cid" on tag <img> at body mail
258
+ msg.attach(msg_image)
259
+ except FileNotFoundError as e:
260
+ alert_print(f'File Not Found! Error: {str(e)}')
261
+ except Exception as e:
262
+ error_print(f'An Error ocurred, during set image: <{image_footer}> as MIMEImage! Error: {str(e)}')
263
+
264
+ # Add Attachment
265
+ if attachments:
266
+ result['qt_attach'] = 0
267
+ result['attchament'] = True
268
+ for path_to_attach in attachments:
269
+ file_name = os.path.basename(path_to_attach)
270
+ attachs = open(path_to_attach, 'rb')
271
+ part = MIMEBase('application', 'octet-stream')
272
+ part.set_payload((attachs).read())
273
+ encoders.encode_base64(part)
274
+ part.add_header('Content-Disposition', "attachment; filename= %s" % file_name)
275
+ msg.attach(part)
276
+ result['qt_attach'] += 1
277
+ else:
278
+ result['attchament'] = False
279
+ result['qt_attach'] = 0
280
+
281
+ # SMTP server config
282
+ try:
283
+
284
+ # authentication TLS False -> Using SSL authentication
285
+ if authentication_tls:
286
+
287
+ server_by_smtp = smtplib.SMTP(smtp_server, smtp_port)
288
+ server_by_smtp.starttls()
289
+ server_by_smtp.login(email_from, pass_from)
290
+ email_content = msg.as_string()
291
+
292
+ else: # auth with SSL
293
+
294
+ # Conexão com o servidor SMTP usando SSL
295
+ server_by_smtp = smtplib.SMTP_SSL(smtp_server, smtp_port)
296
+ server_by_smtp.login(email_from, pass_from)
297
+ email_content = msg.as_string()
298
+
299
+ # Treats the email list before trying to send, keeping only valid emails
300
+ try:
301
+ for emails in email_to:
302
+ try:
303
+ v = email_validator.validate_email(emails)
304
+ email_valido.append(emails)
305
+
306
+ except email_validator.EmailNotValidError:
307
+ email_invalido.append(emails)
308
+
309
+ except Exception as e:
310
+ error_print(f'Error while trying to validate email list: {str(e)}')
311
+
312
+ # Attaches the treated email list to perform the sending
313
+ msg['To'] = ', '.join(email_valido)
314
+ for email in email_valido:
315
+ try:
316
+ server_by_smtp.sendmail(email_from, email, email_content)
317
+ result['qt_mails_sent'] += 1
318
+ result['all_mails'] = email_to
319
+
320
+ except smtplib.SMTPException as e:
321
+ error_print(f"The email: {email} don't sent, caused by error: {str(e)}")
322
+
323
+ #server_by_smtp.quit()
324
+ result['success'] = True
325
+ if display_message: success_print(f'Email(s) Sent!')
326
+
327
+
328
+ except smtplib.SMTPException as e:
329
+ result['success'] = False
330
+ error_print(f'Error while trying sent Email: {str(e)}')
331
+
332
+ finally:
333
+ server_by_smtp.quit()
334
+
335
+ # Postprocessing
336
+ result['valid_mails'] = email_valido
337
+ result['invalid_mails'] = email_invalido
338
+
339
+ return result
340
+
341
+ except Exception as e:
342
+ error_print(f'Error function: {self.send_email.__name__}! Error: {str(e)}.')
343
+ return None
rpa_suite/core/file.py ADDED
@@ -0,0 +1,209 @@
1
+ import os, time
2
+ from datetime import datetime
3
+ from rpa_suite.functions._printer import error_print, success_print, alert_print
4
+ from rpa_suite.functions.__create_ss_dir import __create_ss_dir as create_ss_dir
5
+ from colorama import Fore
6
+ from typing import Dict, List, Union
7
+
8
+ class File():
9
+
10
+ def __init__(self):
11
+ self.__create_ss_dir = create_ss_dir
12
+
13
+ def screen_shot(self,
14
+ file_name: str = 'screenshot',
15
+ path_dir:str = None,
16
+ save_with_date: bool = True,
17
+ delay: int = 1,
18
+ use_default_path_and_name: bool = True,
19
+ name_ss_dir:str = None,
20
+ display_message: bool = False) -> str | None:
21
+
22
+ """
23
+ Function responsible for create a dir for screenshot, and file screenshot and save this in dir to create, if dir exists save it on original dir. By default uses date on file name. \n
24
+
25
+ Parameters:
26
+ ----------
27
+ ``file_path: str`` - should be a string, not have a default path.
28
+ ``file_name: str`` - should be a string, by default name is `screenshot`.
29
+ ``save_with_date: bool`` - should be a boolean, by default `True` save namefile with date `foo_dd_mm_yyyy-hh_mm_ss.png`.
30
+ ``delay: int`` - should be a int, by default 1 (represents seconds).
31
+
32
+ Return:
33
+ ----------
34
+ >>> type:str
35
+ * 'screenshot_path': str - represents the absulute path created for this file
36
+
37
+ Description: pt-br
38
+ ----------
39
+ Função responsável por criar um diretório para captura de tela, e arquivo de captura de tela e salvar isso no diretório a ser criado, se o diretório existir, salve-o no diretório original. Por padrão, usa a data no nome do arquivo.
40
+
41
+ Parâmetros:
42
+ ----------
43
+ ``file_path: str`` - deve ser uma string, não tem um caminho padrão.
44
+ ``file_name: str`` - deve ser uma string, por padrão o nome é `screenshot`.
45
+ ``save_with_date: bool`` - deve ser um booleano, por padrão `True` salva o nome do arquivo com a data `foo_dd_mm_yyyy-hh_mm_ss.png`.
46
+ ``delay: int`` - deve ser um int, por padrão 1 representado em segundo(s).
47
+
48
+ Retorno:
49
+ ----------
50
+ >>> tipo: str
51
+ * 'screenshot_path': str - representa o caminho absoluto do arquivo criado
52
+ """
53
+
54
+ # proccess
55
+ try:
56
+
57
+ try:
58
+ import pyautogui
59
+ import pyscreeze
60
+
61
+ except ImportError:
62
+ raise ImportError(f"\nThe 'pyautogui' e 'Pillow' libraries are necessary to use this module. {Fore.YELLOW}Please install them with: 'pip install pyautogui pillow'{Fore.WHITE}")
63
+
64
+ time.sleep(delay)
65
+
66
+ if not use_default_path_and_name:
67
+ result_tryed: dict = self.__create_ss_dir(path_dir, name_ss_dir)
68
+ path_dir = result_tryed['path_created']
69
+ else:
70
+ result_tryed: dict = self.__create_ss_dir()
71
+ path_dir = result_tryed['path_created']
72
+
73
+
74
+ if save_with_date: # use date on file name
75
+ image = pyautogui.screenshot()
76
+ file_name = f'{file_name}_{datetime.today().strftime("%d_%m_%Y-%H_%M_%S")}.png'
77
+ path_file_screenshoted = os.path.join(path_dir, file_name)
78
+
79
+ image.save(path_file_screenshoted)
80
+
81
+ if display_message: success_print(path_file_screenshoted)
82
+
83
+ return path_file_screenshoted
84
+
85
+ else: # not use date on file name
86
+ image = pyautogui.screenshot()
87
+ file_name = f'{file_name}.png'
88
+ path_file_screenshoted = os.path.join(path_dir, file_name)
89
+
90
+ image.save(path_file_screenshoted)
91
+
92
+ if display_message: success_print(path_file_screenshoted)
93
+
94
+ return path_file_screenshoted
95
+
96
+ except Exception as e:
97
+
98
+ error_print(f'Error to execute function:{self.screen_shot.__name__}! Error: {str(e)}')
99
+ return None
100
+
101
+
102
+ def flag_create(self,
103
+ name_file: str = 'running.flag',
104
+ path_to_create: str = None,
105
+ display_message: bool = True) -> None:
106
+ """
107
+ Cria um arquivo de sinalização indicando que o robô está em execução.
108
+ """
109
+
110
+ try:
111
+ if path_to_create == None:
112
+ path_origin: str = os.getcwd()
113
+ full_path_with_name = fr'{path_origin}/{name_file}'
114
+ else:
115
+ full_path_with_name = fr'{path_to_create}/{name_file}'
116
+
117
+ with open(full_path_with_name, 'w', encoding='utf-8') as file:
118
+ file.write('[T-BOT Crédit Simulation] running in realtime, waiting finish to new execution')
119
+ if display_message: success_print("Flag file created.")
120
+
121
+ except Exception as e:
122
+ error_print(f'Erro na função file_scheduling_create: {str(e)}')
123
+
124
+
125
+ def flag_delete(self,
126
+ name_file: str = 'running.flag',
127
+ path_to_delete: str = None,
128
+ display_message: bool = True,) -> None:
129
+
130
+ """
131
+ Deleta o arquivo de sinalização indicando que o robô terminou a execução.
132
+ """
133
+
134
+ try:
135
+
136
+ if path_to_delete == None:
137
+ path_origin: str = os.getcwd()
138
+ full_path_with_name = fr'{path_origin}/{name_file}'
139
+ else:
140
+ full_path_with_name = fr'{path_to_delete}/{name_file}'
141
+
142
+ if os.path.exists(full_path_with_name):
143
+ os.remove(full_path_with_name)
144
+ if display_message: success_print("Flag file deleted.")
145
+ else:
146
+ alert_print("Flag file not found.")
147
+
148
+ except Exception as e:
149
+ error_print(f'Erro na função file_scheduling_delete: {str(e)}')
150
+ time.sleep(1)
151
+
152
+ def count_files(self,
153
+ dir_to_count: List[str] = ['.'],
154
+ type_extension: str = '*',
155
+ display_message: bool = False,) -> Dict[str, Union[bool, int]]:
156
+
157
+ """
158
+ Function responsible for counting files within a folder, considers subfolders to do the count, searches by file type, being all files by default. \n
159
+
160
+ Parameters:
161
+ ----------
162
+ ``dir_to_count: list`` - should be a list, accepts more than one path to count files.
163
+ ``type_extension: str`` - should be a string with the format/extension of the type of file you want to be searched for counting, if empty by default will be used ``*`` which will count all files.
164
+
165
+ Return:
166
+ ----------
167
+ >>> type:dict
168
+ * 'success': bool - represents if the action was performed successfully
169
+ * 'qt': int - number that represents the quantity of files that were counted
170
+
171
+ Description: pt-br
172
+ ----------
173
+ Função responsavel por fazer a contagem de arquivos dentro de uma pasta, considera subpastas para fazer a contagem, busca por tipo de arquivo, sendo todos arquivos por default. \n
174
+
175
+ Parametros:
176
+ ----------
177
+ ``dir_to_count: list`` - deve ser uma lista, aceita mais de um caminho para contar arquivos.
178
+ ``type_extension: str`` - deve ser uma string com o formato/extensão do tipo de arquivo que deseja ser buscado para contagem, se vazio por default sera usado ``*`` que contará todos arquivos.
179
+
180
+ Retorno:
181
+ ----------
182
+ >>> type:dict
183
+ * 'success': bool - representa se ação foi realizada com sucesso
184
+ * 'qt': int - numero que representa a quantidade de arquivos que foram contados
185
+ """
186
+
187
+ # Local Variables
188
+ result: dict = {
189
+ 'success': False,
190
+ 'qt': 0
191
+ }
192
+
193
+ # Process
194
+ try:
195
+ for dir in dir_to_count:
196
+ for current_dir, sub_dir, files in os.walk(dir):
197
+ for file in files:
198
+ if type_extension == '*' or file.endswith(f'.{type_extension}'):
199
+ result['qt'] += 1
200
+ result['success'] = True
201
+
202
+ if display_message: success_print(f'Function: {self.count_files.__name__} counted {result["qt"]} files.')
203
+
204
+ except Exception as e:
205
+ result['success'] = False
206
+ error_print(f'Error when trying to count files! Error: {str(e)}')
207
+
208
+ finally:
209
+ return result