We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f6b75b3 commit 195f7faCopy full SHA for 195f7fa
file-operations/file_utils.py
@@ -5,6 +5,9 @@ def remove_accents(string):
5
return unidecode(string)
6
7
def get_file_content(file):
8
+ file_extention = get_file_extention(file)
9
+ if file_extention != '.txt':
10
+ raise NotImplementedError('Only .txt files are available')
11
with open(file, 'r') as f:
12
file_string = f.read()
13
return file_string
@@ -14,3 +17,11 @@ def store_file_content(content, file='new_file.txt'):
14
17
with open(file, 'w') as f:
15
18
f.write(content)
16
19
return file
20
+
21
+def get_file_extention(file: str):
22
+ if file.startswith('.'):
23
+ dot = file.find('.', 1)
24
+ dot = file.find('.')
25
+ if dot < 0:
26
+ raise ValueError('extention not found')
27
+ return file[dot:]
0 commit comments