-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathler_dados.py
37 lines (32 loc) · 886 Bytes
/
ler_dados.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class LerDados():
def __init__(self) -> None:
pass
def __get_arquivo(self, nome_arquivo: str) -> str:
try:
if isinstance(nome_arquivo, str):
arquivo = self.__abrir_arquivo(nome_arquivo)
return arquivo
except BaseException as err:
print(f'__get_arquivo >>> {err}')
def __abrir_arquivo(self, nome_arquivo: str) -> str:
try:
texto = open(nome_arquivo, 'r')
return texto
except BaseException as err:
raise err
def __ler_texto(self, text: str) -> str:
try:
text = text.read()
return text
except:
print('Não conseguiu ler o arquivo')
def arquivoInterface(self, nome_arquivo) -> str:
'''
Método que retorna os dados dentro do arquivo em formato str
'''
try:
texto = self.__get_arquivo(nome_arquivo)
texto = self.__ler_texto(texto)
return texto
except BaseException as err:
print(f'arquivo interface >>> {err}')