improve error handling
This commit is contained in:
parent
59159e4ad2
commit
5960e8b79a
@ -2,7 +2,8 @@ from os import path, getcwd, listdir, mkdir, makedirs, rename
|
||||
import re
|
||||
|
||||
def read_config(filepath):
|
||||
if not path.isfile(filepath): return False
|
||||
if not path.isfile(filepath):
|
||||
raise FileNotFoundError(f"read_config: Invalid filepath {filepath}")
|
||||
|
||||
file = open(filepath, 'r')
|
||||
keys = {}
|
||||
@ -26,13 +27,12 @@ def create_config():
|
||||
"""
|
||||
===================================================================================================
|
||||
Creating a new config
|
||||
Please enter at least one key and one directory.
|
||||
The key must be one single letter, a single digit number or some other keyboard key like .-#+&/ ...
|
||||
The key can not be 'q', 's', 'o' or 'u'.
|
||||
The directory must be a valid path to a directory, but is does not have to exist.
|
||||
You can use an absolute path (starting with '/', not '~') or a relative path (from here).
|
||||
===================================================================================================
|
||||
Please enter at least one key and one directory.
|
||||
The key must be one single letter, a single digit number or some other keyboard key like .-#+&/ ...
|
||||
The key can not be 'q', 's' or 'u'.
|
||||
The directory must be a valid path to a directory, but is does not have to exist.
|
||||
You can use an absolute path (starting with '/') or a relative path (from here).
|
||||
Do not use '~'!
|
||||
"""
|
||||
)
|
||||
|
||||
@ -93,9 +93,9 @@ def select_config():
|
||||
print(f"{n}: {conf}")
|
||||
|
||||
choice = input("Please select a config: ")
|
||||
if choice == "0": return False
|
||||
if choice == "0": return None
|
||||
elif choice in configs:
|
||||
return path.normpath(config_path + "/" + configs[choice])
|
||||
else:
|
||||
print("Invalid choice - creating new config")
|
||||
return False
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user