0
0
Fork 0

Adds more file error handling and corrects a bad module reference

This commit is contained in:
sloum 2020-08-08 22:15:33 +00:00
parent 720c7bda1f
commit 8ae7793337
1 changed files with 5 additions and 2 deletions

7
chalk
View File

@ -193,7 +193,7 @@ def build_contents_from_file(path):
valid_path = validate_path(filepath)
if not valid_path:
print('Invalid file path')
os.exit(2)
sys.exit(2)
with open(filepath, 'r') as f:
content = f.read().split('\n')
@ -201,9 +201,12 @@ def build_contents_from_file(path):
content.pop()
except FileNotFoundError:
content = []
except IsADirectoryError:
print('The given filepath is a directory')
sys.exit(2)
except PermissionError:
print('You do not have permission to read {}'.format(path))
os.exit(2)
sys.exit(2)
# Yes No queries the user with a yes no question and returns