csc-cia-stne 0.0.23__py3-none-any.whl → 0.0.24__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.
@@ -1,2 +1 @@
1
- from .functions import titulo, recriar_pasta
2
- from .classes import Util
1
+ from .functions import titulo, recriar_pasta, b64encode, b64decode, convert_bquery_result_to_json
@@ -1,2 +1,4 @@
1
1
  from .func_titulo import titulo
2
- from .func_recriar_pastas import recriar_pasta
2
+ from .func_recriar_pastas import recriar_pasta
3
+ from .func_b64 import b64decode, b64encode
4
+ from .func_converters import convert_bquery_result_to_json
@@ -0,0 +1,50 @@
1
+ import base64
2
+
3
+ def b64decode(b64_string:str=None)->str:
4
+ """Faz o decode de uma string em base64
5
+
6
+ Args:
7
+ b64_string (str): string em base64
8
+
9
+ Returns:
10
+ str: string em texto
11
+ """
12
+
13
+ if b64_string is None or b64_string == "":
14
+
15
+ raise ValueError("Uma string Base64 precisa ser informada com o parâmetro 'b64_string'")
16
+
17
+ try:
18
+
19
+ b64_decode_output = base64.b64decode(b64_string).decode('utf-8')
20
+
21
+ except:
22
+
23
+ raise TypeError("A string informada não está em formato Base64")
24
+
25
+ return b64_decode_output
26
+
27
+ def b64encode(string_to_convert:str=None)->base64:
28
+ """Faz o encode de uma string para base64
29
+
30
+ Args:
31
+ string_to_convert (str): string para converter em base64
32
+
33
+ Returns:
34
+ base64: string convertida para base64
35
+ """
36
+
37
+ if string_to_convert is None or string_to_convert == "":
38
+
39
+ raise ValueError("Uma string precisa ser informada com o parâmetro 'string_to_convert'")
40
+
41
+ try:
42
+
43
+ b64_encode_output = base64.b64encode(str(string_to_convert).encode('utf-8')).decode('utf-8')
44
+
45
+ except Exception as e:
46
+
47
+ raise TypeError(f"Erro ao converter a string para Base64: {e}")
48
+
49
+ return b64_encode_output
50
+
@@ -0,0 +1,18 @@
1
+ def convert_bquery_result_to_json(query_result:list)->list:
2
+ """Converte o resultado de uma query do BigQuery em uma lista de dicionários JSON
3
+
4
+ Args:
5
+ query_result (list): resultado da query do BigQuery (query.result)
6
+
7
+ Returns:
8
+ list: lista de dicionários JSON
9
+ """
10
+
11
+ try:
12
+
13
+ #return [dict(row) for row in query_result]
14
+ return [dict(row._asdict()) for row in query_result]
15
+
16
+ except Exception as e:
17
+
18
+ raise e
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: csc_cia_stne
3
- Version: 0.0.23
3
+ Version: 0.0.24
4
4
  Summary: Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs
5
5
  License: MIT
6
6
  Keywords: karavela,csc,cia,stone,rpa
@@ -7,13 +7,14 @@ csc_cia_stne/logger_json.py,sha256=2G0rm0lyCtHn4o2v7fzn4wMylb0A_nbxiQatnrSZxHs,1
7
7
  csc_cia_stne/logger_rich.py,sha256=yW1py7k5yY5Fay5I_eY-ulMGGSmFGGhUl3Q4U8aczbo,3392
8
8
  csc_cia_stne/servicenow.py,sha256=vSsNSANFyCZtDu2O7YmdoCbr-_bO1sgMWnOI29mFBOA,23311
9
9
  csc_cia_stne/stne_admin.py,sha256=G5ozXt18VjKL2BHtROQk4GnfVY1xM14RXSQ-rra_D54,15487
10
- csc_cia_stne/utilitarios/__init__.py,sha256=xd5PD-mNT8iPtzpJuPkseqCaiDBYtj83tsgexKlU3XM,70
11
- csc_cia_stne/utilitarios/classes.py,sha256=LU8YrELiRIW4UxqULjiUPYmgbEx79NGenK5QKRdSh_E,2050
12
- csc_cia_stne/utilitarios/functions/__init__.py,sha256=Vz0tbVaClNnQXTxFB1Nt-_YccYSEbZGmE6w7jctViQ4,78
10
+ csc_cia_stne/utilitarios/__init__.py,sha256=4YFhzxu8F_CDHU6iaNhpzz9mfX-8wfJc1XEQInJzwJ4,98
11
+ csc_cia_stne/utilitarios/functions/__init__.py,sha256=X0PmuSe0RilU824Lvlg-DtO0qDb_D_VfL4ftzR93d40,180
12
+ csc_cia_stne/utilitarios/functions/func_b64.py,sha256=XGU34BIQQXWXBS0yM2B4A2wDlcrMl1unIJXjq4lpLnk,1254
13
+ csc_cia_stne/utilitarios/functions/func_converters.py,sha256=EY1zvlBaRX7G1MceVSiRXwwKDQDZwUO9iECBL0fe5iU,481
13
14
  csc_cia_stne/utilitarios/functions/func_recriar_pastas.py,sha256=2_unoSoQHxShcMw_0XIL9F0NgiF1QCKsX4drvg0fEb8,415
14
15
  csc_cia_stne/utilitarios/functions/func_titulo.py,sha256=EhUtsiIOAz4yERNZl3EOHjiFLjj4rK3pr_KB0DxwGIA,3943
15
- csc_cia_stne-0.0.23.dist-info/LICENCE,sha256=LPGMtgKki2C3KEZP7hDhA1HBrlq5JCHkIeStUCLEMx4,1073
16
- csc_cia_stne-0.0.23.dist-info/METADATA,sha256=TafVrKPHz43vNDeEtOACTCKuLiho7zwlvTasP4hZz7c,1003
17
- csc_cia_stne-0.0.23.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
18
- csc_cia_stne-0.0.23.dist-info/top_level.txt,sha256=ldo7GVv3tQx5KJvwBzdZzzQmjPys2NDVVn1rv0BOF2Q,13
19
- csc_cia_stne-0.0.23.dist-info/RECORD,,
16
+ csc_cia_stne-0.0.24.dist-info/LICENCE,sha256=LPGMtgKki2C3KEZP7hDhA1HBrlq5JCHkIeStUCLEMx4,1073
17
+ csc_cia_stne-0.0.24.dist-info/METADATA,sha256=CiP_W79ifwOjgz6TbKMAVpl0BczsgxhdNQqpZN2G-ow,1003
18
+ csc_cia_stne-0.0.24.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
19
+ csc_cia_stne-0.0.24.dist-info/top_level.txt,sha256=ldo7GVv3tQx5KJvwBzdZzzQmjPys2NDVVn1rv0BOF2Q,13
20
+ csc_cia_stne-0.0.24.dist-info/RECORD,,
@@ -1,72 +0,0 @@
1
- import base64
2
-
3
- class Util():
4
- """Classe Util com necessidades de rotina
5
- """
6
-
7
- def b64decode(self,b64_string:str=None)->str:
8
- """Faz o decode de uma string em base64
9
-
10
- Args:
11
- b64_string (str): string em base64
12
-
13
- Returns:
14
- str: string em texto
15
- """
16
-
17
- if b64_string is None or b64_string == "":
18
-
19
- raise ValueError("Uma string Base64 precisa ser informada com o parâmetro 'b64_string'")
20
-
21
- try:
22
-
23
- b64_decode_output = base64.b64decode(b64_string).decode('utf-8')
24
-
25
- except:
26
-
27
- raise TypeError("A string informada não está em formato Base64")
28
-
29
- return b64_decode_output
30
-
31
- def b64encode(self,string_to_convert:str=None)->base64:
32
- """Faz o encode de uma string para base64
33
-
34
- Args:
35
- string_to_convert (str): string para converter em base64
36
-
37
- Returns:
38
- base64: string convertida para base64
39
- """
40
-
41
- if string_to_convert is None or string_to_convert == "":
42
-
43
- raise ValueError("Uma string precisa ser informada com o parâmetro 'string_to_convert'")
44
-
45
- try:
46
-
47
- b64_encode_output = base64.b64encode(str(string_to_convert).encode('utf-8')).decode('utf-8')
48
-
49
- except Exception as e:
50
-
51
- raise TypeError(f"Erro ao converter a string para Base64: {e}")
52
-
53
- return b64_encode_output
54
-
55
- def convert_query_result_to_json(self,query_result:list)->list:
56
- """Converte o resultado de uma query do BigQuery em uma lista de dicionários JSON
57
-
58
- Args:
59
- query_result (list): resultado da query do BigQuery (query.result)
60
-
61
- Returns:
62
- list: lista de dicionários JSON
63
- """
64
-
65
- try:
66
-
67
- #return [dict(row) for row in query_result]
68
- return [dict(row._asdict()) for row in query_result]
69
-
70
- except Exception as e:
71
-
72
- raise e