rpa-suite 0.8.1__tar.gz → 0.8.3__tar.gz

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 (30) hide show
  1. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/PKG-INFO +20 -14
  2. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/README.md +8 -7
  3. rpa_suite-0.8.3/rpa_suite/clock/exec_at.py +118 -0
  4. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/clock/waiter.py +53 -11
  5. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/date/date.py +41 -8
  6. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/email/sender_smtp.py +42 -13
  7. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/file/counter.py +21 -5
  8. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/file/temp_dir.py +46 -21
  9. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/log/loggin.py +12 -2
  10. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/log/printer.py +64 -0
  11. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/suite.py +29 -3
  12. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/validate/mail_validator.py +25 -6
  13. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/validate/string_validator.py +41 -12
  14. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite.egg-info/PKG-INFO +20 -14
  15. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite.egg-info/SOURCES.txt +1 -1
  16. rpa_suite-0.8.3/setup.py +28 -0
  17. rpa_suite-0.8.1/rpa_suite/clock/exec_while.py +0 -64
  18. rpa_suite-0.8.1/setup.py +0 -23
  19. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/LICENSE +0 -0
  20. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/__init__.py +0 -0
  21. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/clock/__init__.py +0 -0
  22. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/date/__init__.py +0 -0
  23. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/email/__init__.py +0 -0
  24. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/file/__init__.py +0 -0
  25. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/log/__init__.py +0 -0
  26. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite/validate/__init__.py +0 -0
  27. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite.egg-info/dependency_links.txt +0 -0
  28. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite.egg-info/requires.txt +0 -0
  29. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/rpa_suite.egg-info/top_level.txt +0 -0
  30. {rpa_suite-0.8.1 → rpa_suite-0.8.3}/setup.cfg +0 -0
@@ -1,24 +1,29 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rpa_suite
3
- Version: 0.8.1
4
- Summary: Conjunto de ferramentas essenciais para RPA com Python, que facilitam o dia a dia de desenvolvimento.
3
+ Version: 0.8.3
4
+ Summary: Conjunto de ferramentas essenciais para Automação RPA com Python, que facilitam o dia a dia de desenvolvimento.
5
5
  Author: Camilo Costa de Carvalho
6
6
  Author-email: camilo.carvalho@triasoftware.com.br
7
7
  License: MIT
8
- Keywords: basic-tools,email-tools,email-validation,file-tools,simple-functions,rpa-tools,rpa-functions
8
+ Keywords: basic-tools,email-tools,email-validation,file-tools,simple-functions,rpa-tools,rpa-functions,Tools,Rpa,Automation,RPA,Automação,Python,Ferramentas de RPA,Automação de Processos,Biblioteca Python para RPA
9
9
  Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
10
13
  Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.7
13
- Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
20
  Description-Content-Type: text/markdown
16
21
  License-File: LICENSE
17
22
  Requires-Dist: loguru
18
23
  Requires-Dist: colorama
19
24
  Requires-Dist: email_validator
20
25
 
21
- ![RPA Suite](https://raw.githubusercontent.com/CamiloCCarvalho/rpa_suite/ca3820365ae7658ea8a2e801070f4f3b955b3ea6/logo-rpa-suite.svg)
26
+ ![RPA Suite](https://raw.githubusercontent.com/CamiloCCarvalho/rpa_suite/3e1ccd0acad654916466f03c2b8f166dc8d360d4/logo-rpa-suite.svg)
22
27
 
23
28
 
24
29
  <h1 align="left">
@@ -32,7 +37,7 @@ Requires-Dist: email_validator
32
37
  -----------------
33
38
 
34
39
  ## O que é?
35
- **RPA Suite:** um conjunto abrangente de ferramentas projetadas para simplificar e otimizar o desenvolvimento de projetos de automação RPA. Embora nossa suíte seja especializada em RPA, sua versatilidade a torna igualmente útil para uma ampla gama de projetos de desenvolvimento. Experimente a RPA Suite e descubra como podemos facilitar seu próximo projeto.
40
+ **RPA Suite:** um conjunto abrangente de ferramentas projetadas para simplificar e otimizar o desenvolvimento de projetos de automação RPA com Python. Embora nossa suíte seja um conjunto de Ferramentas de RPA especializado, sua versatilidade a torna igualmente útil para uma ampla gama de projetos de desenvolvimento. Esta desenvolvendo com Selenium, Botcity ou Playwright? Experimente a RPA Suite e descubra como podemos facilitar seu projeto, ou qualquer projeto de Robôs de Software.
36
41
 
37
42
  ## Sumário do conteudo
38
43
 
@@ -47,13 +52,13 @@ Requires-Dist: email_validator
47
52
 
48
53
  ## Destaque
49
54
 
50
- **Versátil**: Embora tenha sido criado com foco no desenvolvimento de BOTs em RPA, as ferramentas são de uso geral e podem ser aplicadas em outros tipos de projetos, *além do RPA*.
55
+ **Versátil**: Além da Automação de Processos e criação de BOT em RPA, mas também para uso geral podendo ser aplicadas em outros modelos de projeto, *além do RPA*.
51
56
 
52
57
  **Simples**: Construímos as ferramentas de maneira mais direta e assertiva possível, utilizando apenas bibliotecas conhecidas no mercado para garantir o melhor desempenho possível.
53
58
 
54
59
  ## Objetivo
55
60
 
56
- Nosso objetivo é tornar o desenvolvimento de RPAs mais produtivo, oferecendo funções prontas para usos comuns, como:
61
+ Nosso objetivo é se tornar a Biblioteca Python para RPA referência. Tornando o desenvolvimento de RPAs mais produtivo, oferecendo uma gama de funções para tal:
57
62
 
58
63
  - Envio de emails (já configurado e personalizavel)
59
64
  - Validação de emails (limpeza e tratamento)
@@ -116,7 +121,8 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
116
121
  O módulo principal do rpa-suite é dividido em categorias. Cada categoria contém módulos com funções destinadas a cada tipo de tarefa
117
122
  - **rpa_suite**
118
123
  - **clock**
119
- - **waiter** - Funções para aguardar execução
124
+ - **waiter** - Funções para aguardar em relação a execução de uma função, podendo ser antes ou depois
125
+ - **exec_at** - Funções para executar em momentos pré determinados
120
126
  - **date**
121
127
  - **date** - Funções para capturar data, mes, ano, hora, minutos de forma individual em apenas uma linha
122
128
  - **email**
@@ -134,9 +140,9 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
134
140
  - **string_validator** - Funções para validação/varredura (strings, substrings, palavras)
135
141
 
136
142
  ## Release
137
- Versão: **Alpha 0.8.1**
143
+ Versão: **Alpha 0.8.3**
138
144
 
139
- Lançamento: *04/12/2023*
145
+ Lançamento: *05/12/2023*
140
146
 
141
147
  Status: Em desenvolvimento.
142
148
 
@@ -1,4 +1,4 @@
1
- ![RPA Suite](https://raw.githubusercontent.com/CamiloCCarvalho/rpa_suite/ca3820365ae7658ea8a2e801070f4f3b955b3ea6/logo-rpa-suite.svg)
1
+ ![RPA Suite](https://raw.githubusercontent.com/CamiloCCarvalho/rpa_suite/3e1ccd0acad654916466f03c2b8f166dc8d360d4/logo-rpa-suite.svg)
2
2
 
3
3
 
4
4
  <h1 align="left">
@@ -12,7 +12,7 @@
12
12
  -----------------
13
13
 
14
14
  ## O que é?
15
- **RPA Suite:** um conjunto abrangente de ferramentas projetadas para simplificar e otimizar o desenvolvimento de projetos de automação RPA. Embora nossa suíte seja especializada em RPA, sua versatilidade a torna igualmente útil para uma ampla gama de projetos de desenvolvimento. Experimente a RPA Suite e descubra como podemos facilitar seu próximo projeto.
15
+ **RPA Suite:** um conjunto abrangente de ferramentas projetadas para simplificar e otimizar o desenvolvimento de projetos de automação RPA com Python. Embora nossa suíte seja um conjunto de Ferramentas de RPA especializado, sua versatilidade a torna igualmente útil para uma ampla gama de projetos de desenvolvimento. Esta desenvolvendo com Selenium, Botcity ou Playwright? Experimente a RPA Suite e descubra como podemos facilitar seu projeto, ou qualquer projeto de Robôs de Software.
16
16
 
17
17
  ## Sumário do conteudo
18
18
 
@@ -27,13 +27,13 @@
27
27
 
28
28
  ## Destaque
29
29
 
30
- **Versátil**: Embora tenha sido criado com foco no desenvolvimento de BOTs em RPA, as ferramentas são de uso geral e podem ser aplicadas em outros tipos de projetos, *além do RPA*.
30
+ **Versátil**: Além da Automação de Processos e criação de BOT em RPA, mas também para uso geral podendo ser aplicadas em outros modelos de projeto, *além do RPA*.
31
31
 
32
32
  **Simples**: Construímos as ferramentas de maneira mais direta e assertiva possível, utilizando apenas bibliotecas conhecidas no mercado para garantir o melhor desempenho possível.
33
33
 
34
34
  ## Objetivo
35
35
 
36
- Nosso objetivo é tornar o desenvolvimento de RPAs mais produtivo, oferecendo funções prontas para usos comuns, como:
36
+ Nosso objetivo é se tornar a Biblioteca Python para RPA referência. Tornando o desenvolvimento de RPAs mais produtivo, oferecendo uma gama de funções para tal:
37
37
 
38
38
  - Envio de emails (já configurado e personalizavel)
39
39
  - Validação de emails (limpeza e tratamento)
@@ -96,7 +96,8 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
96
96
  O módulo principal do rpa-suite é dividido em categorias. Cada categoria contém módulos com funções destinadas a cada tipo de tarefa
97
97
  - **rpa_suite**
98
98
  - **clock**
99
- - **waiter** - Funções para aguardar execução
99
+ - **waiter** - Funções para aguardar em relação a execução de uma função, podendo ser antes ou depois
100
+ - **exec_at** - Funções para executar em momentos pré determinados
100
101
  - **date**
101
102
  - **date** - Funções para capturar data, mes, ano, hora, minutos de forma individual em apenas uma linha
102
103
  - **email**
@@ -114,9 +115,9 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
114
115
  - **string_validator** - Funções para validação/varredura (strings, substrings, palavras)
115
116
 
116
117
  ## Release
117
- Versão: **Alpha 0.8.1**
118
+ Versão: **Alpha 0.8.3**
118
119
 
119
- Lançamento: *04/12/2023*
120
+ Lançamento: *05/12/2023*
120
121
 
121
122
  Status: Em desenvolvimento.
122
123
 
@@ -0,0 +1,118 @@
1
+ import time
2
+ from typing import Callable, Any
3
+ from datetime import datetime as dt
4
+ from rpa_suite.log.printer import error_print, success_print
5
+
6
+ def exec_at_hour(
7
+ hour_to_exec: str,
8
+ fn_to_exec: Callable[..., Any],
9
+ *args,
10
+ **kwargs,
11
+ ) -> dict:
12
+
13
+ """
14
+ Timed function, executes the function at the specified time, by ``default`` it executes at runtime, optionally you can choose the time for execution.
15
+
16
+ Parameters:
17
+ ----------
18
+ `hour_to_exec: 'xx:xx'` - time for function execution, if not passed the value will be by ``default`` at runtime at the time of this function call by the main code.
19
+
20
+ ``fn_to_exec: function`` - (function) to be called by the handler, if there are parameters in this function they can be passed as next arguments in ``*args`` and ``**kwargs``
21
+
22
+ Return:
23
+ ----------
24
+ >>> type:dict
25
+ * 'tried': bool - represents if it tried to execute the function passed in the argument
26
+ * 'success': bool - represents if there was success in trying to execute the requested function
27
+
28
+ Example:
29
+ ---------
30
+ Let's execute the function ``sum`` responsible for adding the values of a and b and return x``sum(a, b) -> x`` and we want the code to wait for the specific time to be executed at ``11:00``
31
+ >>> exec_at_hour("11:00", sum, 10, 5) -> 15 \n
32
+ * NOTE: `exec_at_hour` receives as first parameter the function that should be executed, then it can receive the arguments of the function, and explicitly we can define the time for execution.
33
+
34
+ Description: pt-br
35
+ ----------
36
+ Função temporizada, executa a função no horário especificado, por ``default`` executa no momento da chamada em tempo de execução, opcionalmente pode escolher o horário para execução.
37
+
38
+ Parâmetros:
39
+ ----------
40
+ `hour_to_exec: 'xx:xx'` - horário para execução da função, se não for passado o valor será por ``default`` em tempo de execução no momento da chamada desta função pelo cógido principal.
41
+
42
+ ``fn_to_exec: function`` - (função) a ser chamada pelo handler, se houver parâmetros nessa função podem ser passados como próximos argumentos em ``*args`` e ``**kwargs``
43
+
44
+ Retorno:
45
+ ----------
46
+ >>> type:dict
47
+ * 'tried': bool - representa se tentou executar a função passada no argumento
48
+ * 'success': bool - representa se houve sucesso ao tentar executar a função solicitada
49
+
50
+ Exemplo:
51
+ ---------
52
+ Vamos executar a função ``soma`` responsável por somar os valores de a e b e retornar x``soma(a, b) -> x`` e queremos que o código aguarde o horário especifico para ser executado de ``11:00``
53
+ >>> exec_at_hour("11:00", sum, 10, 5) -> 15 \n
54
+ * OBS.: `exec_at_hour` recebe como primeiro parâmetro a função que deve ser executada, em seguida pode receber os argumentos da função, e de forma explicitada podemos definir o horário para execução.
55
+ """
56
+
57
+ # Local Variables
58
+ result: dict = {
59
+ 'tried': bool,
60
+ 'successs': bool
61
+ }
62
+ run: bool
63
+ now: dt
64
+ hours: str
65
+ minutes: str
66
+ moment_now: str
67
+
68
+ # Preprocessing
69
+ run = True
70
+ now = dt.now()
71
+ hours = str(now.hour) if now.hour > 10 else f"0{now.hour}"
72
+ minutes = str(now.minute) if now.minute > 10 else f"0{now.minute}"
73
+ moment_now = f'{hours}:{minutes}'
74
+
75
+ if hour_to_exec == None:
76
+
77
+ # Process
78
+ while run:
79
+ try:
80
+ fn_to_exec(*args, **kwargs)
81
+ run = False
82
+ result['tried'] = not run
83
+ result['success'] = True
84
+ success_print(f'{fn_to_exec.__name__}: Successfully executed!')
85
+ break
86
+
87
+ except Exception as e:
88
+ run = False
89
+ result['tried'] = not run
90
+ result['success'] = False
91
+ error_print(f'An error occurred that prevented the function from executing: {fn_to_exec.__name__} correctly. Error: {str(e)}')
92
+ break
93
+ else:
94
+ # Executes the function call only at the time provided in the argument.
95
+ while run:
96
+ if moment_now == hour_to_exec:
97
+ try:
98
+ fn_to_exec(*args, **kwargs)
99
+ run = False
100
+ result['tried'] = not run
101
+ result['success'] = True
102
+ success_print(f'{fn_to_exec.__name__}: Successfully executed!')
103
+ break
104
+
105
+ except Exception as e:
106
+ run = False
107
+ result['tried'] = not run
108
+ result['success'] = False
109
+ error_print(f'An error occurred that prevented the function from executing: {fn_to_exec.__name__} correctly. Error: {str(e)}')
110
+ break
111
+ else:
112
+ time.sleep(30)
113
+ now = dt.now()
114
+ hours = str(now.hour) if now.hour > 10 else f"0{now.hour}"
115
+ minutes = str(now.minute) if now.minute > 10 else f"0{now.minute}"
116
+ moment_now = f'{hours}:{minutes}'
117
+
118
+ return result
@@ -1,5 +1,5 @@
1
- from typing import Callable, Any
2
1
  import time
2
+ from typing import Callable, Any
3
3
  from rpa_suite.log.printer import error_print, success_print
4
4
 
5
5
  def wait_for_exec(
@@ -10,6 +10,27 @@ def wait_for_exec(
10
10
  ) -> dict:
11
11
 
12
12
  """
13
+ Timer function, wait for a value in ``seconds`` to execute the function of the argument.
14
+
15
+ Parameters:
16
+ ----------
17
+ `wait_time: int` - (seconds) represents the time that should wait before executing the function passed as an argument.
18
+
19
+ ``fn_to_exec: function`` - (function) to be called after the waiting time, if there are parameters in this function they can be passed as next arguments of this function in ``*args`` and ``**kwargs``
20
+
21
+ Return:
22
+ ----------
23
+ >>> type:dict
24
+ * 'success': bool - represents if the action was performed successfully
25
+
26
+ Example:
27
+ ---------
28
+ We have a sum function in the following format ``sum(a, b) -> return x``, where ``x`` is the result of the sum. We want to wait `30 seconds` to execute this function, so:
29
+ >>> wait_for_exec(30, sum, 10, 5) -> 15 \n
30
+ * NOTE: `wait_for_exec` receives as first argument the time to wait (sec), then the function `sum` and finally the arguments that the function will use.
31
+
32
+ Description: pt-br
33
+ ----------
13
34
  Função temporizadora, aguardar um valor em ``segundos`` para executar a função do argumento.
14
35
 
15
36
  Parametros:
@@ -26,25 +47,25 @@ def wait_for_exec(
26
47
  Exemplo:
27
48
  ---------
28
49
  Temos uma função de soma no seguinte formato ``soma(a, b) -> return x``, onde ``x`` é o resultado da soma. Queremos aguardar `30 segundos` para executar essa função, logo:
29
- >>> wait_for_exec(30, soma, a, b) -> x \n
50
+ >>> wait_for_exec(30, soma, 10, 5) -> 15 \n
30
51
  * OBS.: `wait_for_exec` recebe como primeiro argumento o tempo a aguardar (seg), depois a função `soma` e por fim os argumentos que a função ira usar.
31
52
  """
32
53
 
33
- # Variáveis locais
54
+ # Local Variables
34
55
  result: dict = {
35
56
  'success': bool
36
57
  }
37
58
 
38
- # Processo
59
+ # Process
39
60
  try:
40
61
  time.sleep(wait_time)
41
62
  fn_to_exec(*args, **kwargs)
42
63
  result['success'] = True
43
- success_print(f'A função:: {wait_for_exec.__name__} executou a função: {fn_to_exec.__name__}.')
64
+ success_print(f'Function: {wait_for_exec.__name__} executed the function: {fn_to_exec.__name__}.')
44
65
 
45
66
  except Exception as e:
46
67
  result['success'] = False
47
- error_print(f'Erro ao tentar aguardar para executar a função: {fn_to_exec.__name__} \nMensagem: {str(e)}')
68
+ error_print(f'Error while trying to wait to execute the function: {fn_to_exec.__name__} \nMessage: {str(e)}')
48
69
 
49
70
  return result
50
71
 
@@ -56,6 +77,27 @@ def exec_and_wait(
56
77
  ) -> dict:
57
78
 
58
79
  """
80
+ Timer function, executes a function and waits for the time in ``seconds``
81
+
82
+ Parameters:
83
+ ----------
84
+ `wait_time: int` - (seconds) represents the time that should wait after executing the requested function
85
+
86
+ ``fn_to_exec: function`` - (function) to be called before the time to wait, if there are parameters in this function they can be passed as an argument after the function, being: ``*args`` and ``**kwargs``
87
+
88
+ Return:
89
+ ----------
90
+ >>> type:dict
91
+ * 'success': bool - represents if the action was performed successfully
92
+
93
+ Example:
94
+ ---------
95
+ We have a sum function in the following format ``sum(a, b) -> return x``, where ``x`` is the result of the sum. We want to execute the sum and then wait `30 seconds` to continue the main code:
96
+ >>> wait_for_exec(30, sum, 10, 5) -> 15 \n
97
+ * NOTE: `wait_for_exec` receives as first argument the time to wait (sec), then the function `sum` and finally the arguments that the function will use.
98
+
99
+ Description: pt-br
100
+ ----------
59
101
  Função temporizadora, executa uma função e aguarda o tempo em ``segundos``
60
102
 
61
103
  Parametros:
@@ -72,24 +114,24 @@ def exec_and_wait(
72
114
  Exemplo:
73
115
  ---------
74
116
  Temos uma função de soma no seguinte formato ``soma(a, b) -> return x``, onde ``x`` é o resultado da soma. Queremos executar a soma e então aguardar `30 segundos` para continuar o código principal:
75
- >>> wait_for_exec(30, soma, a, b) -> x \n
117
+ >>> wait_for_exec(30, soma, 10, 5) -> 15 \n
76
118
  * OBS.: `wait_for_exec` recebe como primeiro argumento o tempo a aguardar (seg), depois a função `soma` e por fim os argumentos que a função ira usar.
77
119
  """
78
120
 
79
- # Variáveis locais
121
+ # Local Variables
80
122
  result: dict = {
81
123
  'success': bool
82
124
  }
83
125
 
84
- # Processo
126
+ # Process
85
127
  try:
86
128
  fn_to_exec(*args, **kwargs)
87
129
  time.sleep(wait_time)
88
130
  result['success'] = True
89
- success_print(f'A função:: {wait_for_exec.__name__} executou a função: {fn_to_exec.__name__}.')
131
+ success_print(f'Function: {wait_for_exec.__name__} executed the function: {fn_to_exec.__name__}.')
90
132
 
91
133
  except Exception as e:
92
134
  result['success'] = False
93
- error_print(f'Erro ao tentar aguardar para executar a função: {fn_to_exec.__name__} \nMensagem: {str(e)}')
135
+ error_print(f'Error while trying to wait to execute the function: {fn_to_exec.__name__} \nMessage: {str(e)}')
94
136
 
95
137
  return result
@@ -4,7 +4,26 @@ from rpa_suite.log.printer import error_print
4
4
 
5
5
 
6
6
  def get_hms() -> tuple:
7
+
7
8
  """
9
+ Function to return hour, minute and second. The return is in the form of a tuple with strings being able to store and use the values individually.
10
+
11
+ Treatment:
12
+ ----------
13
+ The function already does the treatment for values below 10 always keeping 2 decimal places in all results, the individual values are always in string format
14
+
15
+ Return:
16
+ ----------
17
+ >>> type:tuple
18
+ * tuple('hh', 'mm', 'ss') - tuple with the values of hour, minute and second being able to be stored individually, the values are in string
19
+
20
+ Example:
21
+ ---------
22
+ >>> hour, minute, second = get_hms() \n
23
+ * NOTE: Note that it is possible to destructure the return to store simultaneously.
24
+
25
+ Description: pt-br
26
+ ----------
8
27
  Função para retornar hora, minuto e segundo. O retorno é em forma de tupla com strings podendo armazenar e usar os valores de forma individual.
9
28
 
10
29
  Tratamento:
@@ -22,18 +41,18 @@ def get_hms() -> tuple:
22
41
  * OBS.: Note que é possivel desestruturar o retorno para armazenar de forma simultânea.
23
42
  """
24
43
 
25
- # Variáiveis locais
44
+ # Local Variables
26
45
  hours: str
27
46
  minutes: str
28
47
  seconds: str
29
48
 
30
- # Pré tratamento
49
+ # Preprocessing
31
50
  now = dt.datetime.now()
32
51
  hours: str = str(now.hour) if now.hour > 10 else f"0{now.hour}"
33
52
  minutes: str = str(now.minute) if now.minute > 10 else f"0{now.minute}"
34
53
  seconds: str = str(now.second) if now.second > 10 else f"0{now.second}"
35
54
 
36
- # Processo
55
+ # Process
37
56
  try:
38
57
  if len(hours) == 3 or len(minutes) == 3 or len(seconds) == 3:
39
58
  if len(seconds) == 3:
@@ -45,10 +64,24 @@ def get_hms() -> tuple:
45
64
 
46
65
  return hours, minutes, seconds
47
66
  except Exception as e:
48
- return error_print(f'Não foi possivel capturar o horário. Erro: {str(e)}')
67
+ return error_print(f'Unable to capture the time. Error: {str(e)}')
49
68
 
50
69
  def get_dma() -> tuple:
51
70
  """
71
+ Function to return day, month and year. The return is in the form of a tuple with strings being able to store and use the values individually.
72
+
73
+ Return:
74
+ ----------
75
+ >>> type:tuple
76
+ * tuple('dd', 'mm', 'yy') - tuple with the values of day, month and year being able to be stored individually
77
+
78
+ Example:
79
+ ---------
80
+ >>> day, month, year = get_hms() \n
81
+ * NOTE: Note that it is possible to destructure the return to store simultaneously.
82
+
83
+ Description: pt-br
84
+ ----------
52
85
  Função para retornar dia, mes e ano. O retorno é em forma de tupla com strings podendo armazenar e usar os valores de forma individual.
53
86
 
54
87
  Retorno:
@@ -62,15 +95,15 @@ def get_dma() -> tuple:
62
95
  * OBS.: Note que é possivel desestruturar o retorno para armazenar de forma simultânea.
63
96
  """
64
97
 
65
- # Variáiveis locais
98
+ # Local Variables
66
99
  day_got: str
67
100
  month_got: str
68
101
  year_got: str
69
102
 
70
- # Pré tratamento
103
+ # Preprocessing
71
104
  now = dt.datetime.now()
72
105
 
73
- # Processo
106
+ # Process
74
107
  try:
75
108
  day_got: str = str(now.day) if now.day > 10 else f"0{now.day}"
76
109
  month_got: str = str(now.month) if now.month > 10 else f"0{now.month}"
@@ -79,4 +112,4 @@ def get_dma() -> tuple:
79
112
  return day_got, month_got, year_got
80
113
 
81
114
  except Exception as e:
82
- return error_print(f'Não foi possivel capturar o horário. Erro: {str(e)}')
115
+ return error_print(f'Unable to capture the time. Error: {str(e)}')
@@ -19,6 +19,36 @@ def send_email(
19
19
  ) -> dict:
20
20
 
21
21
  """
22
+ Function responsible for sending emails ``(SMTP)``, accepts ``list of recipients`` and possibility
23
+ of ``attaching files``. \n
24
+
25
+ Parameters:
26
+ ----------
27
+ ``email_from: str`` - email from who will send the email.
28
+ ``pass_from: str`` - password of the account used, advised to isolate the password elsewhere.
29
+ ``email_to: list[str]`` - list of emails to which the emails will be sent.
30
+ ``subject_title: str`` - email title.
31
+ ``body_message: str``- body message of the email.
32
+ ``attachments: list[str]`` - list with path of attachments if any. (default None).
33
+ ``type_content: str`` - type of message content can be 'plain' or 'html' (default 'html').
34
+ ``smtp_server: str`` - server to be used to connect with the email account (default 'smtp.office365.com')
35
+ ``smtp_port: int`` - port to be used on this server (default 587)
36
+
37
+ Return:
38
+ ----------
39
+ >>> type:dict
40
+ a dictionary with all information that may be necessary about the emails.
41
+ Respectively being:
42
+ * 'success': bool - if there was at least one successful shipment
43
+ * 'all_mails': list - list of all emails parameterized for sending
44
+ * 'valid_mails': list - list of all valid emails for sending
45
+ * 'invalid_mails': list - list of all invalid emails for sending
46
+ * 'qt_mails_sent': int - effective quantity that was sent
47
+ * 'attchament': bool - if there are attachments
48
+ * 'qt_attach': int - how many attachments were inserted
49
+
50
+ Description: pt-br
51
+ ----------
22
52
  Função responsavel por enviar emails ``(SMTP)``, aceita ``lista de destinatários`` e possibilidade
23
53
  de ``anexar arquivos``. \n
24
54
 
@@ -48,7 +78,7 @@ def send_email(
48
78
  * 'qt_attach': int - quantos anexos foram inseridos
49
79
  """
50
80
 
51
- # Variáveis locais
81
+ # Local Variables
52
82
  result: dict = {
53
83
  'success': bool,
54
84
  'all_mails': list,
@@ -61,20 +91,19 @@ def send_email(
61
91
  email_valido = []
62
92
  email_invalido = []
63
93
 
64
- # Pré Tratamentos
94
+ # Preprocessing
65
95
  result['success'] = False
66
96
  result['qt_mails_sent'] = 0
67
97
  result['attchament'] = False
68
98
 
69
- # Configuração inicial basica.
70
99
  msg = MIMEMultipart()
71
100
  msg['From'] = email_from
72
101
  msg['Subject'] = subject_title
73
102
 
74
- # Adicionar corpo da mensagem
103
+ # Email Body Content
75
104
  msg.attach(MIMEText(body_message, type_content))
76
105
 
77
- # Adicionar anexos, se houver
106
+ # Add Attachment
78
107
  if attachments:
79
108
  result['attchament'] = True
80
109
  for path_to_attach in attachments:
@@ -90,14 +119,14 @@ def send_email(
90
119
  result['attchament'] = False
91
120
  result['qt_attach'] = 0
92
121
 
93
- # Conectar ao servidor SMTP e enviar email
122
+ # SMTP server config
94
123
  try:
95
124
  server_by_smtp = smtplib.SMTP(smtp_server, smtp_port)
96
125
  server_by_smtp.starttls()
97
126
  server_by_smtp.login(email_from, pass_from)
98
127
  email_content = msg.as_string()
99
128
 
100
- # Trata a lista de emails antes de tentar realizar o envio, mantendo apenas emails validos
129
+ # Treats the email list before trying to send, keeping only valid emails
101
130
  try:
102
131
  for emails in email_to:
103
132
  try:
@@ -108,9 +137,9 @@ def send_email(
108
137
  email_invalido.append(emails)
109
138
 
110
139
  except Exception as e:
111
- error_print(f'Erro ao tentar validar lista de emails: {str(e)}')
140
+ error_print(f'Error while trying to validate email list: {str(e)}')
112
141
 
113
- # anexa a lista de emails tratada para realizar o envio
142
+ # Attaches the treated email list to perform the sending
114
143
  msg['To'] = ', '.join(email_valido)
115
144
  for email in email_valido:
116
145
  try:
@@ -119,18 +148,18 @@ def send_email(
119
148
  result['all_mails'] = email_to
120
149
 
121
150
  except smtplib.SMTPException as e:
122
- error_print(f'O email: {email} não foi enviado, por causa do erro: {str(e)}')
151
+ error_print(f"The email: {email} don't sent, caused by error: {str(e)}")
123
152
 
124
153
  server_by_smtp.quit()
125
154
  result['success'] = True
126
- success_print(f'Email(s) enviado(s) com sucesso!')
155
+ success_print(f'Email(s) Sent!')
127
156
 
128
157
 
129
158
  except smtplib.SMTPException as e:
130
159
  result['success'] = False
131
- error_print(f'Erro ao enviar email(s): {str(e)}')
160
+ error_print(f'Error while trying sent Email: {str(e)}')
132
161
 
133
- # Pós Tratamento
162
+ # Postprocessing
134
163
  result['valid_mails'] = email_valido
135
164
  result['invalid_mails'] = email_invalido
136
165
 
@@ -7,6 +7,22 @@ def count_files(
7
7
  ) -> dict:
8
8
 
9
9
  """
10
+ Function responsible for counting files within a folder, considers subfolders to do the count, searches by file type, being all files by default. \n
11
+
12
+ Parameters:
13
+ ----------
14
+ ``dir_to_count: list`` - should be a list, accepts more than one path to count files.
15
+ ``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.
16
+
17
+
18
+ Return:
19
+ ----------
20
+ >>> type:dict
21
+ * 'success': bool - represents if the action was performed successfully
22
+ * 'qt': int - number that represents the quantity of files that were counted
23
+
24
+ Description: pt-br
25
+ ----------
10
26
  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
11
27
 
12
28
  Parametros:
@@ -22,17 +38,17 @@ def count_files(
22
38
  * 'qt': int - numero que representa a quantidade de arquivos que foram contados
23
39
  """
24
40
 
25
- # Variáveis locais
41
+ # Local Variables
26
42
  result: dict = {
27
43
  'success': bool,
28
44
  'qt': int
29
45
  }
30
46
 
31
- # Pré tratamento
47
+ # Preprocessing
32
48
  result['qt'] = 0
33
49
  result['success'] = False
34
50
 
35
- # Processo
51
+ # Process
36
52
  try:
37
53
  for dir in dir_to_count:
38
54
  for current_dir, sub_dir, files in os.walk(dir):
@@ -40,10 +56,10 @@ def count_files(
40
56
  if file.endswith(f'.{type_extension}'):
41
57
  result['qt'] += 1
42
58
  result['success'] = True
43
- success_print(f'Função: {count_files.__name__} encontrou {result['qt']} arquivos.')
59
+ success_print(f'Function: {count_files.__name__} counted {result['qt']} files.')
44
60
 
45
61
  except Exception as e:
46
62
  result['success'] = False
47
- error_print(f'Erro ao tentar fazer contagem de arquivos! Erro: {str(e)}')
63
+ error_print(f'Error when trying to count files! Error: {str(e)}')
48
64
 
49
65
  return result