From 36145ca399846e482f4bd6bff4d9e73c9dfc8dfe Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Fri, 9 Oct 2015 11:28:54 +0200 Subject: [PATCH] Check if files exist before loading form That way if it will terminate, it will do so earlier --- relational_gui.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/relational_gui.py b/relational_gui.py index a1a33b4..f4de479 100755 --- a/relational_gui.py +++ b/relational_gui.py @@ -93,6 +93,14 @@ if __name__ == "__main__": ) sys.exit(3) + m = zip(files, map(os.path.isfile, files)) + invalid = ' '.join( + (i[0] for i in (filter(lambda x: not x[1], m))) + ) + if invalid: + print ("%s: not a file" % invalid, file=sys.stderr) + printhelp(12) + about.version = version surveyForm.version = version guihandler.version = version @@ -104,13 +112,6 @@ if __name__ == "__main__": form = guihandler.relForm() - m = zip(files, map(os.path.isfile, files)) - invalid = ' '.join( - (i[0] for i in (filter(lambda x: not x[1], m))) - ) - if invalid: - print ("%s: not a file" % invalid, file=sys.stderr) - printhelp(12) if len(files): form.loadRelation(files)