Open the right file

This commit is contained in:
Juhani Krekelä 2018-09-01 22:03:31 +03:00
parent 7754f17cc9
commit 2a1ed46ddd
1 changed files with 4 additions and 2 deletions

View File

@ -10,8 +10,9 @@ def open_all():
raise KeyError('$HOME is not set') from err
# If the directory doesn't exist, just return empty
sshwot_dir_path = os.path.join(homedir, '.sshwot')
try:
sshwot_dir = os.listdir(os.path.join(homedir, '.sshwot'))
sshwot_dir = os.listdir(sshwot_dir_path)
except FileNotFoundError:
return []
@ -19,6 +20,7 @@ def open_all():
files = []
for dir_entry in sshwot_dir:
if dir_entry.split('.')[-1] == 'sshwot':
files.append(open(dir_entry, 'rb'))
path = os.path.join(sshwot_dir_path, dir_entry)
files.append(open(path, 'rb'))
return files