test wether the file exists before opening

This commit is contained in:
waldek 2021-05-24 17:24:46 +02:00
parent 897c3943c1
commit 6672e8d1d2
1 changed files with 3 additions and 0 deletions

View File

@ -125,6 +125,9 @@ if __name__ == "__main__":
parser.add_argument("-n", "--number", default=10, help="number of questions to ask", type=int, action="store") parser.add_argument("-n", "--number", default=10, help="number of questions to ask", type=int, action="store")
args = parser.parse_args() args = parser.parse_args()
filepath = pathlib.Path(args.file) filepath = pathlib.Path(args.file)
if not filepath.exists():
print("no such file!")
exit(1)
interface = Tui() interface = Tui()
app = Application(filepath, interface, args.number) app = Application(filepath, interface, args.number)
try: try: