rpa-suite 1.3.4__py3-none-any.whl → 1.3.6__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.6.dist-info}/METADATA +7 -4
  19. rpa_suite-1.3.6.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.6.dist-info}/WHEEL +0 -0
  47. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.6.dist-info}/licenses/LICENSE +0 -0
  48. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.6.dist-info}/top_level.txt +0 -0
@@ -1,91 +0,0 @@
1
- # /screen_shot.py
2
-
3
- import os, time
4
- from datetime import datetime
5
- from rpa_suite.log.printer import error_print, success_print
6
- from .__create_ss_dir import __create_ss_dir
7
- from colorama import Fore
8
-
9
-
10
-
11
- def screen_shot(path_dir:str = None, file_name: str = 'screenshot', save_with_date: bool = True, delay: int = 1, use_default_path_and_name: bool = True, name_ss_dir:str = None, display_message: bool = False) -> str | None:
12
-
13
- """
14
- 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
15
-
16
- Parameters:
17
- ----------
18
- ``file_path: str`` - should be a string, not have a default path.
19
- ``file_name: str`` - should be a string, by default name is `screenshot`.
20
- ``save_with_date: bool`` - should be a boolean, by default `True` save namefile with date `foo_dd_mm_yyyy-hh_mm_ss.png`.
21
- ``delay: int`` - should be a int, by default 1 (represents seconds).
22
-
23
- Return:
24
- ----------
25
- >>> type:str
26
- * 'screenshot_path': str - represents the absulute path created for this file
27
-
28
- Description: pt-br
29
- ----------
30
- 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.
31
-
32
- Parâmetros:
33
- ----------
34
- ``file_path: str`` - deve ser uma string, não tem um caminho padrão.
35
- ``file_name: str`` - deve ser uma string, por padrão o nome é `screenshot`.
36
- ``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`.
37
- ``delay: int`` - deve ser um int, por padrão 1 representado em segundo(s).
38
-
39
- Retorno:
40
- ----------
41
- >>> tipo: str
42
- * 'screenshot_path': str - representa o caminho absoluto do arquivo criado
43
- """
44
-
45
- # proccess
46
- try:
47
-
48
- try:
49
- import pyautogui
50
- import pyscreeze
51
-
52
- except ImportError:
53
- raise ImportError(f"\nThe libraries ‘pyautogui’ and ‘Pillow’ are necessary to use this module. {Fore.YELLOW}Please install them with: ‘pip install pyautogui pillow‘{Fore.WHITE}")
54
-
55
- time.sleep(delay)
56
-
57
- if not use_default_path_and_name:
58
- result_tryed: dict = __create_ss_dir(path_dir, name_ss_dir)
59
- path_dir = result_tryed['path_created']
60
- else:
61
- if path_dir == None and name_ss_dir == None:
62
- result_tryed: dict = __create_ss_dir()
63
- path_dir = result_tryed['path_created']
64
-
65
-
66
- if save_with_date: # use date on file name
67
- image = pyautogui.screenshot()
68
- file_name = f'{file_name}_{datetime.today().strftime("%d_%m_%Y-%H_%M_%S")}.png'
69
- path_file_screenshoted = os.path.join(path_dir, file_name)
70
-
71
- image.save(path_file_screenshoted)
72
- if display_message:
73
- success_print(path_file_screenshoted)
74
-
75
- return path_file_screenshoted
76
-
77
- else: # not use date on file name
78
- image = pyautogui.screenshot()
79
- file_name = f'{file_name}.png'
80
- path_file_screenshoted = os.path.join(path_dir, file_name)
81
-
82
- image.save(path_file_screenshoted)
83
- if display_message:
84
- success_print(path_file_screenshoted)
85
-
86
- return path_file_screenshoted
87
-
88
- except Exception as e:
89
-
90
- error_print(f'Error to execute function:{screen_shot.__name__}! Error: {str(e)}')
91
- return None
@@ -1,176 +0,0 @@
1
- # /temp_dir.py
2
-
3
- import os, shutil
4
- from typing import Union
5
- from rpa_suite.log.printer import error_print, alert_print, success_print
6
-
7
-
8
- def create_temp_dir(path_to_create: str = 'default', name_temp_dir: str='temp', display_message: bool = False) -> dict[str, Union[bool, str, None]]:
9
-
10
- """
11
- Function responsible for creating a temporary directory to work with files and etc. \n
12
-
13
- Parameters:
14
- ----------
15
- ``path_to_create: str`` - should be a string with the full path pointing to the folder where the temporary 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.
16
-
17
- ``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.
18
-
19
- Return:
20
- ----------
21
- >>> type:dict
22
- * 'success': bool - represents case the action was performed successfully
23
- * 'path_created': str - path of the directory that was created on the process
24
-
25
- Description: pt-br
26
- ----------
27
- Função responsavel por criar diretório temporário para trabalhar com arquivos e etc. \n
28
-
29
- Parametros:
30
- ----------
31
- ``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.
32
-
33
- ``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.
34
-
35
- Retorno:
36
- ----------
37
- >>> type:dict
38
- * 'success': bool - representa se ação foi realizada com sucesso
39
- * 'path_created': str - path do diretório que foi criado no processo
40
- """
41
-
42
- # Local Variables
43
- result: dict = {
44
- 'success': bool,
45
- 'path_created': str,
46
- }
47
-
48
- try:
49
- # by 'default', defines path to local script execution path
50
- if path_to_create == 'default':
51
- path_to_create: str = os.getcwd()
52
-
53
- # Build path to new dir
54
- full_path: str = os.path.join(path_to_create, name_temp_dir)
55
-
56
- # Create dir in this block
57
- try:
58
-
59
- # Successefully created
60
- os.makedirs(full_path, exist_ok=False)
61
-
62
- result['success'] = True
63
- result['path_created'] = fr'{full_path}'
64
-
65
- if display_message:
66
- success_print(f"Dir:'{full_path}' Created!")
67
-
68
- except FileExistsError:
69
- result['success'] = False
70
- result['path_created'] = None
71
- alert_print(f"Dir:'{full_path}' already exists.")
72
-
73
- except PermissionError:
74
- result['success'] = False
75
- result['path_created'] = None
76
- alert_print(f"Permission Denied: Not Able to create dir:'{full_path}'.")
77
-
78
- except Exception as e:
79
- result['success'] = False
80
- result['path_created'] = None
81
- error_print(f'Error capturing current path to create temporary directory! Error: {str(e)}')
82
-
83
- finally:
84
- return result
85
-
86
-
87
- def delete_temp_dir(path_to_delete: str = 'default', name_temp_dir: str='temp', delete_files: bool = False, display_message: bool = False) -> dict[str, Union[bool, str, None]]:
88
-
89
- """
90
- Function responsible for deleting a temporary directory. \n
91
-
92
- Parameters:
93
- ----------
94
- ``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.
95
-
96
- ``name_temp_dir: str`` - should be a string representing the name of the temporary directory to be deleted. If it is empty, the ``temp`` value will be used as the default directory name.
97
-
98
- ``delete_files: bool`` - should be a boolean indicating whether to delete files in the directory. If it is False, files in the directory will not be deleted.
99
-
100
- Return:
101
- ----------
102
- >>> type:dict
103
- * 'success': bool - represents case the action was performed successfully
104
- * 'path_deleted': str - path of the directory that was deleted on the process
105
-
106
- Description: pt-br
107
- ----------
108
- Função responsavel por deletar diretório temporário. \n
109
-
110
- Parametros:
111
- ----------
112
- ``path_to_delete: str`` - deve ser uma string com o path completo apontando para a pasta onde deve ser deletada a pasta temporaria, se estiver vazio sera usado valor ``default`` que deletará pasta no diretório atual onde o arquivo contendo esta função foi chamada.
113
-
114
- ``name_temp_dir: str`` - deve ser uma string representando o nome do diretório temporário a ser deletado. Se estiver vazio, o valor ``temp`` será usado como o nome padrão do diretório.
115
-
116
- ``delete_files: bool`` - deve ser um booleano indicando se deve deletar arquivos no diretório. Se for False, arquivos no diretório não serão deletados.
117
-
118
- Retorno:
119
- ----------
120
- >>> type:dict
121
- * 'success': bool - representa se ação foi realizada com sucesso
122
- * 'path_deleted': str - path do diretório que foi deletado no processo
123
- """
124
-
125
- # Local Variables
126
- result: dict = {
127
- 'success': bool,
128
- 'path_deleted': str,
129
- }
130
-
131
- try:
132
- # by 'default', defines path to local script execution path
133
- if path_to_delete == 'default':
134
- path_to_delete: str = os.getcwd()
135
-
136
- # Build path to new dir
137
- full_path: str = os.path.join(path_to_delete, name_temp_dir)
138
-
139
- # Delete dir in this block
140
- try:
141
-
142
- # Check if directory exists
143
- if os.path.exists(full_path):
144
-
145
- # Check if delete_files is True
146
- if delete_files:
147
- # Delete all files in the directory
148
- shutil.rmtree(full_path)
149
-
150
- else:
151
- # Delete the directory only
152
- os.rmdir(full_path)
153
-
154
- result['success'] = True
155
- result['path_deleted'] = fr'{full_path}'
156
-
157
- if display_message:
158
- success_print(f"Dir:'{full_path}' Deleted!")
159
-
160
- else:
161
- result['success'] = False
162
- result['path_deleted'] = None
163
- alert_print(f"Dir:'{full_path}' Don't exists.")
164
-
165
- except PermissionError:
166
- result['success'] = False
167
- result['path_deleted'] = None
168
- alert_print(f"Permission Denied: Not Able to delete dir: '{full_path}'.")
169
-
170
- except Exception as e:
171
- result['success'] = False
172
- result['path_deleted'] = None
173
- error_print(f'Error capturing current path to delete temporary directory! Error: {str(e)}')
174
-
175
- finally:
176
- return result
rpa_suite/log/__init__.py DELETED
@@ -1 +0,0 @@
1
- # /__init__.py
@@ -1,172 +0,0 @@
1
- # /functions_logger_uru.py
2
-
3
- from loguru import logger
4
- from rpa_suite.log.printer import error_print, alert_print
5
- import inspect, os
6
-
7
- def log_start_run_debug(msg_start_loggin: str) -> None: # represent start application
8
-
9
- """
10
- Function responsable to generate ``start run log level debug``, in file and print on terminal the same log captured on this call.
11
- """
12
-
13
- file_h: False
14
-
15
- try:
16
-
17
- from .logger_uru import config_logger
18
- file_h = config_logger()
19
-
20
- except Exception as e:
21
-
22
- error_print(f'To use log_start_run_debug you need instance file_handler using file "logger_uru" on one file in your project! Error: {str(e)}')
23
-
24
- try:
25
- try:
26
- if file_h:
27
- with open(file_h, 'a') as f:
28
- f.write('\n')
29
-
30
- except Exception as e:
31
- alert_print(f"Don't able to break_row for initial log!")
32
-
33
- # logger.debug(f'{msg_start_loggin}')
34
- frame = inspect.currentframe().f_back
35
- full_path_filename = frame.f_code.co_filename
36
-
37
- # Obtenha o nome do arquivo e o nome da pasta
38
- filename = os.path.basename(full_path_filename)
39
- foldername = os.path.basename(os.path.dirname(full_path_filename))
40
-
41
- # Combine o nome da pasta e o nome do arquivo
42
- filename = os.path.join(foldername, filename)
43
- lineno = frame.f_lineno
44
-
45
- # Vincule o nome do arquivo e a linha à mensagem de log
46
- logger.bind(filename=filename, lineno=lineno).debug(f'{msg_start_loggin}')
47
-
48
- except Exception as e:
49
- error_print(f'Error to execute function:{log_start_run_debug.__name__}! Error: {str(e)}')
50
-
51
-
52
- def log_debug(msg) -> None:
53
-
54
- """
55
- Function responsable to generate log level ``debug``, in file and print on terminal the same log captured on this call.
56
- """
57
-
58
- try:
59
- frame = inspect.currentframe().f_back
60
- full_path_filename = frame.f_code.co_filename
61
-
62
- # Obtem o nome do arquivo e o nome da pasta
63
- filename = os.path.basename(full_path_filename)
64
- foldername = os.path.basename(os.path.dirname(full_path_filename))
65
-
66
- # Combina o nome da pasta e o nome do arquivo
67
- filename = os.path.join(foldername, filename)
68
- lineno = frame.f_lineno
69
-
70
- # Vincula o nome do arquivo e a linha à mensagem de log
71
- logger.bind(filename=filename, lineno=lineno).debug(msg)
72
-
73
- except Exception as e:
74
- error_print(f'Error to execute function:{log_debug.__name__}! Error: {str(e)}')
75
-
76
- def log_info(msg) -> None:
77
-
78
- """
79
- Function responsable to generate log level ``info``, in file and print on terminal the same log captured on this call.
80
- """
81
-
82
- try:
83
- frame = inspect.currentframe().f_back
84
- full_path_filename = frame.f_code.co_filename
85
-
86
- # Obtem o nome do arquivo e o nome da pasta
87
- filename = os.path.basename(full_path_filename)
88
- foldername = os.path.basename(os.path.dirname(full_path_filename))
89
-
90
- # Combina o nome da pasta e o nome do arquivo
91
- filename = os.path.join(foldername, filename)
92
- lineno = frame.f_lineno
93
-
94
- # Vincula o nome do arquivo e a linha à mensagem de log
95
- logger.bind(filename=filename, lineno=lineno).info(msg)
96
-
97
- except Exception as e:
98
- error_print(f'Error to execute function:{log_info.__name__}! Error: {str(e)}')
99
-
100
- def log_warning(msg) -> None:
101
-
102
- """
103
- Function responsable to generate log level ``warning``, in file and print on terminal the same log captured on this call.
104
- """
105
-
106
- try:
107
- frame = inspect.currentframe().f_back
108
- full_path_filename = frame.f_code.co_filename
109
-
110
- # Obtenha o nome do arquivo e o nome da pasta
111
- filename = os.path.basename(full_path_filename)
112
- foldername = os.path.basename(os.path.dirname(full_path_filename))
113
-
114
- # Combine o nome da pasta e o nome do arquivo
115
- filename = os.path.join(foldername, filename)
116
- lineno = frame.f_lineno
117
-
118
- # Vincule o nome do arquivo e a linha à mensagem de log
119
- logger.bind(filename=filename, lineno=lineno).warning(msg)
120
-
121
- except Exception as e:
122
- error_print(f'Error to execute function:{log_warning.__name__}! Error: {str(e)}')
123
-
124
-
125
- def log_error(msg) -> None:
126
-
127
- """
128
- Function responsable to generate log level ``error``, in file and print on terminal the same log captured on this call.
129
- """
130
-
131
- try:
132
- frame = inspect.currentframe().f_back
133
- full_path_filename = frame.f_code.co_filename
134
-
135
- # Obtenha o nome do arquivo e o nome da pasta
136
- filename = os.path.basename(full_path_filename)
137
- foldername = os.path.basename(os.path.dirname(full_path_filename))
138
-
139
- # Combine o nome da pasta e o nome do arquivo
140
- filename = os.path.join(foldername, filename)
141
- lineno = frame.f_lineno
142
-
143
- # Vincule o nome do arquivo e a linha à mensagem de log
144
- logger.bind(filename=filename, lineno=lineno).error(msg)
145
-
146
- except Exception as e:
147
- error_print(f'Error to execute function:{log_error.__name__}! Error: {str(e)}')
148
-
149
-
150
- def log_critical(msg) -> None:
151
-
152
- """
153
- Function responsable to generate log level ``critical``, in file and print on terminal the same log captured on this call.
154
- """
155
-
156
- try:
157
- frame = inspect.currentframe().f_back
158
- full_path_filename = frame.f_code.co_filename
159
-
160
- # Obtenha o nome do arquivo e o nome da pasta
161
- filename = os.path.basename(full_path_filename)
162
- foldername = os.path.basename(os.path.dirname(full_path_filename))
163
-
164
- # Combine o nome da pasta e o nome do arquivo
165
- filename = os.path.join(foldername, filename)
166
- lineno = frame.f_lineno
167
-
168
- # Vincule o nome do arquivo e a linha à mensagem de log
169
- logger.bind(filename=filename, lineno=lineno).critical(msg)
170
-
171
- except Exception as e:
172
- error_print(f'Error to execute function:{log_critical.__name__}! Error: {str(e)}')
@@ -1,37 +0,0 @@
1
- # /log_decorator.py
2
-
3
- from typing import Callable
4
- from loguru import logger
5
-
6
- def logging_decorator(
7
- fn: Callable
8
- ) -> Callable:
9
-
10
- """
11
- Function responsible for displaying log message in the console for functions that are called. \n
12
- Displays function name, and the result of the function in case of return, without return returns None.
13
-
14
- Return:
15
- ----------
16
- A ``wrapper`` function with python decoration ``@logger.catch`` that received:
17
- * ``*args and **kwargs`` in the call parameters as an argument to result in the Log.
18
-
19
- Description: pt-br
20
- ----------
21
- Função responsavel por exibir mensagem de log no console para funções que são chamadas. \n
22
- Exibe nome da função, e o resultado da função em caso de retorno, sem retorno devolve None.
23
-
24
- Retorno:
25
- ----------
26
- Uma função ``wrapper`` com decoração ``@logger.catch`` do python que recebeu:
27
- * ``*args e **kwargs`` nos parametros de chamada como argumento para resultar no Log.
28
- """
29
-
30
- @logger.catch
31
- def wrapper(*args, **kwargs):
32
- logger.info('Function Called: {}', fn.__name__)
33
- result = fn(*args, **kwargs)
34
- logger.info('Function {} returned: {}', fn.__name__, result)
35
- return result
36
-
37
- return wrapper
@@ -1,110 +0,0 @@
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 with filtered words!'
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'Error to execute function:{config_logger.__name__}! Error: {str(e)}.')
110
- return None
@@ -1 +0,0 @@
1
- # /__init__.py
@@ -1,58 +0,0 @@
1
- # /pattern_in_text.py
2
-
3
- import re
4
- from rpa_suite.log.printer import error_print, success_print
5
-
6
-
7
- def check_pattern_in_text(origin_text: str,
8
- pattern_to_search: str,
9
- case_sensitive: bool = True,
10
- display_message: bool = False) -> bool:
11
-
12
- """
13
- Function responsible for searching in a string ``origin_text`` a pattern ``pattern_to_search`` and returning True if the pattern is found, otherwise False. ``case_sensitive`` used for exact cases or cases with diferencce upper and lower cases
14
-
15
- Return:
16
- ----------
17
- A boolean indicating whether the pattern was found in the text.
18
-
19
- Description: pt-br
20
- ----------
21
- Função responsável por buscar em um texto de leitura humana uma string ``origin_text`` por um padrão ``pattern_to_search`` e retornar True se o padrão for encontrado, caso contrário, False. ``case_sensitive`` usado para casos exatos ou casos com diferença entre caixa alta e baixa nos caracteres.
22
-
23
- Retorno:
24
- ----------
25
- Um booleano indicando se o padrão foi encontrado no texto.
26
- """
27
-
28
- try:
29
-
30
- if case_sensitive:
31
-
32
- # Check if the pattern is found in the text
33
- if re.search(pattern_to_search, origin_text):
34
- if display_message: success_print(f'Pattern found successfully!')
35
- return True
36
-
37
- else:
38
- if display_message: success_print(f'Pattern not found.')
39
- return False
40
- else:
41
-
42
- # normalize text to search without case sensitive
43
- origin_text = origin_text.lower()
44
- pattern_to_search = pattern_to_search.lower()
45
-
46
- # Check if the pattern is found in the text
47
- if re.search(pattern_to_search, origin_text):
48
- if display_message: success_print(f'Pattern found successfully!')
49
- return True
50
-
51
- else:
52
- if display_message: success_print(f'Pattern not found.')
53
- return False
54
-
55
- except Exception as e:
56
-
57
- error_print(f"Error when trying to check pattern in text. Error: {str(e)}")
58
- return False
@@ -1 +0,0 @@
1
- # /__init__.py