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.
@@ -7,8 +7,7 @@ from rpa_suite.functions._printer import error_print, success_print
7
7
  import email_validator
8
8
 
9
9
 
10
- class Validate():
11
-
10
+ class Validate:
12
11
  """
13
12
  Class responsible for validating email addresses and searching for words within text.
14
13
 
@@ -30,22 +29,17 @@ class Validate():
30
29
 
31
30
  A classe utiliza a biblioteca email_validator para realizar a validação rigorosa dos endereços de e-mail, garantindo que os dados fornecidos estejam corretos e prontos para uso em aplicações que requerem comunicação via e-mail. Além disso, fornece métodos para busca de palavras em textos, aumentando sua utilidade para o processamento de texto.
32
31
  """
33
-
34
- def __init__(self):
35
- ...
36
-
37
- def emails(self,
38
- email_list: list[str],
39
- display_message: bool = False
40
- ) -> dict:
41
-
32
+
33
+ def __init__(self): ...
34
+
35
+ def emails(self, email_list: list[str], display_message: bool = False) -> dict:
42
36
  """
43
37
  Function responsible for rigorously validating a list of emails using the email_validator library. \n
44
-
38
+
45
39
  Parameters:
46
40
  ------------
47
41
  ``email_list: list`` a list of strings containing the emails to be validated
48
-
42
+
49
43
  Return:
50
44
  ------------
51
45
  >>> type: dict
@@ -56,15 +50,15 @@ class Validate():
56
50
  * 'qt_valids': int - number of valid emails
57
51
  * 'qt_invalids': int - number of invalid emails
58
52
  * 'map_validation' - map of the validation of each email
59
-
53
+
60
54
  Description: pt-br
61
55
  ----------
62
56
  Função responsavel por validar de forma rigorosa lista de emails usando a biblioteca email_validator. \n
63
-
57
+
64
58
  Paramentros:
65
59
  ------------
66
60
  ``email_list: list`` uma lista de strings contendo os emails a serem validados
67
-
61
+
68
62
  Retorno:
69
63
  ------------
70
64
  >>> type: dict
@@ -76,23 +70,22 @@ class Validate():
76
70
  * 'qt_invalids': int - quantidade de emails invalidos
77
71
  * 'map_validation' - mapa da validação de cada email
78
72
  """
79
-
73
+
80
74
  # Local Variables
81
75
  result: dict = {
82
- 'success': bool,
83
- 'valid_emails': list,
84
- 'invalid_emails': list,
85
- 'qt_valids': int,
86
- 'qt_invalids': int,
87
- 'map_validation': list[dict]
76
+ "success": bool,
77
+ "valid_emails": list,
78
+ "invalid_emails": list,
79
+ "qt_valids": int,
80
+ "qt_invalids": int,
81
+ "map_validation": list[dict],
88
82
  }
89
83
 
90
-
91
84
  # Preprocessing
92
85
  validated_emails: list = []
93
86
  invalid_emails: list = []
94
87
  map_validation: list[dict] = []
95
-
88
+
96
89
  # Process
97
90
  try:
98
91
  for email in email_list:
@@ -100,52 +93,51 @@ class Validate():
100
93
  v = email_validator.validate_email(email)
101
94
  validated_emails.append(email)
102
95
  map_validation.append(v)
103
-
96
+
104
97
  except email_validator.EmailNotValidError:
105
98
  invalid_emails.append(email)
106
-
107
- if display_message: success_print(f'Function: {self.emails.__name__} executed.')
99
+
100
+ if display_message:
101
+ success_print(f"Function: {self.emails.__name__} executed.")
108
102
 
109
103
  except Exception as e:
110
- error_print(f'Error when trying to validate email list: {str(e)}')
104
+ error_print(f"Error when trying to validate email list: {str(e)}")
111
105
 
112
-
113
106
  # Postprocessing
114
107
  result = {
115
- 'success': len(invalid_emails) == 0,
116
- 'valid_emails': validated_emails,
117
- 'invalid_emails': invalid_emails,
118
- 'qt_valids': len(validated_emails),
119
- 'qt_invalids': len(invalid_emails),
120
- 'map_validation': map_validation
108
+ "success": len(invalid_emails) == 0,
109
+ "valid_emails": validated_emails,
110
+ "invalid_emails": invalid_emails,
111
+ "qt_valids": len(validated_emails),
112
+ "qt_invalids": len(invalid_emails),
113
+ "map_validation": map_validation,
121
114
  }
122
-
123
- return result
124
115
 
116
+ return result
125
117
 
126
- def word(self,
127
- origin_text: str,
128
- searched_word: str,
129
- case_sensitivy: bool = True,
130
- search_by: str = 'string',
131
- display_message: bool = False
132
- ) -> dict:
133
-
118
+ def word(
119
+ self,
120
+ origin_text: str,
121
+ searched_word: str,
122
+ case_sensitivy: bool = True,
123
+ search_by: str = "string",
124
+ display_message: bool = False,
125
+ ) -> dict:
134
126
  """
135
127
  Function responsible for searching for a string, substring or word within a provided text. \n
136
-
128
+
137
129
  Parameters:
138
130
  -----------
139
131
  ``origin_text: str`` \n
140
-
132
+
141
133
  * It is the text where the search should be made, in string format. \n
142
-
134
+
143
135
  ``search_by: str`` accepts the values: \n
144
-
136
+
145
137
  * 'string' - can find a requested writing excerpt. (default) \n
146
138
  * 'word' - finds only the word written out exclusively. \n
147
139
  * 'regex' - find regex patterns, [ UNDER DEVELOPMENT ...] \n
148
-
140
+
149
141
  Return:
150
142
  -----------
151
143
  >>> type:dict
@@ -154,28 +146,28 @@ class Validate():
154
146
  * 'is_found': bool - if the pattern was found in at least one case
155
147
  * 'number_occurrences': int - represents the number of times this pattern was found
156
148
  * 'positions': list[set(int, int), ...] - represents all positions where the pattern appeared in the original text
157
-
149
+
158
150
  About `Positions`:
159
151
  -----------
160
152
  >>> type: list[set(int, int), ...]
161
153
  * at `index = 0` we find the first occurrence of the text, and the occurrence is composed of a PAIR of numbers in a set, the other indexes represent other positions where occurrences were found if any.
162
-
154
+
163
155
  Description: pt-br
164
156
  ----------
165
157
  Função responsavel por fazer busca de uma string, sbustring ou palavra dentro de um texto fornecido. \n
166
-
158
+
167
159
  Parametros:
168
160
  -----------
169
161
  ``origin_text: str`` \n
170
-
162
+
171
163
  * É o texto onde deve ser feita a busca, no formato string. \n
172
-
164
+
173
165
  ``search_by: str`` aceita os valores: \n
174
-
166
+
175
167
  * 'string' - consegue encontrar um trecho de escrita solicitado. (default) \n
176
168
  * 'word' - encontra apenas a palavra escrita por extenso exclusivamente. \n
177
169
  * 'regex' - encontrar padrões de regex, [ EM DESENVOLVIMENTO ...] \n
178
-
170
+
179
171
  Retorno:
180
172
  -----------
181
173
  >>> type:dict
@@ -184,62 +176,73 @@ class Validate():
184
176
  * 'is_found': bool - se o pattern foi encontrado em pelo menos um caso
185
177
  * 'number_occurrences': int - representa o número de vezes que esse pattern foi econtrado
186
178
  * 'positions': list[set(int, int), ...] - representa todas posições onde apareceu o pattern no texto original
187
-
179
+
188
180
  Sobre o `Positions`:
189
181
  -----------
190
182
  >>> type: list[set(int, int), ...]
191
183
  * no `index = 0` encontramos a primeira ocorrência do texto, e a ocorrência é composta por um PAR de números em um set, os demais indexes representam outras posições onde foram encontradas ocorrências caso hajam.
192
184
  """
193
-
185
+
194
186
  # Local Variables
195
- result: dict = {
196
- 'is_found': False,
197
- 'number_occurrences': 0,
198
- 'positions': []
199
- }
187
+ result: dict = {"is_found": False, "number_occurrences": 0, "positions": []}
200
188
 
201
189
  # Preprocessing
202
- result['is_found'] = False
190
+ result["is_found"] = False
203
191
 
204
192
  # Process
205
193
  try:
206
- if search_by == 'word':
194
+ if search_by == "word":
207
195
  origin_words = origin_text.split()
208
196
  try:
209
197
  if case_sensitivy:
210
- result['number_occurrences'] = origin_words.count(searched_word)
211
- result['is_found'] = result['number_occurrences'] > 0
198
+ result["number_occurrences"] = origin_words.count(searched_word)
199
+ result["is_found"] = result["number_occurrences"] > 0
212
200
  else:
213
201
  words_lowercase = [word.lower() for word in origin_words]
214
202
  searched_word_lower = searched_word.lower()
215
- result['number_occurrences'] = words_lowercase.count(searched_word_lower)
216
- result['is_found'] = result['number_occurrences'] > 0
217
-
203
+ result["number_occurrences"] = words_lowercase.count(
204
+ searched_word_lower
205
+ )
206
+ result["is_found"] = result["number_occurrences"] > 0
207
+
218
208
  except Exception as e:
219
- return error_print(f'Unable to complete the search: {searched_word}. Error: {str(e)}')
220
-
221
- elif search_by == 'string':
209
+ return error_print(
210
+ f"Unable to complete the search: {searched_word}. Error: {str(e)}"
211
+ )
212
+
213
+ elif search_by == "string":
222
214
  try:
223
215
  if case_sensitivy:
224
- result['number_occurrences'] = origin_text.count(searched_word)
225
- result['is_found'] = result['number_occurrences'] > 0
216
+ result["number_occurrences"] = origin_text.count(searched_word)
217
+ result["is_found"] = result["number_occurrences"] > 0
226
218
  else:
227
219
  origin_text_lower = origin_text.lower()
228
220
  searched_word_lower = searched_word.lower()
229
- result['number_occurrences'] = origin_text_lower.count(searched_word_lower)
230
- result['is_found'] = result['number_occurrences'] > 0
231
-
221
+ result["number_occurrences"] = origin_text_lower.count(
222
+ searched_word_lower
223
+ )
224
+ result["is_found"] = result["number_occurrences"] > 0
225
+
232
226
  except Exception as e:
233
- return error_print(f'Unable to complete the search: {searched_word}. Error: {str(e)}')
227
+ return error_print(
228
+ f"Unable to complete the search: {searched_word}. Error: {str(e)}"
229
+ )
234
230
 
235
231
  except Exception as e:
236
- return error_print(f'Unable to search for: {searched_word}. Error: {str(e)}')
232
+ return error_print(
233
+ f"Unable to search for: {searched_word}. Error: {str(e)}"
234
+ )
237
235
 
238
236
  # Postprocessing
239
- if result['is_found']:
240
- if display_message: success_print(f'Function: {self.word.__name__} found: {result["number_occurrences"]} occurrences for "{searched_word}".')
237
+ if result["is_found"]:
238
+ if display_message:
239
+ success_print(
240
+ f'Function: {self.word.__name__} found: {result["number_occurrences"]} occurrences for "{searched_word}".'
241
+ )
241
242
  else:
242
- if display_message: success_print(f'Function: {self.word.__name__} found no occurrences of "{searched_word}" during the search.')
243
+ if display_message:
244
+ success_print(
245
+ f'Function: {self.word.__name__} found no occurrences of "{searched_word}" during the search.'
246
+ )
243
247
 
244
248
  return result
245
-
@@ -8,9 +8,9 @@ import os
8
8
  from typing import Union
9
9
 
10
10
 
11
-
12
- def __create_ss_dir(path_to_create: str = 'default', name_ss_dir: str='screenshots') -> dict[str, Union[bool, str, None]]:
13
-
11
+ def __create_ss_dir(
12
+ path_to_create: str = "default", name_ss_dir: str = "screenshots"
13
+ ) -> dict[str, Union[bool, str, None]]:
14
14
  """
15
15
  Function responsible for creating a screenshots directory to work with your screenshot files. \n
16
16
 
@@ -25,7 +25,7 @@ def __create_ss_dir(path_to_create: str = 'default', name_ss_dir: str='screensho
25
25
  >>> type:dict
26
26
  * 'success': bool - represents case the action was performed successfully
27
27
  * 'path_created': str - path of the directory that was created on the process
28
-
28
+
29
29
  Description: pt-br
30
30
  ----------
31
31
  Função responsavel por criar diretório de screenshots para trabalhar com seus arquivos de sreenshot. \n
@@ -42,16 +42,16 @@ def __create_ss_dir(path_to_create: str = 'default', name_ss_dir: str='screensho
42
42
  * 'success': bool - representa se ação foi realizada com sucesso
43
43
  * 'path_created': str - path do diretório que foi criado no processo
44
44
  """
45
-
45
+
46
46
  # Local Variables
47
47
  result: dict = {
48
- 'success': bool,
49
- 'path_created': str,
48
+ "success": bool,
49
+ "path_created": str,
50
50
  }
51
-
51
+
52
52
  try:
53
53
  # by 'default', defines path to local script execution path
54
- if path_to_create == 'default':
54
+ if path_to_create == "default":
55
55
  path_to_create: str = os.getcwd()
56
56
 
57
57
  # Build path to new dir
@@ -63,25 +63,29 @@ def __create_ss_dir(path_to_create: str = 'default', name_ss_dir: str='screensho
63
63
  # Successefully created
64
64
  os.makedirs(full_path, exist_ok=False)
65
65
 
66
- result['success'] = True
67
- result['path_created'] = fr'{full_path}'
66
+ result["success"] = True
67
+ result["path_created"] = rf"{full_path}"
68
68
 
69
69
  success_print(f"Diretório:'{full_path}' foi criado com sucesso.")
70
70
 
71
71
  except FileExistsError:
72
- result['success'] = False
73
- result['path_created'] = full_path
72
+ result["success"] = False
73
+ result["path_created"] = full_path
74
74
  # alert_print(f"Diretório:'{full_path}' já existe.")
75
75
 
76
76
  except PermissionError:
77
- result['success'] = False
78
- result['path_created'] = None
79
- alert_print(f"Permissão negada: não é possível criar o diretório '{full_path}'.")
77
+ result["success"] = False
78
+ result["path_created"] = None
79
+ alert_print(
80
+ f"Permissão negada: não é possível criar o diretório '{full_path}'."
81
+ )
80
82
 
81
83
  except Exception as e:
82
- result['success'] = False
83
- result['path_created'] = None
84
- error_print(f'Error capturing current path to create screenshots directory! Error: {str(e)}')
85
-
84
+ result["success"] = False
85
+ result["path_created"] = None
86
+ error_print(
87
+ f"Error capturing current path to create screenshots directory! Error: {str(e)}"
88
+ )
89
+
86
90
  finally:
87
91
  return result
@@ -1 +1 @@
1
- # rpa_suite/functions/__init__.py
1
+ # rpa_suite/functions/__init__.py
@@ -5,18 +5,18 @@ from colorama import Fore
5
5
 
6
6
 
7
7
  # Windows bash colors
8
- class Colors():
9
- black = f'{Fore.BLACK}'
10
- blue = f'{Fore.BLUE}'
11
- green = f'{Fore.GREEN}'
12
- cyan = f'{Fore.CYAN}'
13
- red = f'{Fore.RED}'
14
- magenta = f'{Fore.MAGENTA}'
15
- yellow = f'{Fore.YELLOW}'
16
- white = f'{Fore.WHITE}'
17
- default = f'{Fore.WHITE}'
18
- call_fn = f'{Fore.LIGHTMAGENTA_EX}'
19
- retur_fn = f'{Fore.LIGHTYELLOW_EX}'
8
+ class Colors:
9
+ black = f"{Fore.BLACK}"
10
+ blue = f"{Fore.BLUE}"
11
+ green = f"{Fore.GREEN}"
12
+ cyan = f"{Fore.CYAN}"
13
+ red = f"{Fore.RED}"
14
+ magenta = f"{Fore.MAGENTA}"
15
+ yellow = f"{Fore.YELLOW}"
16
+ white = f"{Fore.WHITE}"
17
+ default = f"{Fore.WHITE}"
18
+ call_fn = f"{Fore.LIGHTMAGENTA_EX}"
19
+ retur_fn = f"{Fore.LIGHTYELLOW_EX}"
20
20
 
21
21
 
22
22
  def success_print(string_text: str, color=Colors.green, ending="\n") -> None:
@@ -35,7 +35,7 @@ def success_print(string_text: str, color=Colors.green, ending="\n") -> None:
35
35
  ----------
36
36
  >>> type:None
37
37
  """
38
- print(f'{color}{string_text}{Colors.default}', end=ending)
38
+ print(f"{color}{string_text}{Colors.default}", end=ending)
39
39
 
40
40
 
41
41
  def alert_print(string_text: str, color=Colors.yellow, ending="\n") -> None:
@@ -53,7 +53,7 @@ def alert_print(string_text: str, color=Colors.yellow, ending="\n") -> None:
53
53
  ----------
54
54
  >>> type:None
55
55
  """
56
- print(f'{color}{string_text}{Colors.default}', end=ending)
56
+ print(f"{color}{string_text}{Colors.default}", end=ending)
57
57
 
58
58
 
59
59
  def info_print(string_text: str, color=Colors.cyan, ending="\n") -> None:
@@ -71,7 +71,7 @@ def info_print(string_text: str, color=Colors.cyan, ending="\n") -> None:
71
71
  ----------
72
72
  >>> type:None
73
73
  """
74
- print(f'{color}{string_text}{Colors.default}', end=ending)
74
+ print(f"{color}{string_text}{Colors.default}", end=ending)
75
75
 
76
76
 
77
77
  def error_print(string_text: str, color=Colors.red, ending="\n") -> None:
@@ -89,7 +89,7 @@ def error_print(string_text: str, color=Colors.red, ending="\n") -> None:
89
89
  ----------
90
90
  >>> type:None
91
91
  """
92
- print(f'{color}{string_text}{Colors.default}', end=ending)
92
+ print(f"{color}{string_text}{Colors.default}", end=ending)
93
93
 
94
94
 
95
95
  def magenta_print(string_text: str, color=Colors.magenta, ending="\n") -> None:
@@ -107,7 +107,7 @@ def magenta_print(string_text: str, color=Colors.magenta, ending="\n") -> None:
107
107
  ----------
108
108
  >>> type:None
109
109
  """
110
- print(f'{color}{string_text}{Colors.default}', end=ending)
110
+ print(f"{color}{string_text}{Colors.default}", end=ending)
111
111
 
112
112
 
113
113
  def blue_print(string_text: str, color=Colors.blue, ending="\n") -> None:
@@ -125,7 +125,7 @@ def blue_print(string_text: str, color=Colors.blue, ending="\n") -> None:
125
125
  ----------
126
126
  >>> type:None
127
127
  """
128
- print(f'{color}{string_text}{Colors.default}', end=ending)
128
+ print(f"{color}{string_text}{Colors.default}", end=ending)
129
129
 
130
130
 
131
131
  def print_call_fn(string_text: str, color=Colors.call_fn, ending="\n") -> None:
@@ -144,7 +144,7 @@ def print_call_fn(string_text: str, color=Colors.call_fn, ending="\n") -> None:
144
144
  ----------
145
145
  >>> type:None
146
146
  """
147
- print(f'{color}{string_text}{Colors.default}', end=ending)
147
+ print(f"{color}{string_text}{Colors.default}", end=ending)
148
148
 
149
149
 
150
150
  def print_retur_fn(string_text: str, color=Colors.retur_fn, ending="\n") -> None:
@@ -163,4 +163,4 @@ def print_retur_fn(string_text: str, color=Colors.retur_fn, ending="\n") -> None
163
163
  ----------
164
164
  >>> type:None
165
165
  """
166
- print(f'{color}{string_text}{Colors.default}', end=ending)
166
+ print(f"{color}{string_text}{Colors.default}", end=ending)