I am working on an app that will be something like a text editor, using kivy. I included a FileChooser to choose a file to edit, I included a try except to catch the problems of files readability like videos and executable files.The problem is that this doesn't work and it raises an error of decode so the try except didn't work as expected. I am thinking now of something like precising the extentions of files to open.But I would like to request from you a list of extensions that python can read. Please Help I think no need to share my code because there is nothing specific in it and I think my request is clear:
A list of extensions that python can read. Ok so here is my check function that is called when a user click a button after choosing a file(This is in kivy by the way):
def check(self):
app= App.get_running_app()
with open(os.path.join(sys.path[0], "data.txt"), "r") as f:
dataa= f.read()
data= dataa.split('\n')
if self.namee.text in dataa:
for i in data:
ii = i.split(':')
if ii[1] == self.namee.text and ii[3]== self.password.text:
self.btn.text="Identified successfully!!"
time.sleep(0.5)
break
else:
self.btn.text="Not identified successfully!!"
elif self.password.text.strip() =="":
try:
with codecs.open(self.namee.text, 'r', encoding="utf-8", errors='ignore') as file:
try:
test = file.read()
print(test)
self.btn.text=="Identified successfully!!"
except:
self.btn.text ="Oops! Couldn't access the content of this file, try again later or verify your typing."
self.btn.text=="Identified successfully!!"
except:
self.btn.text ="Oops! Couldn't open the file, try again later or verify your typing."
else:
self.btn.text = "Cannot find any secret file with this name!"
if self.btn.text=="Identified successfully!!":
app.root.current = "control"
self.btn.text = "open"
self.namee.text = ""
self.password.text = ""