Adds more file error handling and corrects a bad module reference
This commit is contained in:
parent
720c7bda1f
commit
8ae7793337
7
chalk
7
chalk
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue